From 6fd014a77e5473fe291a3554efa8be09f78d9a84 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 03 Mar 2014 13:34:32 +0000
Subject: [PATCH] SchemaUtils.java: Removed unreachable code. Renamed trimConsecutiveSpacesInStringList() into trimUnnecessarySpacesInStringList().

---
 opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java |   30 ++++++------------------------
 1 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
index 346c781..66b80de 100644
--- a/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
+++ b/opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
@@ -694,19 +694,16 @@
         if (buffer.length() == 0) {
             return singleSpaceOrEmpty(value);
         }
-        trimConsecutiveSpacesInStringList(buffer);
+        trimUnnecessarySpacesInStringList(buffer);
         return ByteString.valueOf(buffer.toString());
     }
 
-    private static void trimConsecutiveSpacesInStringList(StringBuilder buffer) {
+    private static void trimUnnecessarySpacesInStringList(StringBuilder buffer) {
         // Replace any consecutive spaces with a single space. Any spaces
         // around a dollar sign will also be removed.
         for (int pos = buffer.length() - 1; pos > 0; pos--) {
             if (buffer.charAt(pos) == ' ') {
-                final char c = buffer.charAt(pos - 1);
-                if (c == ' ') {
-                    buffer.delete(pos, pos + 1);
-                } else if (c == '$') {
+                if (buffer.charAt(pos - 1) == '$') {
                     if (pos <= 1 || buffer.charAt(pos - 2) != '\\') {
                         buffer.delete(pos, pos + 1);
                     }
@@ -725,19 +722,9 @@
         if (buffer.length() == 0) {
             return singleSpaceOrEmpty(value);
         }
-        trimConsecutiveSpaces(buffer);
         return ByteString.valueOf(buffer.toString());
     }
 
-    private static void trimConsecutiveSpaces(StringBuilder buffer) {
-        for (int pos = buffer.length() - 1; pos > 0; pos--) {
-            if (buffer.charAt(pos) == ' '
-                    && buffer.charAt(pos - 1) == ' ') {
-                buffer.delete(pos, pos + 1);
-            }
-        }
-    }
-
     static ByteString normalizeIA5StringAttributeValue(final ByteSequence value, boolean trim, boolean foldCase)
             throws DecodeException {
         final StringBuilder buffer = new StringBuilder();
@@ -746,21 +733,16 @@
         if (buffer.length() == 0) {
             return singleSpaceOrEmpty(value);
         }
-        trimConsecutiveSpacesInIA5String(buffer, value);
+        throwIfIA5IllegalCharacter(buffer, value);
         return ByteString.valueOf(buffer.toString());
     }
 
-    private static void trimConsecutiveSpacesInIA5String(StringBuilder buffer, ByteSequence value)
-            throws DecodeException {
+    private static void throwIfIA5IllegalCharacter(StringBuilder buffer, ByteSequence value) throws DecodeException {
         // Replace any consecutive spaces with a single space and watch out
         // for non-ASCII characters.
         for (int pos = buffer.length() - 1; pos > 0; pos--) {
             final char c = buffer.charAt(pos);
-            if (c == ' ') {
-                if (buffer.charAt(pos - 1) == ' ') {
-                    buffer.delete(pos, pos + 1);
-                }
-            } else if ((c & 0x7F) != c) {
+            if ((c & 0x7F) != c) {
                 // This is not a valid character for an IA5 string. If strict
                 // syntax enforcement is enabled, then we'll throw an exception.
                 // Otherwise, we'll get rid of the character.

--
Gitblit v1.10.0