You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2006/08/27 10:14:37 UTC

svn commit: r437332 - /directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java

Author: elecharny
Date: Sun Aug 27 01:14:37 2006
New Revision: 437332

URL: http://svn.apache.org/viewvc?rev=437332&view=rev
Log:
Last modification to make DIRSERVER-714 working : the value is not 
transformed to a String, but to a String or byte[] depending
on the type (it can be binary)

Modified:
    directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java

Modified: directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?rev=437332&r1=437331&r2=437332&view=diff
==============================================================================
--- directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/branches/shared/0.9.5/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Sun Aug 27 01:14:37 2006
@@ -459,23 +459,67 @@
                     switch ( ( ( AttributeValueAssertionFilter ) twixFilter ).getFilterType() )
                     {
                         case LdapConstants.EQUALITY_MATCH_FILTER:
-                            branch = new SimpleNode( ava.getAttributeDesc().toString(), ava.getAssertionValue()
-                                .toString(), AbstractExprNode.EQUALITY );
+                            if ( ava.getAssertionValue() instanceof String )
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(), 
+                                    (String)ava.getAssertionValue(), 
+                                    AbstractExprNode.EQUALITY );
+                            }
+                            else
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(), 
+                                    (byte[])ava.getAssertionValue(), 
+                                    AbstractExprNode.EQUALITY );
+                            }
+                            
                             break;
 
                         case LdapConstants.GREATER_OR_EQUAL_FILTER:
-                            branch = new SimpleNode( ava.getAttributeDesc().toString(), ava.getAssertionValue()
-                                .toString(), AbstractExprNode.GREATEREQ );
+                            if ( ava.getAssertionValue() instanceof String )
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(),
+                                    (String)ava.getAssertionValue(),
+                                    AbstractExprNode.GREATEREQ );
+                            }
+                            else
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(),
+                                    (byte[])ava.getAssertionValue(),
+                                    AbstractExprNode.GREATEREQ );
+                            }
+
                             break;
 
                         case LdapConstants.LESS_OR_EQUAL_FILTER:
-                            branch = new SimpleNode( ava.getAttributeDesc().toString(), ava.getAssertionValue()
-                                .toString(), AbstractExprNode.LESSEQ );
+                            if ( ava.getAssertionValue() instanceof String )
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(), 
+                                    (String)ava.getAssertionValue(), 
+                                    AbstractExprNode.LESSEQ );
+                            }
+                            else
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(), 
+                                    (byte[])ava.getAssertionValue(), 
+                                    AbstractExprNode.LESSEQ );
+                            }
+
                             break;
 
                         case LdapConstants.APPROX_MATCH_FILTER:
-                            branch = new SimpleNode( ava.getAttributeDesc().toString(), ava.getAssertionValue()
-                                .toString(), AbstractExprNode.APPROXIMATE );
+                            if ( ava.getAssertionValue() instanceof String )
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(), 
+                                    (String)ava.getAssertionValue(), 
+                                    AbstractExprNode.APPROXIMATE );
+                            }
+                            else
+                            {
+                                branch = new SimpleNode( ava.getAttributeDesc().toString(), 
+                                    (byte[])ava.getAssertionValue(), 
+                                    AbstractExprNode.APPROXIMATE );
+                            }
+
                             break;
                     }
 
@@ -516,7 +560,6 @@
                     // Transform Extensible Match Filter
                     ExtensibleMatchFilter filter = ( ExtensibleMatchFilter ) twixFilter;
                     String attribute = null;
-                    String value = null;
                     String matchingRule = null;
 
                     if ( filter.getType() != null )
@@ -524,17 +567,28 @@
                         attribute = filter.getType().toString();
                     }
 
-                    if ( filter.getMatchValue() != null )
-                    {
-                        value = filter.getMatchValue().toString();
-                    }
+                    Object value = filter.getMatchValue();
 
                     if ( filter.getMatchingRule() != null )
                     {
                         matchingRule = filter.getMatchingRule().toString();
                     }
 
-                    branch = new ExtensibleNode( attribute, value, matchingRule, filter.isDnAttributes() );
+                    if ( value instanceof String )
+                    {
+                        branch = new ExtensibleNode( attribute, (String)value, matchingRule, filter.isDnAttributes() );
+                    }
+                    else
+                    {
+                        if ( value != null )
+                        {
+                            branch = new ExtensibleNode( attribute, (byte[])value, matchingRule, filter.isDnAttributes() );
+                        }
+                        else
+                        {
+                            branch = new ExtensibleNode( attribute, (byte[])null, matchingRule, filter.isDnAttributes() );
+                        }
+                    }
                 }
 
                 return branch;