From a41662c1136b2bb4a4198df89e0e87d2be3ef099 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 16 Jul 2015 14:57:56 +0000
Subject: [PATCH] AutoRefactor'ed simplify expressions

---
 opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java |  123 +++++++++++++++++++----------------------
 1 files changed, 57 insertions(+), 66 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java
index ae99a04..e731939 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java
@@ -134,7 +134,7 @@
     // whitespace.
     int pos    = 0;
     int length = valueStr.length();
-    while ((pos < length) && (valueStr.charAt(pos) == ' '))
+    while (pos < length && valueStr.charAt(pos) == ' ')
     {
       pos++;
     }
@@ -154,13 +154,13 @@
     char c = valueStr.charAt(pos++);
     if (c != '(')
     {
-      LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get(valueStr, (pos-1), c);
+      LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos-1, c);
       throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
     }
 
 
     // Skip over any spaces immediately following the opening parenthesis.
-    while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
+    while (pos < length && ((c = valueStr.charAt(pos)) == ' '))
     {
       pos++;
     }
@@ -185,26 +185,23 @@
       // This must be a numeric OID.  In that case, we will accept only digits
       // and periods, but not consecutive periods.
       boolean lastWasPeriod = false;
-      while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' '))
+      while (pos < length && ((c = valueStr.charAt(pos++)) != ' '))
       {
         if (c == '.')
         {
           if (lastWasPeriod)
           {
             LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_DOUBLE_PERIOD_IN_NUMERIC_OID.
-                get(valueStr, (pos-1));
+                get(valueStr, pos-1);
             throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                          message);
           }
-          else
-          {
-            lastWasPeriod = true;
-          }
+          lastWasPeriod = true;
         }
         else if (! isDigit(c))
         {
           // This must have been an illegal character.
-          LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, (pos-1));
+          LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1);
           throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
         }
         else
@@ -217,17 +214,17 @@
     {
       // This must be a "fake" OID.  In this case, we will only accept
       // alphabetic characters, numeric digits, and the hyphen.
-      while ((pos < length) && ((c = valueStr.charAt(pos++)) != ' '))
+      while (pos < length && ((c = valueStr.charAt(pos++)) != ' '))
       {
-        if (isAlpha(c) || isDigit(c) || (c == '-') ||
-            ((c == '_') && DirectoryServer.allowAttributeNameExceptions()))
+        if (isAlpha(c) || isDigit(c) || c == '-' ||
+            (c == '_' && DirectoryServer.allowAttributeNameExceptions()))
         {
           // This is fine.  It is an acceptable character.
         }
         else
         {
           // This must have been an illegal character.
-          LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, (pos-1));
+          LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, pos-1);
           throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
         }
       }
@@ -236,18 +233,14 @@
 
     // If we're at the end of the value, then it isn't a valid DIT content rule
     // description.  Otherwise, parse out the OID.
-    String oid;
     if (pos >= length)
     {
       LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_TRUNCATED_VALUE.get(valueStr);
       throw new DirectoryException(
               ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
     }
-    else
-    {
-      oid = lowerStr.substring(oidStartPos, (pos-1));
-    }
 
+    String oid = lowerStr.substring(oidStartPos, pos-1);
 
     // Get the objectclass with the specified OID.  If it does not exist or is
     // not structural, then fail.
@@ -275,7 +268,7 @@
 
 
     // Skip over the space(s) after the OID.
-    while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
+    while (pos < length && ((c = valueStr.charAt(pos)) == ' '))
     {
       pos++;
     }
@@ -319,7 +312,7 @@
         if (pos < length)
         {
           LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_UNEXPECTED_CLOSE_PARENTHESIS.
-              get(valueStr, (pos-1));
+              get(valueStr, pos-1);
           throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                        message);
         }
@@ -336,8 +329,7 @@
         {
           StringBuilder userBuffer  = new StringBuilder();
           StringBuilder lowerBuffer = new StringBuilder();
-          pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer,
-                                 (pos-1));
+          pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos-1);
           names.put(lowerBuffer.toString(), userBuffer.toString());
         }
         else if (c == '(')
@@ -355,7 +347,7 @@
             {
               // Skip over any spaces after the parenthesis.
               pos++;
-              while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
+              while (pos < length && ((c = valueStr.charAt(pos)) == ' '))
               {
                 pos++;
               }
@@ -376,7 +368,7 @@
         else
         {
           // This is an illegal character.
-          LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1));
+          LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1);
           throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
         }
       }
