< prev index next >

src/java.base/share/classes/java/text/RBTableBuilder.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb

@@ -73,17 +73,14 @@
      * ONLY by the RBCollationTables constructor.
      * @see RuleBasedCollator#RuleBasedCollator
      * @exception ParseException If the rules format is incorrect.
      */
 
-    public void build(String pattern, int decmp) throws ParseException
-    {
-        boolean isSource = true;
-        int i = 0;
+    public void build(String pattern, int decmp) throws ParseException {
         String expChars;
         String groupChars;
-        if (pattern.length() == 0)
+        if (pattern.isEmpty())
             throw new ParseException("Build rules empty.", 0);
 
         // This array maps Unicode characters to their collation ordering
         mapping = new UCompactIntArray(RBCollationTables.UNMAPPED);
         // Normalize the build rules.  Find occurances of all decomposed characters

@@ -117,12 +114,11 @@
         mPattern = new MergeCollation(pattern);
 
         int order = 0;
 
         // Now walk though each entry and add it to my own tables
-        for (i = 0; i < mPattern.getCount(); ++i)
-        {
+        for (int i = 0; i < mPattern.getCount(); ++i) {
             PatternEntry entry = mPattern.getItemAt(i);
             if (entry != null) {
                 groupChars = entry.getChars();
                 if (groupChars.length() > 1) {
                     switch(groupChars.charAt(groupChars.length()-1)) {

@@ -138,11 +134,11 @@
                 }
 
                 order = increment(entry.getStrength(), order);
                 expChars = entry.getExtension();
 
-                if (expChars.length() != 0) {
+                if (!expChars.isEmpty()) {
                     addExpandOrder(groupChars, expChars, order);
                 } else if (groupChars.length() > 1) {
                     char ch = groupChars.charAt(0);
                     if (Character.isHighSurrogate(ch) && groupChars.length() == 2) {
                         addOrder(Character.toCodePoint(ch, groupChars.charAt(1)), order);
< prev index next >