directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r208737 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
Date Fri, 01 Jul 2005 09:16:55 GMT
Author: elecharny
Date: Fri Jul  1 02:16:54 2005
New Revision: 208737

URL: http://svn.apache.org/viewcvs?rev=208737&view=rev
Log:
Moved some methods to StringUtils where the deserved to be declared...

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java?rev=208737&r1=208736&r2=208737&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
Fri Jul  1 02:16:54 2005
@@ -70,36 +70,6 @@
         false, false, false
     };
 
-    /** <alpha>    ::= [0x41-0x5A] | [0x61-0x7A] */
-    private static final boolean[] ALPHA =
-    {
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        true, true, true, true, true, true, true, true, true, true, true, true, true, true,
true,
-        true, true, true, true, true, true, true, true, true, true, true, false, false, false,
-        false, false, false, true, true, true, true, true, true, true, true, true, true,
true,
-        true, true, true, true, true, true, true, true, true, true, true, true, true, true,
true,
-        false, false, false, false, false
-    };
-
-    /** <alpha> | <digit> | '-' */
-    private static final boolean[] CHAR =
-    {
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, true, false, false, true, true, true, true,
true,
-        true, true, true, true, true, false, false, false, false, false, false, false, true,
true,
-        true, true, true, true, true, true, true, true, true, true, true, true, true, true,
true,
-        true, true, true, true, true, true, true, true, true, false, false, false, false,
false,
-        false, true, true, true, true, true, true, true, true, true, true, true, true, true,
true,
-        true, true, true, true, true, true, true, true, true, true, true, true, false, false,
-        false, false, false
-    };
-
     /** '"'  | '#'  | '+'  | ','  | [0-9] | ';'  | '<'  | '='  | '>'  | [A-F] | '\'
| [a-f] 
      * 0x22 | 0x23 | 0x2B | 0x2C | [0x30-0x39] | 0x3B | 0x3C | 0x3D | 0x3E | [0x41-0x46]
| 0x5C | [0x61-0x66] */
     private static final boolean[] PAIR_CHAR =
@@ -116,137 +86,9 @@
         false, false, false, false, false, false, false, false
     };
 
