diff options
Diffstat (limited to 'libjava/classpath/java/text')
-rw-r--r-- | libjava/classpath/java/text/ChoiceFormat.java | 8 | ||||
-rw-r--r-- | libjava/classpath/java/text/CollationElementIterator.java | 21 | ||||
-rw-r--r-- | libjava/classpath/java/text/DecimalFormat.java | 18 | ||||
-rw-r--r-- | libjava/classpath/java/text/MessageFormat.java | 4 | ||||
-rw-r--r-- | libjava/classpath/java/text/RuleBasedCollator.java | 11 | ||||
-rw-r--r-- | libjava/classpath/java/text/SimpleDateFormat.java | 16 |
6 files changed, 42 insertions, 36 deletions
diff --git a/libjava/classpath/java/text/ChoiceFormat.java b/libjava/classpath/java/text/ChoiceFormat.java index 94c13a2ca0c..629701c171a 100644 --- a/libjava/classpath/java/text/ChoiceFormat.java +++ b/libjava/classpath/java/text/ChoiceFormat.java @@ -114,10 +114,10 @@ public class ChoiceFormat extends NumberFormat if (index == max) throw new IllegalArgumentException ("unexpected end of text"); - Double d = new Double (newPattern.substring(dstart, index)); + Double d = Double.valueOf (newPattern.substring(dstart, index)); if (newPattern.charAt(index) == '<') - d = new Double (nextDouble (d.doubleValue())); + d = Double.valueOf (nextDouble (d.doubleValue())); limitVec.addElement(d); @@ -404,11 +404,11 @@ public class ChoiceFormat extends NumberFormat if (sourceStr.startsWith(choiceFormats[i], index)) { pos.setIndex(index + choiceFormats[i].length()); - return new Double (choiceLimits[i]); + return Double.valueOf (choiceLimits[i]); } } pos.setErrorIndex(index); - return new Double (Double.NaN); + return Double.valueOf (Double.NaN); } /** diff --git a/libjava/classpath/java/text/CollationElementIterator.java b/libjava/classpath/java/text/CollationElementIterator.java index 45c79142cc7..08c5cb56361 100644 --- a/libjava/classpath/java/text/CollationElementIterator.java +++ b/libjava/classpath/java/text/CollationElementIterator.java @@ -73,7 +73,7 @@ public final class CollationElementIterator /** * This is the String that is being iterated over. */ - String text; + CharacterIterator text; /** * This is the index into the collation decomposition where we are currently scanning. @@ -111,6 +111,21 @@ public final class CollationElementIterator setText (text); } + /** + * This method initializes a new instance of <code>CollationElementIterator</code> + * to iterate over the specified <code>String</code> using the rules in the + * specified <code>RuleBasedCollator</code>. + * + * @param collator The <code>RuleBasedCollation</code> used for calculating collation values + * @param text The character iterator to iterate over. + */ + CollationElementIterator(RuleBasedCollator collator, CharacterIterator text) + { + this.collator = collator; + + setText (text); + } + RuleBasedCollator.CollationElement nextBlock() { if (index >= text_decomposition.length) @@ -246,7 +261,7 @@ public final class CollationElementIterator int alreadyExpanded = 0; int idxToMove = 0; - this.text = text; + this.text = new StringCharacterIterator(text); this.index = 0; String work_text = text.intern(); @@ -440,7 +455,7 @@ public final class CollationElementIterator if (offset < 0) throw new IllegalArgumentException("Negative offset: " + offset); - if (offset > (text.length() - 1)) + if (offset > (text.getEndIndex() - 1)) throw new IllegalArgumentException("Offset too large: " + offset); for (index = 0; index < text_decomposition.length; index++) diff --git a/libjava/classpath/java/text/DecimalFormat.java b/libjava/classpath/java/text/DecimalFormat.java index 7febdeb49c4..61732c1123d 100644 --- a/libjava/classpath/java/text/DecimalFormat.java +++ b/libjava/classpath/java/text/DecimalFormat.java @@ -716,15 +716,15 @@ public class DecimalFormat extends NumberFormat if (this.parseBigDecimal) { if (isNegative) - return new BigDecimal(Double.NEGATIVE_INFINITY); + return BigDecimal.valueOf(Double.NEGATIVE_INFINITY); - return new BigDecimal(Double.POSITIVE_INFINITY); + return BigDecimal.valueOf(Double.POSITIVE_INFINITY); } if (isNegative) - return new Double(Double.NEGATIVE_INFINITY); + return Double.valueOf(Double.NEGATIVE_INFINITY); - return new Double(Double.POSITIVE_INFINITY); + return Double.valueOf(Double.POSITIVE_INFINITY); } // no number... @@ -771,21 +771,21 @@ public class DecimalFormat extends NumberFormat // want integer? if (this.parseIntegerOnly) - return new Long(bigDecimal.longValue()); + return Long.valueOf(bigDecimal.longValue()); // 3th special case -0.0 if (isNegative && (bigDecimal.compareTo(BigDecimal.ZERO) == 0)) - return new Double(-0.0); + return Double.valueOf(-0.0); try { BigDecimal integer = bigDecimal.setScale(0, BigDecimal.ROUND_UNNECESSARY); - return new Long(integer.longValue()); + return Long.valueOf(integer.longValue()); } catch (ArithmeticException e) { - return new Double(bigDecimal.doubleValue()); + return Double.valueOf(bigDecimal.doubleValue()); } } @@ -1787,7 +1787,7 @@ public class DecimalFormat extends NumberFormat int endIndexFract = 0; // compute the multiplier to use with percent and similar - number = number.multiply(new BigDecimal(_multiplier)); + number = number.multiply(BigDecimal.valueOf(_multiplier)); // XXX: special case, not sure if it belongs here or if it is // correct at all. There may be other special cases as well diff --git a/libjava/classpath/java/text/MessageFormat.java b/libjava/classpath/java/text/MessageFormat.java index ab71cecea5a..5a595f57615 100644 --- a/libjava/classpath/java/text/MessageFormat.java +++ b/libjava/classpath/java/text/MessageFormat.java @@ -498,7 +498,7 @@ public class MessageFormat extends Format int position = output_iterator.getEndIndex(); hash_argument.put (MessageFormat.Field.ARGUMENT, - new Integer(elements[i].argNumber)); + Integer.valueOf(elements[i].argNumber)); if (iterator != null) @@ -630,7 +630,7 @@ public class MessageFormat extends Format // have recursive formatting. ChoiceFormat cf = (ChoiceFormat) formatter; String[] formats = (String[]) cf.getFormats(); - double[] limits = (double[]) cf.getLimits(); + double[] limits = cf.getLimits(); MessageFormat subfmt = new MessageFormat (); subfmt.setLocale(locale); ParsePosition subpos = new ParsePosition (index); diff --git a/libjava/classpath/java/text/RuleBasedCollator.java b/libjava/classpath/java/text/RuleBasedCollator.java index 4bffcaf2905..7ec18dcc92f 100644 --- a/libjava/classpath/java/text/RuleBasedCollator.java +++ b/libjava/classpath/java/text/RuleBasedCollator.java @@ -923,17 +923,8 @@ element_loop: * @return A <code>CollationElementIterator</code> for the specified <code>String</code>. */ public CollationElementIterator getCollationElementIterator(CharacterIterator source) - throws NotImplementedException // Because decomposeCharacter does not work { - StringBuffer expand = new StringBuffer(""); - - // Right now we assume that we will read from the beginning of the string. - for (char c = source.first(); - c != CharacterIterator.DONE; - c = source.next()) - decomposeCharacter(c, expand); - - return getCollationElementIterator(expand.toString()); + return new CollationElementIterator(this, source); } /** diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java index f78fdcb89c5..934fb42e2a1 100644 --- a/libjava/classpath/java/text/SimpleDateFormat.java +++ b/libjava/classpath/java/text/SimpleDateFormat.java @@ -139,9 +139,9 @@ public class SimpleDateFormat extends DateFormat */ public String toString() { - StringBuffer builder; + StringBuilder builder; - builder = new StringBuffer(getClass().getName()); + builder = new StringBuilder(getClass().getName()); builder.append("[field="); builder.append(field); builder.append(", size="); @@ -322,7 +322,7 @@ public class SimpleDateFormat extends DateFormat // Look for the terminating quote. However, if we // see a '', that represents a literal quote and // we must iterate. - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); int oldPos = i + 1; do { @@ -346,7 +346,7 @@ public class SimpleDateFormat extends DateFormat else { // A special character - tokens.add(new Character(thisChar)); + tokens.add(Character.valueOf(thisChar)); } } else @@ -372,7 +372,7 @@ public class SimpleDateFormat extends DateFormat */ public String toString() { - StringBuffer output = new StringBuffer(getClass().getName()); + StringBuilder output = new StringBuilder(getClass().getName()); output.append("[tokens="); output.append(tokens); output.append(", formatData="); @@ -554,7 +554,7 @@ public class SimpleDateFormat extends DateFormat String oldChars, String newChars) { int len = pattern.length(); - StringBuffer buf = new StringBuffer(len); + StringBuilder buf = new StringBuilder(len); boolean quoted = false; for (int i = 0; i < len; i++) { @@ -1279,12 +1279,12 @@ public class SimpleDateFormat extends DateFormat // advance the index pos.setIndex(pos.getIndex() + matcher.end()); - return new Integer(offset); + return Integer.valueOf(offset); } else if (zoneString.startsWith("GMT")) { pos.setIndex(pos.getIndex() + 3); - return new Integer(0); + return Integer.valueOf(0); } return null; } |