@@ -409,7 +401,7 @@
           while (true)
           {
             StringBuilder woidBuffer = new StringBuilder();
-            pos = readWOID(lowerStr, woidBuffer, (pos));
+            pos = readWOID(lowerStr, woidBuffer, pos);
 
             ObjectClass oc = schema.getObjectClass(woidBuffer.toString());
             if (oc == null)
@@ -451,7 +443,7 @@
             else if (c != '$')
             {
               LocalizableMessage message =
-                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1));
+                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1);
               throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
             }
           }
@@ -459,7 +451,7 @@
         else
         {
           StringBuilder woidBuffer = new StringBuilder();
-          pos = readWOID(lowerStr, woidBuffer, (pos-1));
+          pos = readWOID(lowerStr, woidBuffer, pos-1);
 
           ObjectClass oc = schema.getObjectClass(woidBuffer.toString());
           if (oc == null)
@@ -504,7 +496,7 @@
           while (true)
           {
             StringBuilder woidBuffer = new StringBuilder();
-            pos = readWOID(lowerStr, woidBuffer, (pos));
+            pos = readWOID(lowerStr, woidBuffer, pos);
             attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer,
                 ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR));
 
@@ -518,7 +510,7 @@
             else if (c != '$')
             {
               LocalizableMessage message =
-                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1));
+                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1);
               throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
             }
           }
@@ -526,7 +518,7 @@
         else
         {
           StringBuilder woidBuffer = new StringBuilder();
-          pos = readWOID(lowerStr, woidBuffer, (pos-1));
+          pos = readWOID(lowerStr, woidBuffer, pos-1);
           attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer,
               ERR_ATTR_SYNTAX_DCR_UNKNOWN_REQUIRED_ATTR));
         }
@@ -547,7 +539,7 @@
           while (true)
           {
             StringBuilder woidBuffer = new StringBuilder();
-            pos = readWOID(lowerStr, woidBuffer, (pos));
+            pos = readWOID(lowerStr, woidBuffer, pos);
             attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer,
                 ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR));
 
@@ -561,7 +553,7 @@
             else if (c != '$')
             {
               LocalizableMessage message =
-                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1));
+                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1);
               throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
             }
           }
@@ -569,7 +561,7 @@
         else
         {
           StringBuilder woidBuffer = new StringBuilder();
-          pos = readWOID(lowerStr, woidBuffer, (pos-1));
+          pos = readWOID(lowerStr, woidBuffer, pos-1);
           attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer,
               ERR_ATTR_SYNTAX_DCR_UNKNOWN_OPTIONAL_ATTR));
         }
@@ -590,7 +582,7 @@
           while (true)
           {
             StringBuilder woidBuffer = new StringBuilder();
-            pos = readWOID(lowerStr, woidBuffer, (pos));
+            pos = readWOID(lowerStr, woidBuffer, pos);
             attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer,
                 ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR));
 
@@ -604,7 +596,7 @@
             else if (c != '$')
             {
               LocalizableMessage message =
-                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, (pos-1));
+                  ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR.get(valueStr, c, pos-1);
               throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
             }
           }
@@ -612,7 +604,7 @@
         else
         {
           StringBuilder woidBuffer = new StringBuilder();
-          pos = readWOID(lowerStr, woidBuffer, (pos-1));
+          pos = readWOID(lowerStr, woidBuffer, pos-1);
           attrs.add(getAttribute(schema, allowUnknownElements, valueStr, woidBuffer,
               ERR_ATTR_SYNTAX_DCR_UNKNOWN_PROHIBITED_ATTR));
         }
@@ -705,7 +697,7 @@
     // Skip over any spaces at the beginning of the value.
     char c = '\u0000';
     int  length = valueStr.length();
-    while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -719,14 +711,14 @@
 
 
     // Read until we find the next space.
-    while ((startPos < length) && ((c = valueStr.charAt(startPos++)) != ' '))
+    while (startPos < length && ((c = valueStr.charAt(startPos++)) != ' '))
     {
       tokenName.append(c);
     }
 
 
     // Skip over any trailing spaces after the value.
-    while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -761,7 +753,7 @@
     // Skip over any spaces at the beginning of the value.
     char c = '\u0000';
     int  length = valueStr.length();
-    while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -786,7 +778,7 @@
 
     // Read until we find the closing quote.
     startPos++;
