directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r437313 - in /directory/trunks/shared/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/filter/ main/java/org/apache/directory/shared/ldap/name/ main/java/org/apache/directory/shared/ldap/schema/ test/java/org/apache/director...
Date Sun, 27 Aug 2006 07:07:03 GMT
Author: akarasulu
Date: Sun Aug 27 00:07:03 2006
New Revision: 437313

URL: http://svn.apache.org/viewvc?rev=437313&view=rev
Log:
Fix for DIRSERVER-169 and partially for DIRSERVER-715

Added:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ByteArrayComparator.java
      - copied unchanged from r437312, directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ByteArrayComparator.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/schema/ByteArrayComparatorTest.java
      - copied unchanged from r437312, directory/branches/shared/0.9.5/ldap/src/test/java/org/apache/directory/shared/ldap/schema/ByteArrayComparatorTest.java
Modified:
    directory/trunks/shared/ldap/src/main/antlr/filter-parser.g
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/NameComponentNormalizer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NoOpNormalizer.java

Modified: directory/trunks/shared/ldap/src/main/antlr/filter-parser.g
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/antlr/filter-parser.g?rev=437313&r1=437312&r2=437313&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/antlr/filter-parser.g (original)
+++ directory/trunks/shared/ldap/src/main/antlr/filter-parser.g Sun Aug 27 00:07:03 2006
@@ -27,6 +27,7 @@
 
 import antlr.*;
 import java.util.ArrayList;
+import org.apache.directory.shared.ldap.util.StringTools;
 }
 
 // ----------------------------------------------------------------------------
