directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1069580 - in /directory: apacheds/branches/m1/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/ shared/branches/m1/asn1-api/...
Date Thu, 10 Feb 2011 21:47:28 GMT
Author: elecharny
Date: Thu Feb 10 21:47:27 2011
New Revision: 1069580

URL: http://svn.apache.org/viewvc?rev=1069580&view=rev
Log:
o Removed some useless classes, fixed the tests that were using them

Removed:
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/AbstractStatefulDecoder.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/BinaryDecoder.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/BinaryEncoder.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/DecoderCallback.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/EncoderCallback.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/Hex.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/StatefulDecoder.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/StatefulEncoder.java
Modified:
    directory/apacheds/branches/m1/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshaller.java
    directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java
    directory/shared/branches/m1/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectTest.java
    directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/filter/LdapURL.java
    directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/filter/LdapUrlTest.java
    directory/shared/branches/m1/util/src/main/java/org/apache/directory/shared/util/Strings.java

Modified: directory/apacheds/branches/m1/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshaller.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshaller.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/apacheds/branches/m1/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshaller.java (original)
+++ directory/apacheds/branches/m1/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshaller.java Thu Feb 10 21:47:27 2011
@@ -24,7 +24,7 @@ import java.io.IOException;
 
 import org.apache.directory.server.core.avltree.Marshaller;
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.asn1.Hex;
+import org.apache.directory.shared.util.Strings;
 
 
 /**
@@ -66,15 +66,15 @@ public class BTreeRedirectMarshaller imp
 
 
     /**
-     * @see Marshaller#deserialize(byte[]) 
+     * @see Marshaller#deserialize(byte[])
      */
