src/share/classes/javax/swing/text/html/StyleSheet.java
Print this page
*** 190,199 ****
--- 190,200 ----
public Style getRule(HTML.Tag t, Element e) {
SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
try {
// Build an array of all the parent elements.
+ @SuppressWarnings("unchecked")
Vector<Element> searchContext = sb.getVector();
for (Element p = e; p != null; p = p.getParentElement()) {
searchContext.addElement(p);
}
*** 691,701 ****
* it is removed from old. The resulting AttributeSet is then returned.
*/
private AttributeSet removeHTMLTags(AttributeSet old, AttributeSet attr) {
if (!(attr instanceof LargeConversionSet) &&
!(attr instanceof SmallConversionSet)) {
! Enumeration names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object key = names.nextElement();
if (key instanceof StyleConstants) {
--- 692,702 ----
* it is removed from old. The resulting AttributeSet is then returned.
*/
private AttributeSet removeHTMLTags(AttributeSet old, AttributeSet attr) {
if (!(attr instanceof LargeConversionSet) &&
!(attr instanceof SmallConversionSet)) {
! Enumeration<?> names = attr.getAttributeNames();
while (names.hasMoreElements()) {
Object key = names.nextElement();
if (key instanceof StyleConstants) {
*** 724,741 ****
return a;
}
// in most cases, there are no StyleConstants attributes
// so we iterate the collection of keys to avoid creating
// a new set.
! Enumeration names = a.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
if (name instanceof StyleConstants) {
// we really need to do a conversion, iterate again
// building a new set.
MutableAttributeSet converted = new LargeConversionSet();
! Enumeration keys = a.getAttributeNames();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object cssValue = null;
if (key instanceof StyleConstants) {
// convert the StyleConstants attribute if possible
--- 725,742 ----
return a;
}
// in most cases, there are no StyleConstants attributes
// so we iterate the collection of keys to avoid creating
// a new set.
! Enumeration<?> names = a.getAttributeNames();
while (names.hasMoreElements()) {
Object name = names.nextElement();
if (name instanceof StyleConstants) {
// we really need to do a conversion, iterate again
// building a new set.
MutableAttributeSet converted = new LargeConversionSet();
! Enumeration<?> keys = a.getAttributeNames();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object cssValue = null;
if (key instanceof StyleConstants) {
// convert the StyleConstants attribute if possible
*** 1076,1085 ****
--- 1077,1087 ----
*/
/* protected */
String[] getSimpleSelectors(String selector) {
selector = cleanSelectorString(selector);
SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
+ @SuppressWarnings("unchecked")
Vector<String> selectors = sb.getVector();
int lastIndex = 0;
int length = selector.length();
while (lastIndex != -1) {
int newIndex = selector.indexOf(' ', lastIndex);
*** 1254,1264 ****
/**
* Returns the resolved style for <code>selector</code>. This will
* create the resolved style, if necessary.
*/
private synchronized Style getResolvedStyle(String selector,
! Vector elements,
HTML.Tag t) {
Style retStyle = resolvedStyles.get(selector);
if (retStyle == null) {
retStyle = createResolvedStyle(selector, elements, t);
}
--- 1256,1266 ----
/**
* Returns the resolved style for <code>selector</code>. This will
* create the resolved style, if necessary.
*/
private synchronized Style getResolvedStyle(String selector,
! Vector<Element> elements,
HTML.Tag t) {
Style retStyle = resolvedStyles.get(selector);
if (retStyle == null) {
retStyle = createResolvedStyle(selector, elements, t);
}
*** 1366,1376 ****
--- 1368,1380 ----
*/
private synchronized Style createResolvedStyle(String selector,
String[] tags,
String[] ids, String[] classes) {
SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
+ @SuppressWarnings("unchecked")
Vector<SelectorMapping> tempVector = sb.getVector();
+ @SuppressWarnings("unchecked")
Hashtable<SelectorMapping, SelectorMapping> tempHashtable = sb.getHashtable();
// Determine all the Styles that are appropriate, placing them
// in tempVector
try {
SelectorMapping mapping = getRootSelectorMapping();
*** 1450,1469 ****
* first Element is the deepest Element, with the last Element
* representing the root.
* @param t the Tag to use for
* the first Element in <code>elements</code>
*/
! private Style createResolvedStyle(String selector, Vector elements,
HTML.Tag t) {
int numElements = elements.size();
// Build three arrays, one for tags, one for class's, and one for
// id's
String tags[] = new String[numElements];
String ids[] = new String[numElements];
String classes[] = new String[numElements];
for (int counter = 0; counter < numElements; counter++) {
! Element e = (Element)elements.elementAt(counter);
AttributeSet attr = e.getAttributes();
if (counter == 0 && e.isLeaf()) {
// For leafs, we use the second tier attributes.
Object testAttr = attr.getAttribute(t);
if (testAttr instanceof AttributeSet) {
--- 1454,1473 ----
* first Element is the deepest Element, with the last Element
* representing the root.
* @param t the Tag to use for
* the first Element in <code>elements</code>
*/
! private Style createResolvedStyle(String selector, Vector<Element> elements,
HTML.Tag t) {
int numElements = elements.size();
// Build three arrays, one for tags, one for class's, and one for
// id's
String tags[] = new String[numElements];
String ids[] = new String[numElements];
String classes[] = new String[numElements];
for (int counter = 0; counter < numElements; counter++) {
! Element e = elements.elementAt(counter);
AttributeSet attr = e.getAttributes();
if (counter == 0 && e.isLeaf()) {
// For leafs, we use the second tier attributes.
Object testAttr = attr.getAttribute(t);
if (testAttr instanceof AttributeSet) {
*** 1511,1520 ****
--- 1515,1525 ----
* in <code>selector</code> is separated by a space.
*/
private Style createResolvedStyle(String selector) {
SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
// Will contain the tags, ids, and classes, in that order.
+ @SuppressWarnings("unchecked")
Vector<String> elements = sb.getVector();
try {
boolean done;
int dotIndex = 0;
int spaceIndex;
*** 1676,1685 ****
--- 1681,1691 ----
* Hashtable. This is used to avoid allocing a lot of garbage when
* searching for rules. Use the static method obtainSearchBuffer and
* releaseSearchBuffer to get a SearchBuffer, and release it when
* done.
*/
+ @SuppressWarnings("rawtypes")
private static class SearchBuffer {
/** A stack containing instances of SearchBuffer. Used in getting
* rules. */
static Stack<SearchBuffer> searchBuffers = new Stack<SearchBuffer>();
// A set of temporary variables that can be used in whatever way.
*** 2628,2637 ****
--- 2634,2644 ----
// PENDING(prinz) fix this up to be a more realistic
// implementation.
Document doc = v.getDocument();
SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
+ @SuppressWarnings("unchecked")
Vector<AttributeSet> muxList = sb.getVector();
try {
if (doc instanceof HTMLDocument) {
StyleSheet styles = StyleSheet.this;
Element elem = v.getElement();
*** 2640,2650 ****
if (htmlAttr.getAttributeCount() != 0) {
muxList.addElement(htmlAttr);
}
if (elem.isLeaf()) {
! Enumeration keys = a.getAttributeNames();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (key instanceof HTML.Tag) {
if (key == HTML.Tag.A) {
Object o = a.getAttribute(key);
--- 2647,2657 ----
if (htmlAttr.getAttributeCount() != 0) {
muxList.addElement(htmlAttr);
}
if (elem.isLeaf()) {
! Enumeration<?> keys = a.getAttributeNames();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
if (key instanceof HTML.Tag) {
if (key == HTML.Tag.A) {
Object o = a.getAttribute(key);