diff options
Diffstat (limited to 'libjava/classpath/javax/swing/text')
10 files changed, 45 insertions, 40 deletions
diff --git a/libjava/classpath/javax/swing/text/AbstractDocument.java b/libjava/classpath/javax/swing/text/AbstractDocument.java index 72178f840f3..29b20b321fb 100644 --- a/libjava/classpath/javax/swing/text/AbstractDocument.java +++ b/libjava/classpath/javax/swing/text/AbstractDocument.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing.text; +import gnu.java.lang.CPStringBuilder; + import java.awt.font.TextAttribute; import java.io.PrintStream; import java.io.Serializable; @@ -2013,7 +2015,7 @@ public abstract class AbstractDocument implements Document, Serializable */ public void dump(PrintStream stream, int indent) { - StringBuffer b = new StringBuffer(); + CPStringBuilder b = new CPStringBuilder(); for (int i = 0; i < indent; ++i) b.append(' '); b.append('<'); diff --git a/libjava/classpath/javax/swing/text/DefaultEditorKit.java b/libjava/classpath/javax/swing/text/DefaultEditorKit.java index aa69deca545..0d999a38096 100644 --- a/libjava/classpath/javax/swing/text/DefaultEditorKit.java +++ b/libjava/classpath/javax/swing/text/DefaultEditorKit.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing.text; +import gnu.java.lang.CPStringBuilder; + import java.awt.Toolkit; import java.awt.event.ActionEvent; @@ -1634,7 +1636,7 @@ public class DefaultEditorKit extends EditorKit BufferedReader reader = new BufferedReader(in); String line; - StringBuffer content = new StringBuffer(); + CPStringBuilder content = new CPStringBuilder(); while ((line = reader.readLine()) != null) { diff --git a/libjava/classpath/javax/swing/text/DefaultStyledDocument.java b/libjava/classpath/javax/swing/text/DefaultStyledDocument.java index 341579e3df8..8c70a8a3bfd 100644 --- a/libjava/classpath/javax/swing/text/DefaultStyledDocument.java +++ b/libjava/classpath/javax/swing/text/DefaultStyledDocument.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing.text; +import gnu.java.lang.CPStringBuilder; + import java.awt.Color; import java.awt.Font; import java.io.Serializable; @@ -374,7 +376,7 @@ public class DefaultStyledDocument extends AbstractDocument implements */ public String toString() { - StringBuilder b = new StringBuilder(); + CPStringBuilder b = new CPStringBuilder(); switch (type) { case StartTagType: @@ -2420,7 +2422,7 @@ public class DefaultStyledDocument extends AbstractDocument implements writeLock(); // First we collect the content to be inserted. - StringBuffer contentBuffer = new StringBuffer(); + CPStringBuilder contentBuffer = new CPStringBuilder(); for (int i = 0; i < data.length; i++) { // Collect all inserts into one so we can get the correct diff --git a/libjava/classpath/javax/swing/text/JTextComponent.java b/libjava/classpath/javax/swing/text/JTextComponent.java index 8e70fe2bb2b..24035e35ac2 100644 --- a/libjava/classpath/javax/swing/text/JTextComponent.java +++ b/libjava/classpath/javax/swing/text/JTextComponent.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing.text; +import gnu.java.lang.CPStringBuilder; + import java.awt.AWTEvent; import java.awt.Color; import java.awt.Container; @@ -2016,7 +2018,7 @@ public abstract class JTextComponent extends JComponent d.putProperty(Document.StreamDescriptionProperty, streamDescription); } - StringBuffer b = new StringBuffer(); + CPStringBuilder b = new CPStringBuilder(); int c; // Read till -1 (EOF). diff --git a/libjava/classpath/javax/swing/text/MaskFormatter.java b/libjava/classpath/javax/swing/text/MaskFormatter.java index 581cceb617d..4ebf65b9332 100644 --- a/libjava/classpath/javax/swing/text/MaskFormatter.java +++ b/libjava/classpath/javax/swing/text/MaskFormatter.java @@ -38,6 +38,8 @@ exception statement from your version. */ package javax.swing.text; +import gnu.java.lang.CPStringBuilder; + import java.text.ParseException; import javax.swing.JFormattedTextField; @@ -311,7 +313,7 @@ public class MaskFormatter extends DefaultFormatter private String convertStringToValue(String value) throws ParseException { - StringBuffer result = new StringBuffer(); + CPStringBuilder result = new CPStringBuilder(); char valueChar; boolean isPlaceHolder; @@ -447,7 +449,7 @@ public class MaskFormatter extends DefaultFormatter private String convertValueToString(String value) throws ParseException { - StringBuffer result = new StringBuffer(); + CPStringBuilder result = new CPStringBuilder(); char valueChar; boolean isPlaceHolder; diff --git a/libjava/classpath/javax/swing/text/TabSet.java b/libjava/classpath/javax/swing/text/TabSet.java index 0f2c8c7c1ee..c08a650fb11 100644 --- a/libjava/classpath/javax/swing/text/TabSet.java +++ b/libjava/classpath/javax/swing/text/TabSet.java @@ -37,6 +37,8 @@ exception statement from your version. */ package javax.swing.text; +import gnu.java.lang.CPStringBuilder; + import java.io.Serializable; /** @@ -194,7 +196,7 @@ public class TabSet implements Serializable */ public String toString() { - StringBuffer sb = new StringBuffer(); + CPStringBuilder sb = new CPStringBuilder(); sb.append("[ "); for (int i = 0; i < tabs.length; ++i) { diff --git a/libjava/classpath/javax/swing/text/html/CSSParser.java b/libjava/classpath/javax/swing/text/html/CSSParser.java index 54a16bcc599..d49ac3a6fc9 100644 --- a/libjava/classpath/javax/swing/text/html/CSSParser.java +++ b/libjava/classpath/javax/swing/text/html/CSSParser.java @@ -163,11 +163,6 @@ class CSSParser private int pushedChar; /** - * Temporary place to hold identifiers. - */ - private StringBuffer unitBuffer; - - /** * Used to indicate blocks. */ private int[] unitStack; @@ -212,7 +207,6 @@ class CSSParser */ CSSParser() { - unitBuffer = new StringBuffer(); tokenBuffer = new char[10]; } diff --git a/libjava/classpath/javax/swing/text/html/HTMLWriter.java b/libjava/classpath/javax/swing/text/html/HTMLWriter.java index 44119c73286..6cc23df9aab 100644 --- a/libjava/classpath/javax/swing/text/html/HTMLWriter.java +++ b/libjava/classpath/javax/swing/text/html/HTMLWriter.java @@ -37,6 +37,8 @@ exception statement from your version. */ package javax.swing.text.html; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.Writer; @@ -574,7 +576,7 @@ public class HTMLWriter protected void output(char[] chars, int off, int len) throws IOException { - StringBuffer strBuffer = new StringBuffer(); + CPStringBuilder strBuffer = new CPStringBuilder(); for (int i = 0; i < chars.length; i++) { @@ -1081,4 +1083,4 @@ public class HTMLWriter return ret_str; } // private String escapeCharHtmlEntity(char param_char) -} // public class HTMLWriter extends AbstractWriter
\ No newline at end of file +} // public class HTMLWriter extends AbstractWriter diff --git a/libjava/classpath/javax/swing/text/html/StyleSheet.java b/libjava/classpath/javax/swing/text/html/StyleSheet.java index 01f19fd7bdd..08578c80fad 100644 --- a/libjava/classpath/javax/swing/text/html/StyleSheet.java +++ b/libjava/classpath/javax/swing/text/html/StyleSheet.java @@ -182,7 +182,7 @@ public class StyleSheet extends StyleContext */ private class CSSStyle extends SimpleAttributeSet - implements Style, Comparable + implements Style, Comparable<CSSStyle> { static final int PREC_UA = 0; @@ -229,9 +229,8 @@ public class StyleSheet extends StyleContext * Sorts the rule according to the style's precedence and the * selectors specificity. */ - public int compareTo(Object o) + public int compareTo(CSSStyle other) { - CSSStyle other = (CSSStyle) o; return other.precedence + other.selector.getSpecificity() - precedence - selector.getSpecificity(); } @@ -247,18 +246,18 @@ public class StyleSheet extends StyleContext /** * The linked style sheets stored. */ - private ArrayList linked; + private ArrayList<StyleSheet> linked; /** * Maps element names (selectors) to AttributSet (the corresponding style * information). */ - ArrayList css = new ArrayList(); + ArrayList<CSSStyle> css = new ArrayList<CSSStyle>(); /** * Maps selectors to their resolved styles. */ - private HashMap resolvedStyles; + private HashMap<String,Style> resolvedStyles; /** * Constructs a StyleSheet. @@ -267,7 +266,7 @@ public class StyleSheet extends StyleContext { super(); baseFontSize = 4; // Default font size from CSS - resolvedStyles = new HashMap(); + resolvedStyles = new HashMap<String,Style>(); } /** @@ -283,7 +282,7 @@ public class StyleSheet extends StyleContext { // Create list of the element and all of its parents, starting // with the bottommost element. - ArrayList path = new ArrayList(); + ArrayList<Element> path = new ArrayList<Element>(); Element el; AttributeSet atts; for (el = e; el != null; el = el.getParentElement()) @@ -295,7 +294,7 @@ public class StyleSheet extends StyleContext // We append the actual element after this loop. for (int i = count - 1; i > 0; i--) { - el = (Element) path.get(i); + el = path.get(i); atts = el.getAttributes(); Object name = atts.getAttribute(StyleConstants.NameAttribute); selector.append(name.toString()); @@ -322,7 +321,7 @@ public class StyleSheet extends StyleContext selector.append(' '); } selector.append(t.toString()); - el = (Element) path.get(0); + el = path.get(0); atts = el.getAttributes(); // For leaf elements, we have to fetch the tag specific attributes. if (el.isLeaf()) @@ -372,7 +371,7 @@ public class StyleSheet extends StyleContext */ private Style getResolvedStyle(String selector, List path, HTML.Tag tag) { - Style style = (Style) resolvedStyles.get(selector); + Style style = resolvedStyles.get(selector); if (style == null) style = resolveStyle(selector, path, tag); return style; @@ -439,11 +438,9 @@ public class StyleSheet extends StyleContext { // FIXME: This style resolver is not correct. But it works good enough for // the default.css. - int count = tags.length; - ArrayList styles = new ArrayList(); - for (Iterator i = css.iterator(); i.hasNext();) + ArrayList<CSSStyle> styles = new ArrayList<CSSStyle>(); + for (CSSStyle style : css) { - CSSStyle style = (CSSStyle) i.next(); if (style.selector.matches(tags, attributes)) styles.add(style); } @@ -453,10 +450,10 @@ public class StyleSheet extends StyleContext { for (int i = linked.size() - 1; i >= 0; i--) { - StyleSheet ss = (StyleSheet) linked.get(i); + StyleSheet ss = linked.get(i); for (int j = ss.css.size() - 1; j >= 0; j--) { - CSSStyle style = (CSSStyle) ss.css.get(j); + CSSStyle style = ss.css.get(j); if (style.selector.matches(tags, attributes)) styles.add(style); } @@ -615,7 +612,7 @@ public class StyleSheet extends StyleContext if (linked != null) { linkedSS = new StyleSheet[linked.size()]; - linkedSS = (StyleSheet[]) linked.toArray(linkedSS); + linkedSS = linked.toArray(linkedSS); } else { @@ -1074,7 +1071,7 @@ public class StyleSheet extends StyleContext */ public void setBaseFontSize(String size) { - size.trim(); + size = size.trim(); int temp = 0; try { @@ -1446,8 +1443,8 @@ public class StyleSheet extends StyleContext */ private Map attributeSetToMap(AttributeSet atts) { - HashMap map = new HashMap(); - Enumeration keys = atts.getAttributeNames(); + HashMap<String,String> map = new HashMap<String,String>(); + Enumeration<?> keys = atts.getAttributeNames(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); diff --git a/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java b/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java index 25db89fc405..8838646d5f5 100644 --- a/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java +++ b/libjava/classpath/javax/swing/text/html/ViewAttributeSet.java @@ -83,7 +83,7 @@ class ViewAttributeSet { styleSheet = ss; view = v; - ArrayList atts = new ArrayList(); + ArrayList<AttributeSet> atts = new ArrayList<AttributeSet>(); Element el = v.getElement(); AttributeSet elAtts = el.getAttributes(); @@ -93,7 +93,7 @@ class ViewAttributeSet if (el.isLeaf()) { - Enumeration n = elAtts.getAttributeNames(); + Enumeration<?> n = elAtts.getAttributeNames(); while (n.hasMoreElements()) { Object key = n.nextElement(); @@ -115,7 +115,7 @@ class ViewAttributeSet } AttributeSet[] atts1 = new AttributeSet[atts.size()]; - atts1 = (AttributeSet[]) atts.toArray(atts1); + atts1 = atts.toArray(atts1); init(atts1); } |