-    public final BTreeRedirect deserialize( byte[] bites ) throws IOException
+    public final BTreeRedirect deserialize( byte[] bytes ) throws IOException
     {
-        if ( bites == null || bites.length != SIZE || bites[0] != 1 )
+        if ( ( bytes == null ) || ( bytes.length != SIZE ) || ( bytes[0] != 1 ) )
         {
-            if ( bites != null )
+            if ( bytes != null )
             {
-                throw new IOException( I18n.err( I18n.ERR_568, new String( Hex.encodeHex(bites) ) ) );
+                throw new IOException( I18n.err( I18n.ERR_568, Strings.dumpBytes( bytes ) ) );
             }
             else
             {
@@ -83,21 +83,21 @@ public class BTreeRedirectMarshaller imp
         }
 
         long recId;
-        recId = bites[1] + ( ( bites[1] < 0 ) ? 256 : 0 );
+        recId = bytes[1] + ( ( bytes[1] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[2] + ( ( bites[2] < 0 ) ? 256 : 0 );
+        recId += bytes[2] + ( ( bytes[2] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[3] + ( ( bites[3] < 0 ) ? 256 : 0 );
+        recId += bytes[3] + ( ( bytes[3] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[4] + ( ( bites[4] < 0 ) ? 256 : 0 );
+        recId += bytes[4] + ( ( bytes[4] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[5] + ( ( bites[5] < 0 ) ? 256 : 0 );
+        recId += bytes[5] + ( ( bytes[5] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[6] + ( ( bites[6] < 0 ) ? 256 : 0 );
+        recId += bytes[6] + ( ( bytes[6] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[7] + ( ( bites[7] < 0 ) ? 256 : 0 );
+        recId += bytes[7] + ( ( bytes[7] < 0 ) ? 256 : 0 );
         recId <<= 8;
-        recId += bites[8] + ( ( bites[8] < 0 ) ? 256 : 0 );
+        recId += bytes[8] + ( ( bytes[8] < 0 ) ? 256 : 0 );
 
         return new BTreeRedirect( recId );
     }
@@ -111,6 +111,6 @@ public class BTreeRedirectMarshaller imp
      */
     public static boolean isRedirect( byte[] bites )
     {
-        return bites != null && bites.length == SIZE && bites[0] == 1;
+        return ( bites != null ) && ( bites.length == SIZE ) && ( bites[0] == 1 );
     }
 }

Modified: directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java (original)
+++ directory/shared/branches/m1/asn1-api/src/main/java/org/apache/directory/shared/asn1/util/Asn1StringUtils.java Thu Feb 10 21:47:27 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.asn1.util;
 
@@ -25,7 +25,7 @@ import java.io.UnsupportedEncodingExcept
 
 /**
  * Little helper class.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public final class Asn1StringUtils
@@ -42,17 +42,8 @@ public final class Asn1StringUtils
 
 
     /**
-     * This is a helper class, there is no reason to define a public constructor for it.
-     */
-    private Asn1StringUtils()
-    {
-        // Do nothing
-    }
-
-
-    /**
      * Helper function that dump a byte in hex form
-     * 
+     *
      * @param octet The byte to dump
      * @return A string representation of the byte
      */
@@ -65,7 +56,7 @@ public final class Asn1StringUtils
 
     /**
      * Helper function that dump an array of bytes in hex form
-     * 
+     *
      * @param buffer The bytes array to dump
      * @return A string representation of the array of bytes
      */
@@ -90,7 +81,7 @@ public final class Asn1StringUtils
 
     /**
      * Return UTF-8 encoded byte[] representation of a String
-     * 
+     *
      * @param string The string to be transformed to a byte array
      * @return The transformed byte array
      */
@@ -116,7 +107,7 @@ public final class Asn1StringUtils
     /**
      * Transform a string to an array of ASCII bytes, where the byte array will contain
      * only values in [0, 127].
-     * 
+     *
      * @param string The byte array to transform
      * @return The resulting string
      */

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java (original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapDecoder.java Thu Feb 10 21:47:27 2011
@@ -6,24 +6,24 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.ldap.codec;
 
 
 import java.io.InputStream;
 import java.nio.ByteBuffer;
+import java.security.ProviderException;
 
-import org.apache.directory.shared.asn1.DecoderCallback;
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
@@ -43,7 +43,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * The LdapDecoder decodes ASN.1 BER encoded PDUs.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class LdapDecoder implements ProtocolDecoder
@@ -57,9 +57,6 @@ public class LdapDecoder implements Prot
     /** The message container for this instance */
     private LdapMessageContainer<MessageDecorator<? extends Message>> ldapMessageContainer;
 
-    /** The callback to call when the decoding is done */
-    private DecoderCallback decoderCallback;
-
     /** The ASN 1 decoder instance */
     private Asn1Decoder asn1Decoder;
 
@@ -76,7 +73,7 @@ public class LdapDecoder implements Prot
     /**
      * Feeds the bytes within the input stream to the digester to generate the
      * resultant decoded Message.
-     * 
+     *
      * @param in The InputStream containing the PDU to be decoded
      * @throws ProviderException If the decoding went wrong
      */
@@ -112,7 +109,7 @@ public class LdapDecoder implements Prot
     /**
      * Decodes a PDU from an input stream into a Snickers compiler generated
      * stub envelope.
-     * 
+     *
      * @param lock Lock object used to exclusively read from the input stream
      * @param in The input stream to read and decode PDU bytes from
      * @return return decoded stub
@@ -177,31 +174,11 @@ public class LdapDecoder implements Prot
     }
 
 
-    /**
-     * Set the callback to call when the PDU has been decoded
-     * 
-     * @param cb The callback
-     */
-    public void setCallback( DecoderCallback cb )
-    {
-        decoderCallback = cb;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public DecoderCallback getCallback()
-    {
-        return decoderCallback;
-    }
-
-
     @SuppressWarnings("unchecked")
     public void decode( IoSession session, IoBuffer in, ProtocolDecoderOutput out ) throws Exception
     {
         ByteBuffer buf = in.buf();
-        LdapMessageContainer<MessageDecorator<? extends Message>> messageContainer = 
+        LdapMessageContainer<MessageDecorator<? extends Message>> messageContainer =
             ( LdapMessageContainer<MessageDecorator<? extends Message>> ) session.getAttribute( "messageContainer" );
 
         if ( session.containsAttribute( "maxPDUSize" ) )
@@ -252,9 +229,9 @@ public class LdapDecoder implements Prot
                     {
                         LOG.debug( "Decoded LdapMessage : " + messageContainer.getMessage() );
                     }
-                    
+
                     Message message = messageContainer.getMessage();
-                    
+
                     out.write( message );
 
                     messageContainer.clean();

Modified: directory/shared/branches/m1/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectTest.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectTest.java (original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectTest.java Thu Feb 10 21:47:27 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.ldap.extras.extended.ads_impl;
 
@@ -27,11 +27,8 @@ import static org.junit.Assert.fail;
 import java.nio.ByteBuffer;
 
 import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.EncoderException;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulDisconnect;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulDisconnectContainer;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulDisconnectDecoder;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -42,7 +39,7 @@ import com.mycila.junit.concurrent.Concu
 
 /**
  * Test the GracefulDisconnectTest codec
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(ConcurrentJunitRunner.class)
@@ -91,7 +88,7 @@ public class GracefulDisconnectTest
         assertEquals( 1, gracefulDisconnect.getDelay() );
         assertEquals( 2, gracefulDisconnect.getReplicatedContexts().size() );
         assertEquals( "ldap://directory.apache.org:80/", gracefulDisconnect.getReplicatedContexts().get( 0 ).toString() );
-        assertEquals( "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5c00%5c00%5c00%5c04)", gracefulDisconnect
+        assertEquals( "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5C00%5C00%5C00%5C04)", gracefulDisconnect
             .getReplicatedContexts().get( 1 ).toString() );
 
         // Check the length
@@ -112,7 +109,7 @@ public class GracefulDisconnectTest
             fail( ee.getMessage() );
         }
     }
-    
+
 
     /**
      * Test the decoding of a GracefulDisconnect with a timeOffline only
@@ -285,16 +282,16 @@ public class GracefulDisconnectTest
         Asn1Decoder decoder = new GracefulDisconnectDecoder();
         ByteBuffer stream = ByteBuffer.allocate( 0x6A );
         stream.put( new byte[]
-            { 
+            {
             0x30, 0x68,             // GracefulDisconnec ::= SEQUENCE {
               0x30, 0x66,           // replicatedContexts Referral OPTIONAL
-                0x04, 0x1F, 
+                0x04, 0x1F,
                   'l', 'd', 'a', 'p', ':', '/', '/', 'd', 'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', '.', 'a',
-                  'p', 'a', 'c', 'h', 'e', '.', 'o', 'r', 'g', ':', '8', '0', '/', 
-                0x04, 0x43, 
-                  'l', 'd', 'a', 'p', ':', '/', '/', 'l', 'd', 'a', 'p', '.', 'n', 'e', 't', 's', 'c', 'a', 
-                  'p', 'e', '.', 'c', 'o', 'm', '/', 'o', '=', 'B', 'a', 'b', 's', 'c', 'o', ',', 'c', '=', 
-                  'U', 'S', '?', '?', '?', '(', 'i', 'n', 't', '=', '%', '5', 'c', '0', '0', '%', '5', 'c', 
+                  'p', 'a', 'c', 'h', 'e', '.', 'o', 'r', 'g', ':', '8', '0', '/',
+                0x04, 0x43,
+                  'l', 'd', 'a', 'p', ':', '/', '/', 'l', 'd', 'a', 'p', '.', 'n', 'e', 't', 's', 'c', 'a',
+                  'p', 'e', '.', 'c', 'o', 'm', '/', 'o', '=', 'B', 'a', 'b', 's', 'c', 'o', ',', 'c', '=',
+                  'U', 'S', '?', '?', '?', '(', 'i', 'n', 't', '=', '%', '5', 'c', '0', '0', '%', '5', 'c',
                   '0', '0', '%', '5', 'c', '0', '0', '%', '5', 'c', '0', '4', ')'
             } );
 
@@ -318,7 +315,7 @@ public class GracefulDisconnectTest
         assertEquals( 0, gracefulDisconnect.getDelay() );
         assertEquals( 2, gracefulDisconnect.getReplicatedContexts().size() );
         assertEquals( "ldap://directory.apache.org:80/", gracefulDisconnect.getReplicatedContexts().get( 0 ).toString() );
-        assertEquals( "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5c00%5c00%5c00%5c04)", gracefulDisconnect
+        assertEquals( "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5C00%5C00%5C00%5C04)", gracefulDisconnect
             .getReplicatedContexts().get( 1 ).toString() );
 
         // Check the length

Modified: directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/filter/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/filter/LdapURL.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/filter/LdapURL.java (original)
+++ directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/filter/LdapURL.java Thu Feb 10 21:47:27 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.ldap.model.filter;
 
@@ -28,7 +28,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.directory.shared.asn1.Hex;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException;
@@ -295,7 +294,7 @@ public class LdapURL
 
     /**
      * Create a new LdapURL from a String after having parsed it.
-     * 
+     *
      * @param string TheString that contains the LDAPURL
      * @throws LdapURLEncodingException If the String does not comply with RFC 2255
      */
@@ -321,7 +320,7 @@ public class LdapURL
 
     /**
      * Create a new LdapURL after having parsed it.
-     * 
+     *
      * @param bytes The byte buffer that contains the LDAPURL
      * @throws LdapURLEncodingException If the byte array does not comply with RFC 2255
      */
@@ -356,7 +355,7 @@ public class LdapURL
      * &lt;hostnumber&gt; ::= &lt;digits&gt; "." &lt;digits&gt; "."
      * &lt;digits&gt; "." &lt;digits&gt;
      * </p>
-     * 
+     *
      * @param chars The buffer to parse
      * @param pos The current position in the byte buffer
      * @return The new position in the byte buffer, or -1 if the rule does not
@@ -402,7 +401,7 @@ public class LdapURL
                 }
 
                 // Let's check the string we had before the dot.
-                if ( isHostNumber && nbDots < 4 )
+                if ( isHostNumber && ( nbDots < 4 ) )
                 {
 
                     // We had only digits. It may be an IP adress? Check it
@@ -503,7 +502,7 @@ public class LdapURL
      * &lt;digit&gt; ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
      * </p>
      * The port must be between 0 and 65535.
-     * 
+     *
      * @param chars The buffer to parse
      * @param pos The current position in the byte buffer
      * @return The new position in the byte buffer, or -1 if the rule does not
@@ -542,7 +541,7 @@ public class LdapURL
      * <p>
      * &lt;hostport&gt; ::= &lt;host&gt; ':' &lt;port&gt;
      * </p>
-     * 
+     *
      * @param chars The char array to parse
      * @param pos The current position in the byte buffer
      * @return The new position in the byte buffer, or -1 if the rule does not
@@ -587,7 +586,7 @@ public class LdapURL
      * From commons-httpclients. Converts the byte array of HTTP content
      * characters to a string. If the specified charset is not supported,
      * default system encoding is used.
-     * 
+     *
      * @param data the byte array to be encoded
      * @param offset the index of the first byte to encode
      * @param length the number of bytes to encode
@@ -602,7 +601,7 @@ public class LdapURL
             throw new IllegalArgumentException( I18n.err( I18n.ERR_04411 ) );
         }
 
-        if ( charset == null || charset.length() == 0 )
+        if ( ( charset == null ) || ( charset.length() == 0 ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_04412 ) );
         }
@@ -622,7 +621,7 @@ public class LdapURL
      * From commons-httpclients. Converts the byte array of HTTP content
      * characters to a string. If the specified charset is not supported,
      * default system encoding is used.
-     * 
+     *
      * @param data the byte array to be encoded
      * @param charset the desired character encoding
      * @return The result of the conversion.
@@ -636,7 +635,7 @@ public class LdapURL
 
     /**
      * Converts the specified string to byte array of ASCII characters.
-     * 
+     *
      * @param data the string to be encoded
      * @return The string as a byte array.
      * @throws org.apache.directory.shared.ldap.model.exception.UrlDecoderException if encoding is not supported
@@ -664,7 +663,7 @@ public class LdapURL
      * From commons-codec. Decodes an array of URL safe 7-bit characters into an
      * array of original bytes. Escaped characters are converted back to their
      * original representation.
-     * 
+     *
      * @param bytes array of URL safe characters
      * @return array of original bytes
      * @throws UrlDecoderException Thrown if URL decoding is unsuccessful
@@ -689,7 +688,7 @@ public class LdapURL
                     int u = Character.digit( ( char ) bytes[++i], 16 );
                     int l = Character.digit( ( char ) bytes[++i], 16 );
 
-                    if ( u == -1 || l == -1 )
+                    if ( ( u == -1 ) || ( l == -1 ) )
                     {
                         throw new UrlDecoderException( I18n.err( I18n.ERR_04414 ) );
                     }
@@ -714,7 +713,7 @@ public class LdapURL
     /**
      * From commons-httpclients. Unescape and decode a given string regarded as
      * an escaped string with the default protocol charset.
-     * 
+     *
      * @param escaped a string
      * @return the unescaped string
      * @throws LdapUriException if the string cannot be decoded (invalid)
@@ -736,7 +735,7 @@ public class LdapURL
     /**
      * Parse a string and check that it complies with RFC 2253. Here, we will
      * just call the Dn parser to do the job.
-     * 
+     *
      * @param chars The char array to be checked
      * @param pos the starting position
      * @return -1 if the char array does not contains a Dn
@@ -770,7 +769,7 @@ public class LdapURL
 
     /**
      * Parse the attributes part
-     * 
+     *
      * @param chars The char array to be checked
      * @param pos the starting position
      * @return -1 if the char array does not contains attributes
@@ -878,7 +877,7 @@ public class LdapURL
 
     /**
      * Parse the filter part. We will use the FilterParserImpl class
-     * 
+     *
      * @param chars The char array to be checked
      * @param pos the starting position
      * @return -1 if the char array does not contains a filter
@@ -919,7 +918,7 @@ public class LdapURL
 
     /**
      * Parse the scope part.
-     * 
+     *
      * @param chars The char array to be checked
      * @param pos the starting position
      * @return -1 if the char array does not contains a scope
@@ -999,12 +998,12 @@ public class LdapURL
 
 
     /**
-     * Parse extensions and critical extensions. 
-     * 
-     * The grammar is : 
-     * extensions ::= extension [ ',' extension ]* 
+     * Parse extensions and critical extensions.
+     *
+     * The grammar is :
+     * extensions ::= extension [ ',' extension ]*
      * extension ::= [ '!' ] ( token | ( 'x-' | 'X-' ) token ) ) [ '=' exvalue ]
-     * 
+     *
      * @param chars The char array to be checked
      * @param pos the starting position
      * @return -1 if the char array does not contains valid extensions or
@@ -1125,7 +1124,7 @@ public class LdapURL
     /**
      * Encode a String to avoid special characters.
      *
-     * 
+     *
      * RFC 4516, section 2.1. (Percent-Encoding)
      *
      * A generated LDAP URL MUST consist only of the restricted set of
@@ -1139,7 +1138,7 @@ public class LdapURL
      * Implementations SHOULD accept other valid UTF-8 strings [RFC3629] as
      * input.  An octet MUST be encoded using the percent-encoding mechanism
      * described in section 2.1 of [RFC3986] in any of these situations:
-     * 
+     *
      *  The octet is not in the reserved set defined in section 2.2 of
      *  [RFC3986] or in the unreserved set defined in section 2.3 of
      *  [RFC3986].
@@ -1151,18 +1150,18 @@ public class LdapURL
      *
      *
      * RFC 3986, section 2.2 (Reserved Characters)
-     * 
+     *
      * reserved    = gen-delims / sub-delims
      * gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
      * sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
      *              / "*" / "+" / "," / ";" / "="
-     *             
-     *             
+     *
+     *
      * RFC 3986, section 2.3 (Unreserved Characters)
-     * 
+     *
      * unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
      *
-     * 
+     *
      * @param url The String to encode
      * @param doubleEncode Set if we need to encode the comma
      * @return An encoded string
@@ -1296,7 +1295,7 @@ public class LdapURL
 
                     // percent encoding
                     byte[] bytes = Unicode.charToBytes(c);
-                    char[] hex = Hex.encodeHex( bytes );
+                    char[] hex = Strings.toHexString( bytes ).toCharArray();
                     for ( int j = 0; j < hex.length; j++ )
                     {
                         if ( j % 2 == 0 )
@@ -1317,10 +1316,11 @@ public class LdapURL
 
     /**
      * Get a string representation of a LdapURL.
-     * 
+     *
      * @return A LdapURL string
      * @see LdapURL#forceScopeRendering
      */
+    @Override
     public String toString()
     {
         StringBuffer sb = new StringBuffer();
@@ -1338,7 +1338,7 @@ public class LdapURL
         {
             sb.append( '/' ).append( urlEncode( dn.getName(), false ) );
 
-            if ( attributes.size() != 0 || forceScopeRendering
+            if ( ( attributes.size() != 0 ) || forceScopeRendering
                 || ( ( scope != SearchScope.OBJECT ) || ( filter != null ) || ( extensionList.size() != 0 ) ) )
             {
                 sb.append( '?' );
@@ -1468,10 +1468,10 @@ public class LdapURL
 
     /**
      * Gets the extension.
-     * 
+     *
      * @param type the extension type, case-insensitive
-     * 
-     * @return Returns the extension, null if this URL does not contain 
+     *
+     * @return Returns the extension, null if this URL does not contain
      *         such an extension.
      */
     public Extension getExtension( String type )
@@ -1489,10 +1489,10 @@ public class LdapURL
 
     /**
      * Gets the extension value.
-     * 
+     *
      * @param type the extension type, case-insensitive
-     * 
-     * @return Returns the extension value, null if this URL does not  
+     *
+     * @return Returns the extension value, null if this URL does not
      *         contain such an extension or if the extension value is null.
      */
     public String getExtensionValue( String type )
@@ -1538,7 +1538,7 @@ public class LdapURL
     /**
      * Returns the scope, one of {@link SearchScope#OBJECT},
      * {@link SearchScope#ONELEVEL} or {@link SearchScope#SUBTREE}.
-     * 
+     *
      * @return Returns the scope.
      */
     public SearchScope getScope()
@@ -1637,12 +1637,12 @@ public class LdapURL
 
     /**
      * Sets the scheme. Must be "ldap://" or "ldaps://", otherwise "ldap://" is assumed as default.
-     * 
+     *
      * @param scheme the new scheme
      */
     public void setScheme( String scheme )
     {
-        if ( scheme != null && LDAP_SCHEME.equals( scheme ) || LDAPS_SCHEME.equals( scheme ) )
+        if ( ( ( scheme != null ) && LDAP_SCHEME.equals( scheme ) ) || LDAPS_SCHEME.equals( scheme ) )
         {
             this.scheme = scheme;
         }
@@ -1656,7 +1656,7 @@ public class LdapURL
 
     /**
      * Sets the host.
-     * 
+     *
      * @param host the new host
      */
     public void setHost( String host )
@@ -1667,12 +1667,12 @@ public class LdapURL
 
     /**
      * Sets the port. Must be between 1 and 65535, otherwise -1 is assumed as default.
-     * 
+     *
      * @param port the new port
      */
     public void setPort( int port )
     {
-        if ( port < 1 || port > 65535 )
+        if ( ( port < 1 ) || ( port > 65535 ) )
         {
             this.port = -1;
         }
@@ -1685,7 +1685,7 @@ public class LdapURL
 
     /**
      * Sets the dn.
-     * 
+     *
      * @param dn the new dn
      */
     public void setDn( Dn dn )
@@ -1696,7 +1696,7 @@ public class LdapURL
 
     /**
      * Sets the attributes, null removes all existing attributes.
-     * 
+     *
      * @param attributes the new attributes
      */
     public void setAttributes( List<String> attributes )
@@ -1716,7 +1716,7 @@ public class LdapURL
      * Sets the scope. Must be one of {@link SearchScope#OBJECT},
      * {@link SearchScope#ONELEVEL} or {@link SearchScope#SUBTREE},
      * otherwise {@link SearchScope#OBJECT} is assumed as default.
-     * 
+     *
      * @param scope the new scope
      */
     public void setScope( int scope )
@@ -1736,7 +1736,7 @@ public class LdapURL
      * Sets the scope. Must be one of {@link SearchScope#OBJECT},
      * {@link SearchScope#ONELEVEL} or {@link SearchScope#SUBTREE},
      * otherwise {@link SearchScope#OBJECT} is assumed as default.
-     * 
+     *
      * @param scope the new scope
      */
     public void setScope( SearchScope scope )
@@ -1754,7 +1754,7 @@ public class LdapURL
 
     /**
      * Sets the filter.
-     * 
+     *
      * @param filter the new filter
      */
     public void setFilter( String filter )
@@ -1764,10 +1764,10 @@ public class LdapURL
 
 
     /**
-     * If set to true forces the toString method to render the scope 
+     * If set to true forces the toString method to render the scope
      * regardless of optional nature.  Use this when you want explicit
      * search URL scope rendering.
-     * 
+     *
      * @param forceScopeRendering the forceScopeRendering to set
      */
     public void setForceScopeRendering( boolean forceScopeRendering )
@@ -1777,10 +1777,10 @@ public class LdapURL
 
 
     /**
-     * If set to true forces the toString method to render the scope 
+     * If set to true forces the toString method to render the scope
      * regardless of optional nature.  Use this when you want explicit
      * search URL scope rendering.
-     * 
+     *
      * @return the forceScopeRendering
      */
     public boolean isForceScopeRendering()
@@ -1818,7 +1818,7 @@ public class LdapURL
 
         /**
          * Checks if is critical.
-         * 
+         *
          * @return true, if is critical
          */
         public boolean isCritical()
@@ -1829,7 +1829,7 @@ public class LdapURL
 
         /**
          * Sets the critical flag.
-         * 
+         *
          * @param critical the new critical flag
          */
         public void setCritical( boolean critical )
@@ -1840,7 +1840,7 @@ public class LdapURL
 
         /**
          * Gets the type.
-         * 
+         *
          * @return the type
          */
         public String getType()
@@ -1851,7 +1851,7 @@ public class LdapURL
 
         /**
          * Sets the type.
-         * 
+         *
          * @param type the new type
          */
         public void setType( String type )
@@ -1862,7 +1862,7 @@ public class LdapURL
 
         /**
          * Gets the value.
-         * 
+         *
          * @return the value
          */
         public String getValue()
@@ -1873,7 +1873,7 @@ public class LdapURL
 
         /**
          * Sets the value.
-         * 
+         *
          * @param value the new value
          */
         public void setValue( String value )

Modified: directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/filter/LdapUrlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/filter/LdapUrlTest.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/filter/LdapUrlTest.java (original)
+++ directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/filter/LdapUrlTest.java Thu Feb 10 21:47:27 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.ldap.model.filter;
 
@@ -30,8 +30,6 @@ import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException;
 import org.apache.directory.shared.ldap.model.filter.LdapURL.Extension;
@@ -39,10 +37,13 @@ import org.apache.directory.shared.ldap.
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test the class LdapURL
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 @RunWith(ConcurrentJunitRunner.class)
@@ -611,7 +612,7 @@ public class LdapUrlTest
     @Test
     public void testLdapRFC2255_6() throws LdapURLEncodingException
     {
-        assertEquals( "ldap://ldap.question.com/o=Question%3f,c=US?mail", new LdapURL(
+        assertEquals( "ldap://ldap.question.com/o=Question%3F,c=US?mail", new LdapURL(
             "ldap://ldap.question.com/o=Question%3f,c=US?mail" ).toString() );
     }
 
@@ -622,7 +623,7 @@ public class LdapUrlTest
     @Test
     public void testLdapRFC2255_7() throws LdapURLEncodingException
     {
-        assertEquals( "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5c00%5c00%5c00%5c04)", new LdapURL(
+        assertEquals( "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5C00%5C00%5C00%5C04)", new LdapURL(
             "ldap://ldap.netscape.com/o=Babsco,c=US???(int=%5c00%5c00%5c00%5c04)" ).toString() );
     }
 
@@ -2057,7 +2058,7 @@ public class LdapUrlTest
 
 
     /**
-     * Test the extension order of an LdapURL. 
+     * Test the extension order of an LdapURL.
      */
     @Test
     public void testLdapURLExtensionOrder()
@@ -2118,13 +2119,13 @@ public class LdapUrlTest
         url1.setPort( 123 );
         url1.setDn( Dn.EMPTY_DN );
         url1.getExtensions().add( new Extension( false, "X-CONNECTION-NAME", germanChars ) );
-        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=%c3%84%c3%96%c3%9c%c3%9f%c3%a4%c3%b6%c3%bc", url1
+        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=%C3%84%C3%96%C3%9C%C3%9F%C3%A4%C3%B6%C3%BC", url1
             .toString() );
 
         LdapURL url2 = new LdapURL(
             "ldap://localhost:123/????X-CONNECTION-NAME=%c3%84%c3%96%c3%9c%c3%9f%c3%a4%c3%b6%c3%bc" );
         assertEquals( germanChars, url1.getExtensionValue( "X-CONNECTION-NAME" ) );
-        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=%c3%84%c3%96%c3%9c%c3%9f%c3%a4%c3%b6%c3%bc", url2
+        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=%C3%84%C3%96%C3%9C%C3%9F%C3%A4%C3%B6%C3%BC", url2
             .toString() );
     }
 
@@ -2150,14 +2151,14 @@ public class LdapUrlTest
 
     /**
      * Test with RFC 3986 reserved characters in extension value.
-     * 
+     *
      *   reserved    = gen-delims / sub-delims
      *   gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"
      *   sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
      *                 / "*" / "+" / "," / ";" / "="
-     *              
+     *
      * RFC 4516 specifies that '?' and a ',' must be percent encoded.
-     * 
+     *
      */
     @Test
     public void testLdapURLExtensionWithRFC3986ReservedCharsAndRFC4616Exception() throws Exception
@@ -2167,17 +2168,17 @@ public class LdapUrlTest
         url1.setPort( 123 );
         url1.setDn( Dn.EMPTY_DN );
         url1.getExtensions().add( new Extension( false, "X-CONNECTION-NAME", ":/?#[]@!$&'()*+,;=" ) );
-        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3f#[]@!$&'()*+%2c;=", url1.toString() );
+        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3F#[]@!$&'()*+%2c;=", url1.toString() );
 
         LdapURL url2 = new LdapURL( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3f#[]@!$&'()*+%2c;=" );
         assertEquals( ":/?#[]@!$&'()*+,;=", url1.getExtensionValue( "X-CONNECTION-NAME" ) );
-        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3f#[]@!$&'()*+%2c;=", url2.toString() );
+        assertEquals( "ldap://localhost:123/????X-CONNECTION-NAME=:/%3F#[]@!$&'()*+%2c;=", url2.toString() );
     }
 
 
     /**
      * Test with RFC 3986 unreserved characters in extension value.
-     * 
+     *
      *   unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"
      */
     @Test

Modified: directory/shared/branches/m1/util/src/main/java/org/apache/directory/shared/util/Strings.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/util/src/main/java/org/apache/directory/shared/util/Strings.java?rev=1069580&r1=1069579&r2=1069580&view=diff
==============================================================================
--- directory/shared/branches/m1/util/src/main/java/org/apache/directory/shared/util/Strings.java (original)
+++ directory/shared/branches/m1/util/src/main/java/org/apache/directory/shared/util/Strings.java Thu Feb 10 21:47:27 2011
@@ -6,22 +6,23 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.util;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import static org.apache.directory.shared.util.Chars.isHex;
+import static org.apache.directory.shared.util.Hex.encodeHex;
+import static org.apache.directory.shared.util.Hex.getHexValue;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStreamWriter;
@@ -33,15 +34,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import static org.apache.directory.shared.util.Chars.isHex;
-import static org.apache.directory.shared.util.Hex.encodeHex;
-import static org.apache.directory.shared.util.Hex.getHexValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Various string manipulation methods that are more efficient then chaining
  * string operations: all is done in the same buffer without creating a bunch of
  * string objects.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public final class Strings
@@ -51,7 +51,7 @@ public final class Strings
 
     /** The default charset, because it's not provided by JDK 1.5 */
     static String defaultCharset = null;
-    
+
 
     /** Hex chars */
     private static final byte[] HEX_CHAR = new byte[]
@@ -175,11 +175,11 @@ public final class Strings
 
         return sb.toString();
     }
-    
+
 
     /**
      * Helper function that dump a byte in hex form
-     * 
+     *
      * @param octet The byte to dump
      * @return A string representation of the byte
      */
@@ -192,7 +192,7 @@ public final class Strings
 
     /**
      * Helper function that returns a char from an hex
-     * 
+     *
      * @param hex The hex to dump
      * @return A char representation of the hex
      */
@@ -203,9 +203,9 @@ public final class Strings
 
 
     /**
-     * Helper function that dump an array of bytes in hex pair form, 
+     * Helper function that dump an array of bytes in hex pair form,
      * without '0x' and space chars
-     * 
+     *
      * @param buffer The bytes array to dump
      * @return A string representation of the array of bytes
      */
@@ -215,27 +215,27 @@ public final class Strings
         {
             return "";
         }
-    
+
         char[] str = new char[buffer.length << 1];
-    
+
         for ( int i = 0, pos = 0; i < buffer.length; i++ )
         {
             str[pos++] = ( char ) ( HEX_CHAR[( buffer[i] & 0x00F0 ) >> 4] );
             str[pos++] = ( char ) ( HEX_CHAR[buffer[i] & 0x000F] );
         }
-    
+
         return new String( str );
     }
 
 
     /**
      * Put common code to deepTrim(String) and deepTrimToLower here.
-     * 
+     *
      * @param str the string to deep trim
      * @param toLowerCase how to normalize for case: upper or lower
      * @return the deep trimmed string
      * @see Strings#deepTrim( String )
-     * 
+     *
      * TODO Replace the toCharArray() by substring manipulations
      */
     public static String deepTrim( String str, boolean toLowerCase )
@@ -244,24 +244,24 @@ public final class Strings
         {
             return "";
         }
-    
+
         char ch;
         char[] buf = str.toCharArray();
         char[] newbuf = new char[buf.length];
         boolean wsSeen = false;
         boolean isStart = true;
         int pos = 0;
-    
+
         for ( int i = 0; i < str.length(); i++ )
         {
             ch = buf[i];
-    
+
             // filter out all uppercase characters
             if ( toLowerCase && Character.isUpperCase( ch ) )
             {
                 ch = Character.toLowerCase( ch );
             }
-    
+
             // Check to see if we should add space
             if ( Character.isWhitespace( ch ) )
             {
@@ -275,7 +275,7 @@ public final class Strings
                 else
                 {
                     wsSeen = true;
-    
+
                     if ( isStart )
                     {
                         isStart = false;
@@ -294,7 +294,7 @@ public final class Strings
                 newbuf[pos++] = ch;
             }
         }
-    
+
         return ( pos == 0 ? "" : new String( newbuf, 0, ( wsSeen ? pos - 1 : pos ) ) );
     }
 
@@ -304,7 +304,7 @@ public final class Strings
      * performing the deep trim within the same buffer. This saves us from
      * having to create multiple String and StringBuffer objects and is much
      * more efficient.
-     * 
+     *
      * @see Strings#deepTrim( String )
      */
     public static String deepTrimToLower( String string )
@@ -319,7 +319,7 @@ public final class Strings
      * non-whitespace characters. A deep trim reduces internal whitespace down
      * to a single space to perserve the whitespace separated tokenization order
      * of the String.
-     * 
+     *
      * @param string the string to deep trim.
      * @return the trimmed string.
      */
@@ -331,7 +331,7 @@ public final class Strings
 
     /**
      * Trims several consecutive characters into one.
-     * 
+     *
      * @param str the string to trim consecutive characters of
      * @param ch the character to trim down
      * @return the newly trimmed down string
@@ -342,16 +342,16 @@ public final class Strings
         {
             return "";
         }
-    
+
         char[] buffer = str.toCharArray();
         char[] newbuf = new char[buffer.length];
         int pos = 0;
         boolean same = false;
-    
+
         for ( int i = 0; i < buffer.length; i++ )
         {
             char car = buffer[i];
-    
+
             if ( car == ch )
             {
                 if ( same )
@@ -370,17 +370,17 @@ public final class Strings
                 newbuf[pos++] = car;
             }
         }
-    
+
         return new String( newbuf, 0, pos );
     }
-    
+
 
     /**
      * Truncates large Strings showing a portion of the String's head and tail
      * with the center cut out and replaced with '...'. Also displays the total
      * length of the truncated string so size of '...' can be interpreted.
      * Useful for large strings in UIs or hex dumps to log files.
-     * 
+     *
      * @param str the string to truncate
      * @param head the amount of the head to display
      * @param tail the amount of the tail to display
@@ -389,7 +389,7 @@ public final class Strings
     public static String centerTrunc( String str, int head, int tail )
     {
         StringBuffer buf = null;
-    
+
         // Return as-is if String is smaller than or equal to the head plus the
         // tail plus the number of characters added to the trunc representation
         // plus the number of digits in the string length.
@@ -397,7 +397,7 @@ public final class Strings
         {
             return str;
         }
-    
+
         buf = new StringBuffer();
         buf.append( '[' ).append( str.length() ).append( "][" );
         buf.append( str.substring( 0, head ) ).append( "..." );
@@ -405,36 +405,37 @@ public final class Strings
         buf.append( ']' );
         return buf.toString();
     }
-    
+
 
     /**
      * Gets a hex string from byte array.
-     * 
+     *
      * @param res the byte array
      * @return the hex string representing the binary values in the array
      */
     public static String toHexString( byte[] res )
     {
         StringBuffer buf = new StringBuffer( res.length << 1 );
-        
+
         for ( int ii = 0; ii < res.length; ii++ )
         {
             String digit = Integer.toHexString( 0xFF & res[ii] );
-            
+
             if ( digit.length() == 1 )
             {
                 digit = '0' + digit;
             }
-            
+
             buf.append( digit );
         }
+
         return buf.toString().toUpperCase();
     }
-    
+
 
     /**
      * Get byte array from hex string
-     * 
+     *
      * @param hexString the hex string to convert to a byte array
      * @return the byte form of the hex string.
      */
@@ -442,22 +443,22 @@ public final class Strings
     {
         int arrLength = hexString.length() >> 1;
         byte [] buf = new byte[arrLength];
-        
+
         for ( int ii = 0; ii < arrLength; ii++ )
         {
             int index = ii << 1;
-            
+
             String digit = hexString.substring( index, index + 2 );
             buf[ii] = ( byte ) Integer.parseInt( digit, 16 );
         }
-        
+
         return buf;
     }
-    
+
 
     /**
      * This method is used to insert HTML block dynamically
-     * 
+     *
      * @param source the HTML code to be processes
      * @param replaceNl if true '\n' will be replaced by &lt;br>
      * @param replaceTag if true '<' will be replaced by &lt; and '>' will be replaced
@@ -470,11 +471,11 @@ public final class Strings
     {
         StringBuffer buf = new StringBuffer();
         int len = source.length();
-    
+
         for ( int ii = 0; ii < len; ii++ )
         {
             char ch = source.charAt( ii );
-            
+
             switch ( ch )
             {
                 case '\"':
@@ -487,7 +488,7 @@ public final class Strings
                         buf.append( ch );
                     }
                     break;
-    
+
                 case '<':
                     if ( replaceTag )
                     {
@@ -498,7 +499,7 @@ public final class Strings
                         buf.append( ch );
                     }
                     break;
-    
+
                 case '>':
                     if ( replaceTag )
                     {
@@ -509,7 +510,7 @@ public final class Strings
                         buf.append( ch );
                     }
                     break;
-    
+
                 case '\n':
                     if ( replaceNl )
                     {
@@ -527,27 +528,27 @@ public final class Strings
                         buf.append( ch );
                     }
                     break;
-    
+
                 case '\r':
                     break;
-    
+
                 case '&':
                     buf.append( "&amp;" );
                     break;
-    
+
                 default:
                     buf.append( ch );
                     break;
             }
         }
-    
+
         return buf.toString();
     }
-    
+
 
     /**
      * Check if a text is present at the current position in another string.
-     * 
+     *
      * @param string The string which contains the data
      * @param index Current position in the string
      * @param text The text we want to check
@@ -555,14 +556,14 @@ public final class Strings
      */
     public static boolean areEquals( String string, int index, String text )
     {
-        if ( ( string == null ) || ( text == null ) ) 
+        if ( ( string == null ) || ( text == null ) )
         {
             return false;
         }
-        
+
         int length1 = string.length();
         int length2 = text.length();
-    
+
         if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 )
             || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) )
         {
@@ -573,13 +574,13 @@ public final class Strings
             return string.substring( index ).startsWith( text );
         }
     }
-    
+
 
     /**
      * Test if the current character is equal to a specific character. This
      * function works only for character between 0 and 127, as it does compare a
      * byte and a char (which is 16 bits wide)
-     * 
+     *
      * @param byteArray The buffer which contains the data
      * @param index Current position in the buffer
      * @param car The character we want to compare with the current buffer position
@@ -600,7 +601,7 @@ public final class Strings
 
     /**
      * Test if the current character is equal to a specific character.
-     * 
+     *
      * @param string The String which contains the data
      * @param index Current position in the string
      * @param car The character we want to compare with the current string position
@@ -612,9 +613,9 @@ public final class Strings
         {
             return false;
         }
-        
+
         int length = string.length();
-        
+
         if ( ( length == 0 ) || ( index < 0 ) || ( index >= length ) )
         {
             return false;
@@ -846,7 +847,7 @@ public final class Strings
      */
     public static boolean isEmpty( String str )
     {
-        return str == null || str.length() == 0;
+        return ( str == null ) || ( str.length() == 0 );
     }
 
 
@@ -858,7 +859,7 @@ public final class Strings
      */
     public static boolean isEmpty( byte[] bytes )
     {
-        return bytes == null || bytes.length == 0;
+        return ( bytes == null ) || ( bytes.length == 0 );
     }
 
 
@@ -1839,7 +1840,7 @@ public final class Strings
      */
     public static boolean isNotEmpty( String str )
     {
-        return str != null && str.length() > 0;
+        return ( str != null ) && ( str.length() > 0 );
     }
 
 
@@ -1889,13 +1890,13 @@ public final class Strings
 
         if ( isHex( b[0] ) && isHex( b[1] ) && isHex( b[2] ) && isHex( b[3] )
             && isHex( b[4] ) && isHex( b[5] ) && isHex( b[6] ) && isHex( b[7] )
-            && b[8] == '-'
+            && ( b[8] == '-' )
             && isHex( b[9] ) && isHex( b[10] ) && isHex( b[11] ) && isHex( b[12] )
-            && b[13] == '-'
+            && ( b[13] == '-' )
             && isHex( b[14] ) && isHex( b[15] ) && isHex( b[16] ) && isHex( b[17] )
-            && b[18] == '-'
+            && ( b[18] == '-' )
             && isHex( b[19] ) && isHex( b[20] ) && isHex( b[21] ) && isHex( b[22] )
-            && b[23] == '-'
+            && ( b[23] == '-' )
             && isHex( b[24] ) && isHex( b[25] ) && isHex( b[26] ) && isHex( b[27] )
             && isHex( b[28] ) && isHex( b[29] ) && isHex( b[30] ) && isHex( b[31] )
             && isHex( b[32] ) && isHex( b[33] ) && isHex( b[34] ) && isHex( b[35] ) )
@@ -1918,7 +1919,7 @@ public final class Strings
      */
     public static String uuidToString( byte[] bytes )
     {
-        if ( bytes == null || bytes.length != 16 )
+        if ( ( bytes == null ) || ( bytes.length != 16 ) )
         {
             return "Invalid UUID";
         }
@@ -1977,11 +1978,11 @@ public final class Strings
 
         return bytes;
     }
-    
-    
+
+
     /**
      * Copy a byte array into a new byte array
-     * 
+     *
      * @param value the byte array to copy
      * @return The copied byte array
      */
@@ -1991,10 +1992,10 @@ public final class Strings
     	{
     		return StringConstants.EMPTY_BYTES;
     	}
-    	
+
     	byte[] copy = new byte[value.length];
     	System.arraycopy( value, 0, copy, 0, value.length );
-    	
+
     	return copy;
     }
 }



Mime
View raw message