directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r487404 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BitStringSyntaxChecker.java
Date Fri, 15 Dec 2006 00:05:36 GMT
Author: elecharny
Date: Thu Dec 14 16:05:35 2006
New Revision: 487404

URL: http://svn.apache.org/viewvc?view=rev&rev=487404
Log:
Added a static method to validate a BitString, as this method will be used in two classes
(BitString and NameAndOptionalUID syntax checker)

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BitStringSyntaxChecker.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BitStringSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BitStringSyntaxChecker.java?view=diff&rev=487404&r1=487403&r2=487404
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BitStringSyntaxChecker.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/syntax/BitStringSyntaxChecker.java
Thu Dec 14 16:05:35 2006
@@ -86,32 +86,17 @@
         return oid;
     }
 
-
-    /* (non-Javadoc)
-     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+    /**
+     * A shared and static method used to check that the string is a BitString.
+     * A BitString is a string of bits, between quots and followed by a 'B' :
+     * 
+     * '01010110'B for instance
+     * 
+     * @param strValue The string to check
+     * @return <code>true</code> if teh string is a BitString
      */
-    public boolean isValidSyntax( Object value )
+    public static boolean isValid( String strValue )
     {
-        String strValue;
-
-        if ( value == null )
-        {
-            return false;
-        }
-        
-        if ( value instanceof String )
-        {
-            strValue = ( String ) value;
-        }
-        else if ( value instanceof byte[] )
-        {
-            strValue = StringTools.utf8ToString( ( byte[] ) value ); 
-        }
-        else
-        {
-            strValue = value.toString();
-        }
-
         if ( strValue.length() == 0 )
         {
             return false;
@@ -150,5 +135,33 @@
         }
 
         return true;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.shared.ldap.schema.SyntaxChecker#isValidSyntax(java.lang.Object)
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue;
+
+        if ( value == null )
+        {
+            return false;
+        }
+        
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = StringTools.utf8ToString( ( byte[] ) value ); 
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        return isValid( strValue );
     }
 }



Mime
View raw message