From c10bf728da5d8039b517c9e91086c9f93a31a4e1 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 6 Jan 2009 22:44:05 +0000 Subject: Merge GNU Classpath libgcj-snapshot-20090102. 2009-01-06 Andrew John Hughes Import GNU Classpath (libgcj-snapshot-20090102). * libjava/classpath/lib/java/text/RuleBasedCollator$CollationSorter.class, * libjava/classpath/lib/java/text/MessageFormat$MessageFormatElement.class, * libjava/classpath/lib/java/text/MessageFormat.class, * libjava/classpath/lib/java/text/SimpleDateFormat.class, * libjava/classpath/lib/java/text/NumberFormat.class, * libjava/classpath/lib/java/text/RuleBasedCollator$CollationElement.class, * libjava/classpath/lib/java/text/MessageFormat$Field.class, * libjava/classpath/lib/java/text/RuleBasedCollator.class, * libjava/classpath/lib/java/text/NumberFormat$Field.class, * libjava/classpath/lib/gnu/xml/transform/Bindings.class, * libjava/classpath/lib/gnu/java/locale/LocaleData.class, * libjava/classpath/lib/gnu/java/awt/peer/gtk/FreetypeGlyphVector.class, * libjava/classpath/lib/gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.class, * libjava/gnu/java/awt/peer/gtk/FreetypeGlyphVector.h, * libjava/java/text/MessageFormat.h, * libjava/java/text/RuleBasedCollator$CollationSorter.h, * libjava/java/text/RuleBasedCollator.h, * libjava/java/text/SimpleDateFormat.h: Regenerated. 2009-01-02 Andrew John Hughes * ChangeLog-2008: New file. 2009-01-02 Andrew John Hughes * java/text/MessageFormat.java: (setLocale(Locale)): Integer format should use NumberFormat.getIntegerInstance. libjava/classpath/ChangeLog-2008 2008-12-31 Andrew John Hughes * java/text/MessageFormat.java: (parse(String,ParsePosition)): Emulate behaviour of Vector's setSize() which was being implicitly relied on. 2008-12-31 Andrew John Hughes * java/text/SimpleDateFormat.java: Remove superfluous empty line introduced in last commit. 2008-12-31 Andrew John Hughes * java/text/MessageFormat.java: Convert variables to use generic types, use CPStringBuilder in place of StringBuilder. (Field()): Suppress warning due to only being used by deserialization. (scanFormat(String,int,CPStringBuilder,List,Locale)): Use ArrayList instead of Vector as no synchronisation needed. (parse(String,ParsePosition)): Likewise. * java/text/NumberFormat.java: (Field()): Suppress warning due to only being used by deserialization. * java/text/RuleBasedCollator.java: Convert variables to use generic types. (CollationElement): Make fields final. (CollationSorter): Likewise. (CollationSorter(int,String,int,boolean)): New constructor. * java/text/SimpleDateFormat.java, Convert variables to use generic types. (applyPattern(String)): Clear list rather than creating a new instance. 2008-12-30 Andrew John Hughes * java/text/SimpleDateFormat.java: (standardChars): Use standard characters from CLDR. (RFC822_TIMEZONE_FIELD): Fixed to match new standard characters. 2008-12-22 Andrew John Hughes * java/lang/String.java: (byte[],int,int,String): Call new Charset method. (stringToCharset(String)): Private method added to handle exception conversion. (byte[],int,int,Charset): Implemented. (byte[], Charset): Likewise. (getBytes(String)): Call new Charset method. (getBytes(Charset)): Implemented. 2008-12-18 Andrew John Hughes * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c: Include '\0' in the string. 2008-12-09 Andrew John Hughes PR classpath/38473: * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c: (Java_gnu_java_awt_peer_gtk_FreetypeGlyphVector_getGlyphOutlineNative): Check that the glyph is an outline before calling FT_Outline_Decompose. 2008-11-16 Andrew John Hughes * gnu/xml/transform/Bindings.java: Add generics to collections. 2008-11-16 Andrew John Hughes * gnu/javax/crypto/jce/key/SecretKeyGeneratorImpl.java: (init(int,SecureRandom)): Improve exception message. 2008-11-06 Mark Wielaard * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c (getKerning): Removed unused cls, method, values. 2008-11-05 Andrew Haley * gnu/java/awt/peer/gtk/FreetypeGlyphVector.java (getKerning): Return result in a float[], not a Point2D. (performDefaultLayout): Call getKerning with a float[]. * native/jni/gtk-peer/gnu_java_awt_peer_gtk_FreetypeGlyphVector.c (getKerning): Return result in a float[], not a Point2D. 2008-11-05 Andrew Haley * tools/Makefile.am (UPDATE_TOOLS_ZIP, CREATE_TOOLS_ZIP): Exclude .svn direcories. 2008-10-23 David Edelsohn * native/fdlibm/fdlibm.h: Undef hz. 2008-10-20 Andrew John Hughes * m4/ac_prog_antlr.m4: Remove redundant checks. * tools/Makefile.am: Use gjdoc_gendir when calling antlr. 2008-10-17 Robert Lougher * native/jni/gtk-peer/gnu_java_awt_peer_gtk_CairoGraphics2D.c (Java_gnu_java_awt_peer_gtk_CairoGraphics2D_cairoDrawGlyphVector): Release 'fonts'. 2008-10-16 Tom Tromey * tools/gnu/classpath/tools/jar/WorkSet.java (initSet): Use foreach. Change argument type. (WorkSet): Change argument type. * tools/gnu/classpath/tools/jar/Indexer.java (indexJarFile): Use foreach. * tools/gnu/classpath/tools/jar/Creator.java (writeCommandLineEntries): Use foreach. (getAllEntries): Likewise. 2008-10-15 Andrew John Hughes * configure.ac: Remove superfluous AC_PROG_JAVA call. From-SVN: r143139 --- libjava/classpath/java/text/RuleBasedCollator.java | 104 ++++++++++----------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'libjava/classpath/java/text/RuleBasedCollator.java') diff --git a/libjava/classpath/java/text/RuleBasedCollator.java b/libjava/classpath/java/text/RuleBasedCollator.java index fdd1446cc0c..b761039ad80 100644 --- a/libjava/classpath/java/text/RuleBasedCollator.java +++ b/libjava/classpath/java/text/RuleBasedCollator.java @@ -151,13 +151,13 @@ public class RuleBasedCollator extends Collator */ static final class CollationElement { - String key; - int primary; - short secondary; - short tertiary; - short equality; - boolean ignore; - String expansion; + final String key; + final int primary; + final short secondary; + final short tertiary; + final short equality; + final boolean ignore; + final String expansion; CollationElement(String key, int primary, short secondary, short tertiary, short equality, String expansion, boolean ignore) @@ -185,7 +185,7 @@ public class RuleBasedCollator extends Collator * {@link #mergeRules(int,java.lang.String,java.util.ArrayList,java.util.ArrayList)}) * as a temporary state while merging two sets of instructions. */ - static final class CollationSorter + private static final class CollationSorter { static final int GREATERP = 0; static final int GREATERS = 1; @@ -194,29 +194,39 @@ public class RuleBasedCollator extends Collator static final int RESET = 4; static final int INVERSE_SECONDARY = 5; - int comparisonType; - String textElement; - int hashText; - int offset; - boolean ignore; + final int comparisonType; + final String textElement; + final int hashText; + final int offset; + final boolean ignore; String expansionOrdering; + + private CollationSorter(final int comparisonType, final String textElement, + final int offset, final boolean ignore) + { + this.comparisonType = comparisonType; + this.textElement = textElement; + this.offset = offset; + this.ignore = ignore; + hashText = textElement.hashCode(); + } } /** - * This the the original rule string. + * This is the original rule string. */ private String rules; /** * This is the table of collation element values */ - private Object[] ce_table; + private CollationElement[] ce_table; /** * Quick-prefix finder. */ - HashMap prefix_tree; + HashMap prefix_tree; /** * This is the value of the last sequence entered into @@ -306,7 +316,8 @@ public class RuleBasedCollator extends Collator * @param patch Rules to be merged into the repository. * @throws ParseException if it is impossible to find an anchor point for the new rules. */ - private void mergeRules(int offset, String starter, ArrayList main, ArrayList patch) + private void mergeRules(int offset, String starter, ArrayList main, + ArrayList patch) throws ParseException { int insertion_point = -1; @@ -324,8 +335,8 @@ public class RuleBasedCollator extends Collator while (j < main.size()) { - CollationSorter rule1 = (CollationSorter) patch.get(i); - CollationSorter rule2 = (CollationSorter) main.get(j); + CollationSorter rule1 = patch.get(i); + CollationSorter rule2 = main.get(j); if (rule1.textElement.equals(rule2.textElement)) main.remove(j); @@ -337,7 +348,7 @@ public class RuleBasedCollator extends Collator // Find the insertion point... O(N) for (int i = 0; i < main.size(); i++) { - CollationSorter sorter = (CollationSorter) main.get(i); + CollationSorter sorter = main.get(i); int length = findPrefixLength(starter, sorter.textElement); if (length > max_length) @@ -363,9 +374,7 @@ public class RuleBasedCollator extends Collator * sequence. The rest of the subsequence must be appended * to the end of the sequence. */ - CollationSorter sorter = (CollationSorter) patch.get(0); - CollationSorter expansionPrefix = - (CollationSorter) main.get(insertion_point-1); + CollationSorter sorter = patch.get(0); sorter.expansionOrdering = starter.substring(max_length); // Skip the first good prefix element @@ -398,7 +407,7 @@ public class RuleBasedCollator extends Collator * @throws ParseException if something turned wrong during the parsing. To get details * decode the message. */ - private int subParseString(boolean stop_on_reset, ArrayList v, + private int subParseString(boolean stop_on_reset, ArrayList v, int base_offset, String rules) throws ParseException { @@ -508,7 +517,7 @@ main_parse_loop: * indicated by the text element. */ String subrules = rules.substring(i); - ArrayList sorted_rules = new ArrayList(); + ArrayList sorted_rules = new ArrayList(); int idx; // Parse the subrules but do not iterate through all @@ -533,16 +542,12 @@ main_parse_loop: break main_parse_loop; } - CollationSorter sorter = new CollationSorter(); - + String textElement = sb.toString(); if (operator == CollationSorter.GREATERP) ignoreChars = false; - - sorter.comparisonType = operator; - sorter.textElement = sb.toString(); - sorter.hashText = sorter.textElement.hashCode(); - sorter.offset = base_offset+rules.length(); - sorter.ignore = ignoreChars; + CollationSorter sorter = new CollationSorter(operator, textElement, + base_offset + rules.length(), + ignoreChars); sb.setLength(0); v.add(sorter); @@ -551,7 +556,6 @@ main_parse_loop: if (operator >= 0) { - CollationSorter sorter = new CollationSorter(); int pos = rules.length() + base_offset; if ((sb.length() != 0 && nextIsModifier) @@ -561,11 +565,8 @@ main_parse_loop: if (operator == CollationSorter.GREATERP) ignoreChars = false; - sorter.comparisonType = operator; - sorter.textElement = sb.toString(); - sorter.hashText = sorter.textElement.hashCode(); - sorter.offset = base_offset+pos; - sorter.ignore = ignoreChars; + CollationSorter sorter = new CollationSorter(operator, sb.toString(), + base_offset+pos, ignoreChars); v.add(sorter); } @@ -593,10 +594,10 @@ main_parse_loop: * @throws ParseException if something turned wrong during the parsing. To get details * decode the message. */ - private ArrayList parseString(String rules) + private ArrayList parseString(String rules) throws ParseException { - ArrayList v = new ArrayList(); + ArrayList v = new ArrayList(); // result of the first subParseString is not absolute (may be -1 or a // positive integer). But we do not care. @@ -612,7 +613,7 @@ main_parse_loop: * @param parsedElements Parsed instructions stored in a ArrayList. * @throws ParseException if the order of the instructions are not valid. */ - private void buildCollationVector(ArrayList parsedElements) + private void buildCollationVector(ArrayList parsedElements) throws ParseException { int primary_seq = 0; @@ -624,14 +625,13 @@ main_parse_loop: final boolean DECREASING = false; final boolean INCREASING = true; boolean secondaryType = INCREASING; - ArrayList v = new ArrayList(); + ArrayList v = new ArrayList(); // elts is completely sorted. element_loop: for (int i = 0; i < parsedElements.size(); i++) { - CollationSorter elt = (CollationSorter) parsedElements.get(i); - boolean ignoreChar = false; + CollationSorter elt = parsedElements.get(i); switch (elt.comparisonType) { @@ -686,7 +686,7 @@ element_loop: this.inverseAccentComparison = inverseComparisons; - ce_table = v.toArray(); + ce_table = v.toArray(new CollationElement[v.size()]); last_primary_value = primary_seq+1; last_tertiary_value = last_tertiary_seq+1; @@ -699,11 +699,11 @@ element_loop: */ private void buildPrefixAccess() { - prefix_tree = new HashMap(); + prefix_tree = new HashMap(); for (int i = 0; i < ce_table.length; i++) { - CollationElement e = (CollationElement) ce_table[i]; + CollationElement e = ce_table[i]; prefix_tree.put(e.key, e); } @@ -941,7 +941,7 @@ element_loop: public CollationKey getCollationKey(String source) { CollationElementIterator cei = getCollationElementIterator(source); - ArrayList vect = new ArrayList(); + ArrayList vect = new ArrayList(); int ord = cei.next(); cei.reset(); //set to start of string @@ -969,16 +969,16 @@ element_loop: break; } - vect.add(new Integer(ord)); + vect.add(Integer.valueOf(ord)); ord = cei.next(); //increment to next key } - Object[] objarr = vect.toArray(); + Integer[] objarr = vect.toArray(new Integer[vect.size()]); byte[] key = new byte[objarr.length * 4]; for (int i = 0; i < objarr.length; i++) { - int j = ((Integer) objarr[i]).intValue(); + int j = objarr[i].intValue(); key [i * 4] = (byte) ((j & 0xFF000000) >> 24); key [i * 4 + 1] = (byte) ((j & 0x00FF0000) >> 16); key [i * 4 + 2] = (byte) ((j & 0x0000FF00) >> 8); -- cgit v1.2.3