Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 77562 invoked from network); 1 Jul 2005 09:17:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Jul 2005 09:17:02 -0000 Received: (qmail 45596 invoked by uid 500); 1 Jul 2005 09:17:01 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 45503 invoked by uid 500); 1 Jul 2005 09:17:01 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 45471 invoked by uid 99); 1 Jul 2005 09:16:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2005 02:16:59 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 01 Jul 2005 02:16:58 -0700 Received: (qmail 77532 invoked by uid 65534); 1 Jul 2005 09:16:55 -0000 Message-ID: <20050701091655.77530.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.2 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 }; - /** ::= [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 - }; - - /** | | '-' */ - 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, - }; - - /** ::= [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 true 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 - * ::= '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 true 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 - * ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' - * - * @param byteArray The buffer which contains the data - * - * @return true 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 : - * ::= [0x41-0x5A] | [0x61-0x7A] - * - * @param byteArray The buffer which contains the data - * @param index Current position in the buffer - * - * @return true 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 : * ::= * ::= [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 - * ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] - * - * @param byteArray The buffer which contains the data - * @param index Current position in the buffer - * - * @return true 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 * ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"' | [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). - * ::= | | '-' - * - * @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 : * ::= * ::= | @@ -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 true 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 true 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 true 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; - } - } }