-    /** '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' */
-    private static final boolean[] DIGIT =
-    {
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, true, true, true,
true,
-        true, true, true, true, true, true, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false,
-    };
-
-    /** <hex>    ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] */
-    private static final boolean[] HEX =
-    {
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false, true, true, true,
true,
-        true, true, true, true, true, true, false, false, false, false, false, false, false,
true,
-        true, true, true, true, true, false, false, false, false, false, false, false, false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, true, true, true, true, true, true, false, false,
false,
-        false, false, false, false, false, false, false, false, false, false, false, false,
false,
-        false, false, false, false, false, false, false, false, false
-    };
-
     //~ Methods ------------------------------------------------------------------------------------
 
     /**
-     * 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
-     *
-     * @return <code>true</code> if the current character equals the given character.
-     */
-    public static boolean isCharASCII( byte[] byteArray, int index, char car )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
-                ( index >= byteArray.length ) )
-        {
-            return false;
-        }
-        else
-        {
-            return ( ( byteArray[index] == car ) ? true : false );
-        }
-    }
-
-    /**
-     * Test if the current character is a digit
-     * <digit>    ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
-     *
-     * @param byteArray The buffer which contains the data
-     * @param index Current position in the buffer
-     *
-     * @return <code>true</code> if the current character is a Digit
-     */
-    public static boolean isDigit( byte[] byteArray, int index )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
-                ( index >= byteArray.length ) )
-        {
-            return false;
-        }
-        else
-        {
-            return ( ( ( byteArray[index] > 127 ) || ! DIGIT[byteArray[index]] ) ? false
: true );
-        }
-    }
-
-    /**
-     * Test if the current character is a digit
-     * <digit>    ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
-     *
-     * @param byteArray The buffer which contains the data
-     *
-     * @return <code>true</code> if the current character is a Digit
-     */
-    public static boolean isDigit( byte[] byteArray )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) )
-        {
-            return false;
-        }
-        else
-        {
-            return ( ( ( byteArray[0] > 127 ) || ! DIGIT[byteArray[0]] ) ? false : true
);
-        }
-    }
-
-    /**
-     * Test if the current character is an Alpha character :
-     *  <alpha>    ::= [0x41-0x5A] | [0x61-0x7A]
-     * 
-     * @param byteArray The buffer which contains the data
-     * @param index Current position in the buffer
-     *
-     * @return <code>true</code> if the current character is an Alpha character
-     */
-    public static boolean isAlphaASCII( byte[] byteArray, int index )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
-                ( index >= byteArray.length ) )
-        {
-            return false;
-        }
-        else
-        {
-            byte c = byteArray[index++];
-
-            if ( ( c > 127 ) || ( ALPHA[c] == false ) )
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-    }
-
-    /**
      * Walk the buffer while characters are Safe String characters :
      *  <safe-string>    ::= <safe-init-char> <safe-chars>
      *  <safe-init-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39]
| 0x3B | [0x3D-0x7F]
@@ -312,7 +154,7 @@
         {
             byte c = byteArray[index++];
 
-            if ( ( c > 127 ) || ( ALPHA[c] == false ) )
+            if ( ( c > 127 ) || ( StringUtils.ALPHA[c] == false ) )
             {
                 return -1;
             }
@@ -324,37 +166,6 @@
     }
 
     /**
-     * Check if the current character is an Hex Char
-     *  <hex>    ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66]
-     * 
-     * @param byteArray The buffer which contains the data
-     * @param index Current position in the buffer
-     *
-     * @return <code>true</code> if the current character is a Hex Char
-     */
-    public static boolean isHex( byte[] byteArray, int index )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
-                ( index >= byteArray.length ) )
-        {
-            return false;
-        }
-        else
-        {
-            byte c = byteArray[index];
-
-            if ( ( c > 127 ) || ( HEX[c] == false ) )
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-    }
-
-    /**
      * Check if the current character is a Pair Char
      *  <pairchar>    ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"'
| [0-9a-fA-F] [0-9a-fA-F]
      *  
@@ -380,9 +191,9 @@
             }
             else
             {
-                if ( isHex( byteArray, index++ ) )
+                if ( StringUtils.isHex( byteArray, index++ ) )
                 {
-                    return isHex( byteArray, index );
+                    return StringUtils.isHex( byteArray, index );
                 }
                 else
                 {
@@ -477,9 +288,9 @@
      */
     public static int parseHexPair( byte[] byteArray, int index )
     {
-        if ( isHex( byteArray, index ) )
+        if ( StringUtils.isHex( byteArray, index ) )
         {
-            if ( isHex( byteArray, index + 1 ) )
+            if ( StringUtils.isHex( byteArray, index + 1 ) )
             {
                 return index + 2;
             }
@@ -527,37 +338,6 @@
     }
 
     /**
-     * Check if the current character is an 7 bits ASCII CHAR (between 0 and 127).
-     *   <char>    ::= <alpha> | <digit> | '-'
-     *
-     * @param byteArray The buffer which contains the data
-     * @param index Current position in the buffer
-     *
-     * @return The position of the next character, if the current one is a CHAR.
-     */
-    public static int parseCharASCII( byte[] byteArray, int index )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( index < 0 ) ||
-                ( index >= byteArray.length ) )
-        {
-            return -1;
-        }
-        else
-        {
-            byte c = byteArray[index++];
-
-            if ( ( c > 127 ) || ( CHAR[c] == false ) )
-            {
-                return -1;
-            }
-            else
-            {
-                return index;
-            }
-        }
-    }
-
-    /**
      * Walk the buffer while characters are Base64 characters : 
      *     <base64-string>      ::= <base64-char> <base64-chars>
      *  <base64-chars>       ::= <base64-char> <base64-chars> |
@@ -602,99 +382,4 @@
         }
     }
 
-    /**
-     * Check if a text is present at the current position in a buffer.
-     *
-     * @param byteArray The buffer which contains the data
-     * @param index Current position in the buffer
-     * @param text The text we want to check
-     *
-     * @return <code>true</code> if the buffer contains the text.
-     */
-    public static int areEquals( byte[] byteArray, int index, String text )
-    {
-        if ( ( byteArray == null ) || ( byteArray.length == 0 ) || ( byteArray.length <=
index ) ||
-                ( index < 0 ) || ( text == null ) )
-        {
-            return -1;
-        }
-        else
-        {
-            byte[] data = text.getBytes();
-
-            return areEquals( byteArray, index, data );
-        }
-    }
-
-    /**
-     * Check if a text is present at the current position in a buffer.
-     *
-     * @param charArray The buffer which contains the data
-     * @param index Current position in the buffer
-     * @param charArray2 The text we want to check
-     *
-     * @return <code>true</code> if the buffer contains the text.
-     */
-    public static int areEquals( char[] charArray, int index, char[] charArray2 )
-    {
-
-        if ( ( charArray == null ) ||
-                ( charArray.length == 0 ) ||
-                ( charArray.length <= index ) ||
-                ( index < 0 ) ||
-                ( charArray2 == null ) ||
-                ( charArray2.length == 0 ) ||
-                ( charArray2.length > ( charArray.length + index ) ) )
-        {
-            return -1;
-        }
-        else
-        {
-            for ( int i = 0; i < charArray2.length; i++ )
-            {
-                if ( charArray[index++] != charArray2[i] )
-                {
-                    return -1;
-                }
-            }
-
-            return index;
-        }
-    }
-
-    /**
-     * Check if a text is present at the current position in a buffer.
-     *
-     * @param byteArray The buffer which contains the data
-     * @param index Current position in the buffer
-     * @param byteArray2 The text we want to check
-     *
-     * @return <code>true</code> if the buffer contains the text.
-     */
-    public static int areEquals( byte[] byteArray, int index, byte[] byteArray2 )
-    {
-
-        if ( ( byteArray == null ) ||
-                ( byteArray.length == 0 ) ||
-                ( byteArray.length <= index ) ||
-                ( index < 0 ) ||
-                ( byteArray2 == null ) ||
-                ( byteArray2.length == 0 ) ||
-                ( byteArray2.length > ( byteArray.length + index ) ) )
-        {
-            return -1;
-        }
-        else
-        {
-            for ( int i = 0; i < byteArray2.length; i++ )
-            {
-                if ( byteArray[index++] != byteArray2[i] )
-                {
-                    return -1;
-                }
-            }
-
-            return index;
-        }
-    }
 }



Mime
View raw message