-    while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\''))
+    while (startPos < length && ((c = valueStr.charAt(startPos)) != '\''))
     {
       valueBuffer.append(c);
       startPos++;
@@ -795,7 +787,7 @@
 
     // Skip over any trailing spaces after the value.
     startPos++;
-    while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -844,7 +836,7 @@
     // Skip over any spaces at the beginning of the value.
     char c = '\u0000';
     int  length = lowerStr.length();
-    while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -869,7 +861,7 @@
 
     // Read until we find the closing quote.
     startPos++;
-    while ((startPos < length) && ((c = lowerStr.charAt(startPos)) != '\''))
+    while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\''))
     {
       lowerBuffer.append(c);
       userBuffer.append(valueStr.charAt(startPos));
@@ -879,7 +871,7 @@
 
     // Skip over any trailing spaces after the value.
     startPos++;
-    while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -921,7 +913,7 @@
     // Skip over any spaces at the beginning of the value.
     char c = '\u0000';
     int  length = lowerStr.length();
-    while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -941,14 +933,14 @@
       // This must be a numeric OID.  In that case, we will accept only digits
       // and periods, but not consecutive periods.
       boolean lastWasPeriod = false;
-      while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' '))
+      while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' '))
       {
         if (c == '.')
         {
           if (lastWasPeriod)
           {
             LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_DOUBLE_PERIOD_IN_NUMERIC_OID.
-                get(lowerStr, (startPos-1));
+                get(lowerStr, startPos-1);
             throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                          message);
           }
@@ -968,12 +960,12 @@
           // additional characters.
           if (c == ')')
           {
-            return (startPos-1);
+            return startPos-1;
           }
 
           // This must have been an illegal character.
           LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_NUMERIC_OID.get(
-              lowerStr, c, (startPos-1));
+              lowerStr, c, startPos-1);
           throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
         }
         else
@@ -986,12 +978,11 @@
     else if (isAlpha(c))
     {
       // This must be an attribute type/objectclass description.  In this case,
-      // we will only accept alphabetic characters, numeric digits, and the
-      // hyphen.
-      while ((startPos < length) && ((c = lowerStr.charAt(startPos++)) != ' '))
+      // we will only accept alphabetic characters, numeric digits, and the hyphen.
+      while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' '))
       {
-        if (isAlpha(c) || isDigit(c) || (c == '-') ||
-            ((c == '_') && DirectoryServer.allowAttributeNameExceptions()))
+        if (isAlpha(c) || isDigit(c) || c == '-' ||
+            (c == '_' && DirectoryServer.allowAttributeNameExceptions()))
         {
           woidBuffer.append(c);
         }
@@ -1005,12 +996,12 @@
           // additional characters.
           if (c == ')')
           {
-            return (startPos-1);
+            return startPos-1;
           }
 
           // This must have been an illegal character.
           LocalizableMessage message = ERR_ATTR_SYNTAX_DCR_ILLEGAL_CHAR_IN_STRING_OID.get(
-              lowerStr, c, (startPos-1));
+              lowerStr, c, startPos-1);
           throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
         }
       }
@@ -1023,7 +1014,7 @@
 
 
     // Skip over any trailing spaces after the value.
-    while ((startPos < length) && ((c = lowerStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -1065,7 +1056,7 @@
     // Skip over any leading spaces.
     int length = valueStr.length();
     char c = '\u0000';
-    while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
+    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
     {
       startPos++;
     }
@@ -1088,7 +1079,7 @@
       // Parse until the closing quote.
       StringBuilder valueBuffer = new StringBuilder();
       startPos++;
-      while ((startPos < length) && ((c = valueStr.charAt(startPos)) != '\''))
+      while (startPos < length && ((c = valueStr.charAt(startPos)) != '\''))
       {
         valueBuffer.append(c);
         startPos++;
@@ -1103,7 +1094,7 @@
       while (true)
       {
         // Skip over any leading spaces;
-        while ((startPos < length) && ((c = valueStr.charAt(startPos)) == ' '))
+        while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
         {
           startPos++;
         }
@@ -1134,7 +1125,7 @@
           // We have a quoted string
           StringBuilder valueBuffer = new StringBuilder();
           startPos++;
-          while ((startPos < length) &&
+          while (startPos < length &&
               ((c = valueStr.charAt(startPos)) != '\''))
           {
             valueBuffer.append(c);
@@ -1148,7 +1139,7 @@
         {
           //Consider unquoted string
           StringBuilder valueBuffer = new StringBuilder();
-          while ((startPos < length) &&
+          while (startPos < length &&
               ((c = valueStr.charAt(startPos)) != ' '))
           {
             valueBuffer.append(c);
@@ -1171,7 +1162,7 @@
     {
       // Parse until the next space.
       StringBuilder valueBuffer = new StringBuilder();
-      while ((startPos < length) && ((c = valueStr.charAt(startPos)) != ' '))
+      while (startPos < length && ((c = valueStr.charAt(startPos)) != ' '))
       {
         valueBuffer.append(c);
         startPos++;
@@ -1181,7 +1172,7 @@
     }
 
     // Skip over any trailing spaces.
-    while ((startPos < length) && (valueStr.charAt(startPos) == ' '))
+    while (startPos < length && valueStr.charAt(startPos) == ' ')
     {
       startPos++;
     }

--
Gitblit v1.10.0