@@ -288,18 +289,42 @@
       {
         selector.select( valueLexer );
         Object value = valueParser.value( attribute );
+        
+        if ( value instanceof String )
+        {
+            String str = ( String ) value;
+            if ( str.charAt( 0 ) == '#' )
+            {
+                value = StringTools.toByteArray( str.substring( 1 ) );
+            }
+            else
+            {
+                value = str.trim();
+            }
+        }
 
         switch( type )
         {
             case( AbstractExprNode.APPROXIMATE ):
             case( AbstractExprNode.GREATEREQ ):
             case( AbstractExprNode.LESSEQ ):
-                node = new SimpleNode( attribute, ( ( String ) value).trim(), type );
+                if ( value instanceof String )
+                {
+                    node = new SimpleNode( attribute, ( String ) value, type );
+                }
+                else if ( value instanceof byte[] )
+                {
+                    node = new SimpleNode( attribute, ( byte[] ) value, type );
+                }
                 break;
             case( AbstractExprNode.EQUALITY ):
                 if ( value instanceof String )
                 {
-                    node = new SimpleNode( attribute, ( ( String ) value ).trim(), type );
+                    node = new SimpleNode( attribute, ( String ) value, type );
+                }
+                else if ( value instanceof byte[] )
+                {
+                    node = new SimpleNode( attribute, ( byte[] ) value, type );
                 }
                 else
                 {

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=437313&r1=437312&r2=437313&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
Sun Aug 27 00:07:03 2006
@@ -32,7 +32,7 @@
 public class SimpleNode extends LeafNode
 {
     /** the value */
-    private String value;
+    private Object value;
 
 
     /**
@@ -47,7 +47,39 @@
      */
     public SimpleNode( String attribute, byte[] value, int type )
     {
-        this( attribute, StringTools.utf8ToString( value ), type );
+//        this( attribute, StringTools.utf8ToString( value ), type );
+        super( attribute, type );
+        this.value = value;
+
+        switch ( type )
+        {
+            case ( APPROXIMATE ):
+                break;
+
+            case ( EQUALITY ):
+                break;
+
+            case ( EXTENSIBLE ):
+                throw new IllegalArgumentException( "Assertion type supplied is "
+                    + "extensible.  Use ExtensibleNode instead." );
+
+            case ( GREATEREQ ):
+                break;
+
+            case ( LESSEQ ):
+                break;
+
+            case ( PRESENCE ):
+                throw new IllegalArgumentException( "Assertion type supplied is "
+                    + "presence.  Use PresenceNode instead." );
+
+            case ( SUBSTRING ):
+                throw new IllegalArgumentException( "Assertion type supplied is "
+                    + "substring.  Use SubstringNode instead." );
+
+            default:
+                throw new IllegalArgumentException( "Attribute value assertion type is undefined."
);
+        }
     }
 
 
@@ -103,7 +135,7 @@
      * 
      * @return the value
      */
-    public final String getValue()
+    public final Object getValue()
     {
         return value;
     }
@@ -112,10 +144,9 @@
     /**
      * Sets the value of this node.
      * 
-     * @param value
-     *            the value for this node
+     * @param value the value for this node
      */
-    public void setValue( String value )
+    public void setValue( Object value )
     {
         this.value = value;
     }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/NameComponentNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/NameComponentNormalizer.java?rev=437313&r1=437312&r2=437313&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/NameComponentNormalizer.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/NameComponentNormalizer.java
Sun Aug 27 00:07:03 2006
@@ -62,7 +62,7 @@
      * @throws NamingException
      *             if there is a recognition problem or a syntax issue
      */
-    String normalizeByName( String attributeName, String value ) throws NamingException;
+    Object normalizeByName( String attributeName, String value ) throws NamingException;
 
 
     /**
@@ -77,7 +77,7 @@
      * @throws NamingException
      *             if there is a recognition problem or a syntax issue
      */
-    String normalizeByName( String attributeName, byte[] value ) throws NamingException;
+    Object normalizeByName( String attributeName, byte[] value ) throws NamingException;
 
 
     /**
@@ -91,7 +91,7 @@
      * @throws NamingException
      *             if there is a recognition problem or a syntax issue
      */
-    String normalizeByOid( String attributeOid, String value ) throws NamingException;
+    Object normalizeByOid( String attributeOid, String value ) throws NamingException;
 
 
     /**
@@ -105,5 +105,5 @@
      * @throws NamingException
      *             if there is a recognition problem or a syntax issue
      */
-    String normalizeByOid( String attributeOid, byte[] value ) throws NamingException;
+    Object normalizeByOid( String attributeOid, byte[] value ) throws NamingException;
 }

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java?rev=437313&r1=437312&r2=437313&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/name/SimpleNameComponentNormalizer.java
Sun Aug 27 00:07:03 2006
@@ -53,27 +53,27 @@
     }
 
 
-    public String normalizeByName( String name, String val ) throws NamingException
+    public Object normalizeByName( String name, String val ) throws NamingException
     {
-        return ( String ) normalizer.normalize( val );
+        return normalizer.normalize( val );
     }
 
 
-    public String normalizeByName( String name, byte[] val ) throws NamingException
+    public Object normalizeByName( String name, byte[] val ) throws NamingException
     {
-        return ( String ) normalizer.normalize( val );
+        return normalizer.normalize( val );
     }
 
 
-    public String normalizeByOid( String oid, String val ) throws NamingException
+    public Object normalizeByOid( String oid, String val ) throws NamingException
     {
-        return ( String ) normalizer.normalize( val );
+        return normalizer.normalize( val );
     }
 
 
-    public String normalizeByOid( String oid, byte[] val ) throws NamingException
+    public Object normalizeByOid( String oid, byte[] val ) throws NamingException
     {
-        return ( String ) normalizer.normalize( val );
+        return normalizer.normalize( val );
     }
 
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NoOpNormalizer.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NoOpNormalizer.java?rev=437313&r1=437312&r2=437313&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NoOpNormalizer.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NoOpNormalizer.java
Sun Aug 27 00:07:03 2006
@@ -31,8 +31,9 @@
  */
 public class NoOpNormalizer implements Normalizer, Serializable
 {
+    public static final NoOpNormalizer INSTANCE = new NoOpNormalizer();
     static final long serialVersionUID = -7817763636668562489L;
-
+    
 
     /**
      * Creates a do nothing normalizer.



Mime
View raw message