directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r234264 [10/11] - in /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src: ./ java/ java/main/ java/main/org/ java/main/org/apache/ java/main/org/apache/asn1new/ java/main/org/apache/asn1new/ldap/ java/main/org/apache/...
Date Sun, 21 Aug 2005 16:54:00 GMT
Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,541 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo;
+
+import org.apache.asn1new.Asn1Object;
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.pojo.filters.Filter;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * A SearchRequest ldapObject. It's a sub-class of Asn1Object, and it implements
+ * the ldapObject class to be seen as a member of the LdapMessage
+ * CHOICE.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchRequest extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The base DN */
+    private LdapDN baseObject;
+
+    /** The scope. It could be baseObject, singleLevel or wholeSubtree. */
+    private int scope;
+
+    /** The deref alias could be neverDerefAliases, derefInSearching, 
+     * derefFindingBaseObj or derefAlways. */
+    private int derefAliases;
+
+    /** The size limit (number of objects returned)*/
+    private int sizeLimit;
+
+    /** The time limit (max time to process the response before returning the result) */
+    private int timeLimit;
+
+    /** An indicator as to whether search results will contain
+     both attribute types and values, or just attribute types.  Setting
+     this field to TRUE causes only attribute types (no values) to be
+     returned.  Setting this field to FALSE causes both attribute types
+     and values to be returned. */
+    private boolean typesOnly;
+
+    /** The filter tree */
+    private Filter filter;
+
+    /** The list of attributes to get */
+    private ArrayList attributes;
+
+    /** The current filter. This is used while decoding a PDU */
+    private transient Filter currentFilter;
+    
+    /** The searchRequest length */
+    private transient int searchRequestLength;
+    
+    /** The attributeDescriptionList length */
+    private transient int attributeDescriptionListLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchRequest object.
+     */
+    public SearchRequest()
+    {
+        super( );
+
+        currentFilter = null;
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the list of attributes
+     *
+     * @return Returns the attributes.
+     */
+    public ArrayList getAttributes()
+    {
+        return attributes;
+    }
+
+    /**
+     * Add an attribute to the attributes list.
+     * 
+     * @param attribute The attribute to add to the list
+     */
+    public void addAttribute( LdapString attribute )
+    {
+        attributes.add( attribute );
+    }
+
+    /**
+     * Initialize the attributes list
+     */
+    public void initAttributes()
+    {
+        attributes = new ArrayList();
+    }
+
+    /**
+     * Get the base object
+     *
+     * @return Returns the baseObject.
+     */
+    public String getBaseObject()
+    {
+        return ( ( baseObject == null ) ? null : baseObject.toString() );
+    }
+
+    /**
+     * Set the base object
+     *
+     * @param baseObject The baseObject to set.
+     */
+    public void setBaseObject( LdapDN baseObject )
+    {
+        this.baseObject = baseObject;
+    }
+
+    /**
+     * Get the derefAliases flag
+     *
+     * @return Returns the derefAliases.
+     */
+    public int getDerefAliases()
+    {
+        return derefAliases;
+    }
+
+    /**
+     * Set the derefAliases flag
+     *
+     * @param derefAliases The derefAliases to set.
+     */
+    public void setDerefAliases( int derefAliases )
+    {
+        this.derefAliases = derefAliases;
+    }
+
+    /**
+     * Get the filter
+     *
+     * @return Returns the filter.
+     */
+    public Filter getFilter()
+    {
+        return filter;
+    }
+
+    /**
+     * Set the filter
+     *
+     * @param filter The filter to set.
+     */
+    public void setFilter( Filter filter )
+    {
+        this.filter = filter;
+    }
+
+    /**
+     * Get the search scope
+     *
+     * @return Returns the scope.
+     */
+    public int getScope()
+    {
+        return scope;
+    }
+
+    /**
+     * Set the search scope
+     *
+     * @param scope The scope to set.
+     */
+    public void setScope( int scope )
+    {
+        this.scope = scope;
+    }
+
+    /**
+     * Get the size limit
+     *
+     * @return Returns the sizeLimit.
+     */
+    public int getSizeLimit()
+    {
+        return sizeLimit;
+    }
+
+    /**
+     * Set the size limit
+     *
+     * @param sizeLimit The sizeLimit to set.
+     */
+    public void setSizeLimit( int sizeLimit )
+    {
+        this.sizeLimit = sizeLimit;
+    }
+
+    /**
+     * Get the time limit
+     *
+     * @return Returns the timeLimit.
+     */
+    public int getTimeLimit()
+    {
+        return timeLimit;
+    }
+
+    /**
+     * Set the time limit
+     *
+     * @param timeLimit The timeLimit to set.
+     */
+    public void setTimeLimit( int timeLimit )
+    {
+        this.timeLimit = timeLimit;
+    }
+
+    /**
+     * Get the typesOnly flag
+     *
+     * @return Returns the typesOnly.
+     */
+    public boolean isTypesOnly()
+    {
+        return typesOnly;
+    }
+
+    /**
+     * Set the typesOnly flag
+     *
+     * @param typesOnly The typesOnly to set.
+     */
+    public void setTypesOnly( boolean typesOnly )
+    {
+        this.typesOnly = typesOnly;
+    }
+
+    /**
+     * Get the current dilter
+     *
+     * @return Returns the currentFilter.
+     */
+    public Filter getCurrentFilter()
+    {
+        return currentFilter;
+    }
+
+    /**
+     * Set the current dilter
+     *
+     * @param currentFilter The currentFilter to set.
+     */
+    public void setCurrentFilter( Filter currentFilter )
+    {
+        this.currentFilter = currentFilter;
+    }
+    
+    /**
+     * Compute the SearchRequest length
+     * 
+     * SearchRequest :
+     * 
+     * 0x63 L1
+     *  |
+     *  +--> 0x04 L2 baseObject
+     *  +--> 0x0A 0x01 scope
+     *  +--> 0x0A 0x01 derefAliases
+     *  +--> 0x02 0x0(1..4) sizeLimit
+     *  +--> 0x02 0x0(1..4) timeLimit
+     *  +--> 0x01 0x01 typesOnly
+     *  +--> filter.computeLength()
+     *  +--> 0x30 L3 (Attribute description list)
+     *        |
+     *        +--> 0x04 L4-1 Attribute description 
+     *        +--> 0x04 L4-2 Attribute description 
+     *        +--> ... 
+     *        +--> 0x04 L4-i Attribute description 
+     *        +--> ... 
+     *        +--> 0x04 L4-n Attribute description 
+     * 
+     */
+    public int computeLength()
+    {
+        searchRequestLength = 0;
+        
+        // The baseObject
+        searchRequestLength += 1 + Length.getNbBytes( baseObject.getLength() ) + baseObject.getLength();
+        
+        // The scope
+        searchRequestLength += 1 + 1 + 1;
+        
+        // The derefAliases
+        searchRequestLength += 1 + 1 + 1;
+        
+        // The sizeLimit
+        searchRequestLength += 1 + 1 + Value.getNbBytes(sizeLimit);
+        
+        // The timeLimit
+        searchRequestLength += 1 + 1 + Value.getNbBytes(timeLimit);
+        
+        // The typesOnly
+        searchRequestLength += 1 + 1 + 1;
+        
+        // The filter
+        searchRequestLength += filter.computeLength();
+        
+        // The attributes description list
+        attributeDescriptionListLength = 0;
+        
+        if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+        {
+            Iterator attributeIterator = attributes.iterator();
+            
+            // Compute the attributes length
+            while ( attributeIterator.hasNext() )
+            {
+                LdapString attribute = (LdapString)attributeIterator.next();
+                
+                // add the attribute length to the attributes length
+                attributeDescriptionListLength += 1 + Length.getNbBytes( attribute.getLength() ) + attribute.getLength();
+            }
+        }
+        
+        searchRequestLength += 1 + Length.getNbBytes( attributeDescriptionListLength ) + attributeDescriptionListLength;
+
+        // Return the result.
+        return 1 + Length.getNbBytes( searchRequestLength ) + searchRequestLength;
+    }
+    
+    /**
+     * Encode the SearchRequest message to a PDU.
+     * 
+     * SearchRequest :
+     * 
+     * 0x63 LL
+     *   0x04 LL baseObject
+     *   0x0A 01 scope
+     *   0x0A 01 derefAliases
+     *   0x02 0N sizeLimit
+     *   0x02 0N timeLimit
+     *   0x01 0x01 typesOnly
+     *   filter.encode()
+     *   0x30 LL attributeDescriptionList
+     *     0x04 LL attributeDescription
+     *     ... 
+     *     0x04 LL attributeDescription
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The SearchRequest Tag
+            buffer.put( LdapConstants.SEARCH_REQUEST_TAG );
+            buffer.put( Length.getBytes( searchRequestLength ) ) ;
+            
+            // The baseObject
+            Value.encode( buffer, baseObject );
+            
+            // The scope
+            Value.encodeEnumerated( buffer, scope );
+
+            // The derefAliases
+            Value.encodeEnumerated( buffer, derefAliases );
+
+            // The sizeLimit
+            Value.encode( buffer, sizeLimit );
+
+            // The timeLimit
+            Value.encode( buffer, timeLimit );
+
+            // The typesOnly
+            Value.encode( buffer, typesOnly );
+
+            // The filter
+            filter.encode( buffer );
+            
+            // The attributeDescriptionList
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            buffer.put( Length.getBytes( attributeDescriptionListLength ) );
+            
+            if ( ( attributes != null ) && ( attributes.size() != 0 ) )
+            {
+                Iterator attributeIterator = attributes.iterator();
+                
+                // encode each attribute
+                while ( attributeIterator.hasNext() )
+                {
+                    LdapString attribute = (LdapString)attributeIterator.next();
+                    
+                    Value.encode( buffer, attribute );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        return buffer;
+    }
+
+    /**
+     * 
+     * @return A string that represent the Filter
+     */
+    private String buildFilter()
+    {
+        if (filter == null)
+        {
+            return "";
+        }
+        
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append("(");
+
+        sb.append( filter.toString() );
+        
+        sb.append(")");
+        
+        return sb.toString();
+    }
+    
+    /**
+     * Return a string the represent a SearchRequest
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append( "    Search Request\n" );
+        sb.append( "        Base Object : '" ).append( baseObject ).append( "'\n" );
+        sb.append( "        Scope : " );
+        
+        switch (scope)
+        {
+        	case LdapConstants.SCOPE_BASE_OBJECT : 
+        	    sb.append("base object");
+        	    break;
+        	    
+        	case LdapConstants.SCOPE_SINGLE_LEVEL :
+        		sb.append("single level");
+    	    	break;
+    	    	
+        	case LdapConstants.SCOPE_WHOLE_SUBTREE :
+    	    	sb.append("whole subtree");
+    	    	break;
+        }
+
+        sb.append( "\n" );
+        
+        sb.append( "        Deref Aliases : " );
+        
+        switch (derefAliases)
+        {
+    		case LdapConstants.NEVER_DEREF_ALIASES :
+    		    sb.append("never Deref Aliases");
+	    		break;
+
+        	case LdapConstants.DEREF_IN_SEARCHING :
+    	    	sb.append("deref In Searching");
+    	    	break;
+
+        	case LdapConstants.DEREF_FINDING_BASE_OBJ :
+        		sb.append("deref Finding Base Obj");
+    	    	break;
+    	    	
+        	case LdapConstants.DEREF_ALWAYS : 
+        	    sb.append("deref Always");
+        	    break;
+        }
+
+        sb.append( "\n" );
+        
+        sb.append( "        Size Limit : " );
+        
+        if ( sizeLimit == 0 ) 
+        {
+            sb.append( "no limit" );
+        }
+        else
+        {
+            sb.append( sizeLimit );
+        }
+        
+        sb.append( "\n" );
+        
+        sb.append( "        Time Limit : " );
+        
+        if ( timeLimit == 0 ) 
+        {
+            sb.append( "no limit" );
+        }
+        else
+        {
+            sb.append( timeLimit );
+        }
+        
+        sb.append( "\n" );
+        
+        sb.append( "        Types Only : " ).append( typesOnly ).append( "\n" );
+        sb.append( "        Filter : '" ).append( buildFilter() ).append( "'\n" );
+        
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultDone.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultDone.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultDone.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultDone.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,109 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * A SearchResultDone Message. Its syntax is :
+ *   SearchResultDone ::= [APPLICATION 5] LDAPResult
+ * 
+ * It's a Response, so it inherites from LdapResponse.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResultDone extends LdapResponse
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchResultDone object.
+     */
+    public SearchResultDone()
+    {
+        super( );
+    }
+
+    /**
+     * Compute the SearchResultDone length
+     * 
+     * SearchResultDone :
+     * 
+     * 0x65 L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(SearchResultDone) = Length(0x65) + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        int ldapResponseLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( ldapResponseLength ) + ldapResponseLength;
+    }
+    
+    /**
+     * Encode the SearchResultDone message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer )  throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+        
+        try
+        {
+            // The tag
+            buffer.put( LdapConstants.SEARCH_RESULT_DONE_TAG );
+            buffer.put( Length.getBytes( getLdapResponseLength() ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        // The ldapResult
+        return super.encode( buffer);
+    }
+    
+    /**
+     * Get a String representation of a SearchResultDone
+     *
+     * @return A SearchResultDone String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Search Result Done\n" );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,454 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo;
+
+import org.apache.asn1new.Asn1Object;
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+
+
+/**
+ * A SearchResultEntry Message. Its syntax is :
+ *   SearchResultEntry ::= [APPLICATION 4] SEQUENCE {
+ *       objectName      LDAPDN,
+ *       attributes      PartialAttributeList }
+ * 
+ *   PartialAttributeList ::= SEQUENCE OF SEQUENCE {
+ *       type    AttributeDescription,
+ *       vals    SET OF AttributeValue }
+ * 
+ *   AttributeDescription ::= LDAPString
+ * 
+ *   AttributeValue ::= OCTET STRING
+ * 
+ * It contains an entry, with all its attributes, and all the attributes
+ * values. If a search request is submited, all the results are sent one
+ * by one, followed by a searchResultDone message.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResultEntry extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The DN of the returned entry */
+    private LdapDN objectName;
+
+    /** The attributes list. It contains javax.naming.directory.Attribute */
+    private ArrayList partialAttributeList;
+
+    /** The attributes list expected length */
+    //private transient int partialAttributesListExpectedLength;
+
+    /** The current attribute being decoded */
+    private transient Attribute currentAttributeValue;
+    
+    /** The search result entry length */
+    private transient int searchResultEntryLength;
+    
+    /** The partial attributes length */
+    private transient int attributesLength;
+    
+    /** The list of all attributes length */
+    private transient List attributeLength;
+    
+    /** The list of all vals length */
+    private transient List valsLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchResultEntry object.
+     */
+    public SearchResultEntry()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the entry DN
+     *
+     * @return Returns the objectName.
+     */
+    public String getObjectName()
+    {
+        return ( ( objectName == null ) ? null : objectName.toString() );
+    }
+
+    /**
+     * Set the entry DN
+     *
+     * @param objectName The objectName to set.
+     */
+    public void setObjectName( LdapDN objectName )
+    {
+        this.objectName = objectName;
+    }
+
+    /**
+     * Get the entry's attributes
+     *
+     * @return Returns the partialAttributeList.
+     */
+    public ArrayList getPartialAttributeList()
+    {
+        return partialAttributeList;
+    }
+
+    /**
+     * Initialize the partial Attribute list if needed, otherwise add the current
+     * Attribute Value to the list.
+     *
+     */
+    public void addPartialAttributeList()
+    {
+
+        if ( currentAttributeValue == null )
+        {
+            partialAttributeList = new ArrayList();
+        }
+    }
+
+    /**
+     * Get the partial attributes list length
+     *
+     * @return Returns the partialAttributesListExpectedLength.
+     */
+    //public int getPartialAttributesListExpectedLength()
+    //{
+    //    return partialAttributesListExpectedLength;
+    //}
+
+    /**
+     * Set the partial attributes list length
+     *
+     * @param partialAttributesListExpectedLength The partialAttributesListExpectedLength to set.
+     */
+    //public void setPartialAttributesListExpectedLength( int partialAttributesListExpectedLength )
+    //{
+    //    this.partialAttributesListExpectedLength = partialAttributesListExpectedLength;
+    //}
+
+    /**
+     * Create a new attributeValue
+     * @param type The attribute's name
+     */
+    public void addAttributeValues( LdapString type )
+    {
+        currentAttributeValue = new BasicAttribute( type.toString().toLowerCase() );
+
+        partialAttributeList.add( currentAttributeValue );
+    }
+
+    /**
+     * Add a new value to the current attribute
+     * @param value
+     */
+    public void addAttributeValue( OctetString value )
+    {
+        currentAttributeValue.add( value );
+    }
+
+    /**
+     * Compute the SearchResultEntry length
+     * 
+     * SearchResultEntry :
+     * 
+     * 0x64 L1
+     *  |
+     *  +--> 0x04 L2 objectName
+     *  +--> 0x30 L3 (attributes)
+     *        |
+     *        +--> 0x30 L4-1 (partial attributes list)
+     *        |     |
+     *        |     +--> 0x04 L5-1 type
+     *        |     +--> 0x31 L6-1 (values)
+     *        |           |
+     *        |           +--> 0x04 L7-1-1 value
+     *        |           +--> ...
+     *        |           +--> 0x04 L7-1-n value
+     *        |
+     *        +--> 0x30 L4-2 (partial attributes list)
+     *        |     |
+     *        |     +--> 0x04 L5-2 type
+     *        |     +--> 0x31 L6-2 (values)
+     *        |           |
+     *        |           +--> 0x04 L7-2-1 value
+     *        |           +--> ...
+     *        |           +--> 0x04 L7-2-n value
+     *        |
+     *        +--> ...
+     *        |
+     *        +--> 0x30 L4-m (partial attributes list)
+     *              |
+     *              +--> 0x04 L5-m type
+     *              +--> 0x31 L6-m (values)
+     *                    |
+     *                    +--> 0x04 L7-m-1 value
+     *                    +--> ...
+     *                    +--> 0x04 L7-m-n value
+     * 
+     */
+    public int computeLength()
+    {
+        // The entry
+        searchResultEntryLength = 1 + Length.getNbBytes( objectName.getLength() ) + objectName.getLength();
+        
+        // The attributes sequence
+        attributesLength = 0;
+        
+        if ( ( partialAttributeList != null ) && ( partialAttributeList.size() != 0 ) )
+        {
+            Iterator attributeIterator = partialAttributeList.iterator();
+            attributeLength = new LinkedList();
+            valsLength = new LinkedList();
+            
+            // Compute the attributes length
+            while ( attributeIterator.hasNext() )
+            {
+                Attribute attribute = (Attribute)attributeIterator.next();
+                int localAttributeLength = 0;
+                int localValuesLength = 0;
+                
+                // Get the type length
+                int idLength = attribute.getID().getBytes().length;
+                localAttributeLength = 1 + Length.getNbBytes( idLength ) + idLength;
+                
+                // The values
+                try
+                {
+	                NamingEnumeration values = attribute.getAll();
+	                
+	                if ( values.hasMoreElements() )
+	                {
+                        localValuesLength = 0;
+	                    
+		                while ( values.hasMoreElements() )
+		                {
+		                    OctetString value = (OctetString)values.next();
+		                    
+                            localValuesLength += 1 + Length.getNbBytes( value.getLength() ) + value.getLength();
+		                }
+
+                        localAttributeLength += 1 + Length.getNbBytes( localValuesLength ) + localValuesLength; 
+	                }
+	                
+                }
+                catch (NamingException ne)
+                {
+                    return 0;
+                }
+                
+                // add the attribute length to the attributes length
+                attributesLength += 1 + Length.getNbBytes( localAttributeLength ) + localAttributeLength;
+                
+                attributeLength.add( new Integer( localAttributeLength ) );
+                valsLength.add( new Integer( localValuesLength ) );
+            }
+        }
+        
+        searchResultEntryLength += 1 + Length.getNbBytes( attributesLength ) + attributesLength;
+
+        // Return the result.
+        return 1 + Length.getNbBytes( searchResultEntryLength ) + searchResultEntryLength;
+    }
+    
+    /**
+     * Encode the SearchResultEntry message to a PDU.
+     * 
+     * SearchResultEntry :
+     * 
+     * 0x64 LL
+     *   0x04 LL objectName
+     *   0x30 LL attributes
+     *     0x30 LL partialAttributeList
+     *       0x04 LL type
+     *       0x31 LL vals
+     *         0x04 LL attributeValue
+     *         ... 
+     *         0x04 LL attributeValue
+     *     ... 
+     *     0x30 LL partialAttributeList
+     *       0x04 LL type
+     *       0x31 LL vals
+     *         0x04 LL attributeValue
+     *         ... 
+     *         0x04 LL attributeValue 
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The SearchResultEntry Tag
+            buffer.put( LdapConstants.SEARCH_RESULT_ENTRY_TAG );
+            buffer.put( Length.getBytes( searchResultEntryLength ) ) ;
+            
+            // The objectName
+            Value.encode( buffer, objectName );
+            
+            // The attributes sequence
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            buffer.put( Length.getBytes( attributesLength ) ) ;
+
+            // The partial attribute list
+            if ( ( partialAttributeList != null ) && ( partialAttributeList.size() != 0 ) )
+            {
+                Iterator attributeIterator = partialAttributeList.iterator();
+                int attributeNumber = 0;
+                
+                // Compute the attributes length
+                while ( attributeIterator.hasNext() )
+                {
+                    Attribute attribute = (Attribute)attributeIterator.next();
+                    
+                    // The partial attribute list sequence
+                    buffer.put( UniversalTag.SEQUENCE_TAG );
+                    int localAttributeLength = ( (Integer)attributeLength.get( attributeNumber ) ).intValue();
+                    buffer.put( Length.getBytes( localAttributeLength ) );
+
+                    // The attribute type
+                    Value.encode( buffer, attribute.getID() );
+                    
+                    // The values
+                    buffer.put( UniversalTag.SET_TAG );
+                    int localValuesLength = ( (Integer)valsLength.get( attributeNumber ) ).intValue();
+                    buffer.put( Length.getBytes( localValuesLength ) );
+                    
+                    try
+                    {
+                        NamingEnumeration values = attribute.getAll();
+                        
+                        if ( values.hasMoreElements() )
+                        {
+                            while ( values.hasMoreElements() )
+                            {
+                                OctetString value = (OctetString)values.next();
+                                
+                                Value.encode( buffer, value );
+                            }
+                        }
+                        
+                    }
+                    catch (NamingException ne)
+                    {
+                        throw new EncoderException("Cannot enumerate the values");
+                    }
+                    
+                    // Go to the next attribute number;
+                    attributeNumber++;
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        return buffer;
+    }
+
+    /**
+     * Returns the Search Result Entry string
+     *
+     * @return The Search Result Entry string 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Search Result Entry\n" );
+        sb.append( "        Object Name : '" ).append( objectName.toString() ).append( "'\n" );
+        sb.append( "        Attributes\n" );
+
+        if ( ( partialAttributeList == null ) || ( partialAttributeList.size() == 0 ) )
+        {
+            sb.append( "            No attributes\n" );
+        }
+        else
+        {
+
+            Iterator attributesIter = partialAttributeList.iterator();
+
+            while ( attributesIter.hasNext() )
+            {
+
+                Attribute attribute = ( Attribute ) attributesIter.next();
+
+                sb.append( "            Name : '" ).append( attribute.getID() ).append( "'\n" );
+
+                try
+                {
+
+                    NamingEnumeration values = attribute.getAll();
+
+                    if ( values.hasMoreElements() )
+                    {
+                        sb.append( "            Values\n" );
+
+                        while ( values.hasMore() )
+                        {
+
+                            OctetString value = ( OctetString ) values.next();
+
+                            sb.append( "                '" ).append( value.toString() ).append(
+                                "'\n" );
+                        }
+                    }
+                    else
+                    {
+                        sb.append( "            No Values\n" );
+                    }
+                }
+                catch ( NamingException ne )
+                {
+                    sb.append( "            Error while reading attribute.\n " );
+                }
+            }
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultReference.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultReference.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultReference.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultReference.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,189 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo;
+
+import org.apache.asn1new.Asn1Object;
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapURL;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+/**
+ * A SearchResultReference Message. Its syntax is :
+ *   SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResultReference extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The set of LdapURLs */
+    private ArrayList searchResultReferences;
+    
+    /** The search result reference length */
+    private transient int searchResultReferenceLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchResultEntry object.
+     */
+    public SearchResultReference()
+    {
+        super( );
+        searchResultReferences = new ArrayList();
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Add a new reference to the list.
+     * @param searchResultReference The search result reference
+    */
+    public void addSearchResultReference( LdapURL searchResultReference )
+    {
+        searchResultReferences.add( searchResultReference );
+    }
+
+    /**
+     * Get the list of references
+     * @return An ArrayList of SearchResultReferences
+     */
+    public ArrayList getSearchResultReferences()
+    {
+        return searchResultReferences;
+    }
+
+    /**
+     * Compute the SearchResultReference length
+     * 
+     * SearchResultReference :
+     * 
+     * 0x73 L1
+     *  |
+     *  +--> 0x04 L2 reference
+     *  +--> 0x04 L3 reference
+     *  +--> ...
+     *  +--> 0x04 Li reference
+     *  +--> ...
+     *  +--> 0x04 Ln reference
+     * 
+     * L1 = n*Length(0x04) + sum(Length(Li)) + sum(Length(reference[i]))
+     * 
+     * Length(SearchResultReference) = Length(0x73 + Length(L1) + L1
+     */
+    public int computeLength()
+    {
+        searchResultReferenceLength = 0;
+        
+        Iterator referencesIterator = searchResultReferences.iterator();
+        
+        // We may have more than one reference.
+        while (referencesIterator.hasNext())
+        {
+            int ldapUrlLength = ((LdapURL)referencesIterator.next()).getLength();
+            searchResultReferenceLength += 1 + Length.getNbBytes( ldapUrlLength ) + ldapUrlLength;
+        }
+        
+        return 1 + Length.getNbBytes( searchResultReferenceLength ) + searchResultReferenceLength;
+    }
+
+    /**
+     * Encode the SearchResultReference message to a PDU.
+     * 
+     * SearchResultReference :
+     * 
+     * 0x73 LL
+     *   0x04 LL reference
+     *   [0x04 LL reference]*
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The SearchResultReference Tag
+            buffer.put( LdapConstants.SEARCH_RESULT_REFERENCE_TAG );
+            buffer.put( Length.getBytes( searchResultReferenceLength ) ) ;
+
+            // The references. We must at least have one reference
+            Iterator referencesIterator = searchResultReferences.iterator();
+            
+            // We may have more than one reference.
+            while (referencesIterator.hasNext())
+            {
+                LdapURL reference = ((LdapURL)referencesIterator.next());
+                
+                // Encode the reference
+                Value.encode( buffer, reference );
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        return buffer;
+    }
+
+    /**
+     * Returns the Search Result Reference string
+     *
+     * @return The Search Result Reference string 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    Search Result Reference\n" );
+
+        if ( ( searchResultReferences == null ) || ( searchResultReferences.size() == 0 ) )
+        {
+            sb.append( "        No Reference\n" );
+        }
+        else
+        {
+            sb.append( "        References\n" );
+
+            Iterator referencesIterator = searchResultReferences.iterator();
+
+            while ( referencesIterator.hasNext() )
+            {
+                sb.append( "            '" )
+                  .append( ( ( LdapURL ) referencesIterator.next() ).toString() ).append( "'\n" );
+            }
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,120 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.Asn1Object;
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+
+/**
+ * A ldapObject which stores the Simple authentication for a BindRequest.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SimpleAuthentication extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The simple authentication password */
+    private OctetString simple;
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the simple password
+     *
+     * @return The password
+     */
+    public OctetString getSimple()
+    {
+        return simple;
+    }
+
+    /**
+     * Set the simple password
+     *
+     * @param simple The simple password
+     */
+    public void setSimple( OctetString simple )
+    {
+        this.simple = simple;
+    }
+
+    /**
+     * Compute the Simple authentication length
+     * 
+     * Simple authentication :
+     * 
+     * 0x80 L1 simple
+     * 
+     * L1 = Length(simple)
+     * 
+     * Length(Simple authentication) = Length(0x80) + Length(L1) + Length(simple)
+     */
+    public int computeLength()
+    {
+        return 1 + Length.getNbBytes( simple.getLength() ) + simple.getLength();
+    }
+    
+    /**
+     * Encode the simple authentication to a PDU.
+     * 
+     * SimpleAuthentication :
+     * 
+     * 0x80 LL simple
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( "Cannot put a PDU in a null buffer !" );
+        }
+
+        try 
+        {
+            // The simpleAuthentication Tag
+            buffer.put( (byte)LdapConstants.BIND_REQUEST_SIMPLE_TAG );
+            buffer.put( Length.getBytes( simple.getLength() ) ) ;
+            buffer.put( simple.getValue() ) ;
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+
+        return buffer;
+    }
+
+    /**
+     * Return the simple authentication as a string
+     *
+     * @return The simple authentication string.
+     */
+    public String toString()
+    {
+        return ( ( simple == null ) ? "null" : simple.toString() );
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/UnBindRequest.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/UnBindRequest.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/UnBindRequest.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/UnBindRequest.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,105 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.Asn1Object;
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * A UnBindRequest ldapObject. Its syntax is :
+ * 	UnbindRequest ::= [APPLICATION 2] NULL
+ * 
+ * This ldapObject is empty.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class UnBindRequest extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new BindRequest object.
+     */
+    public UnBindRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+    /**
+     * Compute the UnBindRequest length
+     * 
+     * UnBindRequest :
+     * 
+     * 0x42 00
+     */
+    public int computeLength()
+    {
+        return 2; // Always 2
+    }
+    
+    /**
+     * Encode the UnbindRequest message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer )  throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+        
+        try 
+        {
+            // The tag
+            buffer.put(LdapConstants.UNBIND_REQUEST_TAG);
+            
+            // The length is always null.
+            buffer.put( (byte)0 );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        return buffer;
+    }
+
+    /**
+     * Get a String representation of a UnBindRequest
+     *
+     * @return A UnBindRequest String 
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( "    UnBind Request\n" );
+        sb.append( super.toString() );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AndFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AndFilter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AndFilter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AndFilter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,120 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * And Filter Object to store the And filter.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AndFilter extends ConnectorFilter
+{
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * The constructor. We wont initialize the ArrayList as they may not be used. 
+     */
+    public AndFilter()
+    {
+        super();
+    }
+    
+    /**
+     * Get the AndFilter.
+     *
+     * @return Returns the andFilter.
+     */
+    public ArrayList getAndFilter()
+    {
+        return filterSet;
+    }
+    
+    /**
+     * Compute the AndFilter length
+     * 
+     * AndFilter :
+     * 
+     * 0xA0 L1 super.computeLength()
+     * 
+     * Length(AndFilter) = Length(0xA0) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        filtersLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+    }
+    
+    /**
+     * Encode the AndFilter message to a PDU.
+     * 
+     * AndFilter :
+     * 
+     * 0xA0 LL 
+     * filter.encode()
+     * ...
+     * filter.encode()
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The AndFilter Tag
+            buffer.put( (byte)LdapConstants.AND_FILTER_TAG );
+            buffer.put( Length.getBytes( filtersLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        super.encode( buffer );
+
+        return buffer;
+    }
+
+    /**
+     * Return a string compliant with RFC 2254 representing an AND filter
+     *
+     * @return The AND filter string
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append('&').append(super.toString());
+        
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,206 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.pojo.AttributeValueAssertion;
+
+
+/**
+ * Object to store the filter. A filter is seen as a tree with a root.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AttributeValueAssertionFilter extends Filter
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The assertion. */
+    private AttributeValueAssertion assertion;
+
+    /** The filter type */
+    private int filterType;
+    
+    /** The attributeValueAssertion length */
+    private transient int avaLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * The constructor. 
+     * @param filterType DOCUMENT ME!
+    */
+    public AttributeValueAssertionFilter(  int filterType )
+    {
+        this.filterType = filterType;
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the assertion
+     *
+     * @return Returns the assertion.
+     */
+    public AttributeValueAssertion getAssertion()
+    {
+        return assertion;
+    }
+
+    /**
+     * Set the assertion
+     *
+     * @param assertion The assertion to set.
+     */
+    public void setAssertion( AttributeValueAssertion assertion )
+    {
+        this.assertion = assertion;
+    }
+
+    /**
+     * Get the filter type
+     *
+     * @return Returns the filterType.
+     */
+    public int getFilterType()
+    {
+        return filterType;
+    }
+
+    /**
+     * Set the filter type
+     *
+     * @param filterType The filterType to set.
+     */
+    public void setFilterType( int filterType )
+    {
+        this.filterType = filterType;
+    }
+
+    /**
+     * Compute the AttributeValueFilter length
+     * 
+     * AttributeValueFilter :
+     * 
+     * 0xA(3, 5, 6, 8) L1
+     *  |
+     *  +--> 0x04 L2 attributeDesc
+     *  +--> 0x04 L3 assertionValue
+     *  
+     * 
+     * L2 = Length(attributeDesc)
+     * L3 = Length(assertionValue)
+     * L1 = 1 + Length(L2) + L2 
+     *      + 1 + Length(L3) + L3
+     * 
+     * Length(AttributeValueFilter) = Length(0xA?) + Length(L1)
+     *                                + 1 + Length(L2) + L2 
+     *                                + 1 + Length(L3) + L3 
+     * 
+     */
+    public int computeLength()
+    {
+        avaLength = 0;
+        int attributeDescLength = assertion.getAttributeDesc().length();
+        
+        avaLength = 1 + Length.getNbBytes( attributeDescLength ) + attributeDescLength;
+        
+        int assertionValueLength = assertion.getAssertionValue().getLength();
+        
+        avaLength += 1 + Length.getNbBytes( assertionValueLength ) + assertionValueLength;
+        
+        return 1 + Length.getNbBytes( avaLength ) + avaLength;
+    }
+    
+    /**
+     * Encode the AttributeValueAssertion Filters to a PDU. The 
+     * following filters are to be encoded :
+     *  - equality match 
+     *  - greater or equal
+     *  - less or equal
+     *  - approx match 
+     * 
+     * AttributeValueAssertion filters :
+     * 
+     * 0xA[3, 5, 6, 8] LL 
+     * 0x04 LL attributeDesc
+     * 0x04 LL assertionValue
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The AttributeValueAssertion Tag
+            switch (filterType)
+            {
+                case LdapConstants.EQUALITY_MATCH_FILTER :
+                    buffer.put( (byte)LdapConstants.EQUALITY_MATCH_FILTER_TAG );
+                    break;
+                    
+                case LdapConstants.LESS_OR_EQUAL_FILTER :
+                    buffer.put( (byte)LdapConstants.LESS_OR_EQUAL_FILTER_TAG );
+                    break;
+                    
+                case LdapConstants.GREATER_OR_EQUAL_FILTER :
+                    buffer.put( (byte)LdapConstants.GREATER_OR_EQUAL_FILTER_TAG );
+                    break;
+                    
+                case LdapConstants.APPROX_MATCH_FILTER :
+                    buffer.put( (byte)LdapConstants.APPROX_MATCH_FILTER_TAG );
+                    break;
+            }
+            
+            buffer.put( Length.getBytes( avaLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        // The attribute desc
+        Value.encode( buffer, assertion.getAttributeDesc() );
+
+        // The assertion desc
+        Value.encode( buffer, assertion.getAssertionValue() );
+            
+        return buffer;
+    }
+
+    /**
+     * Return a string compliant with RFC 2254 representing an item filter
+     *
+     * @return The item filter string
+     */
+    public String toString()
+    {
+        return assertion.toStringRFC2254( filterType );
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ConnectorFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ConnectorFilter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ConnectorFilter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ConnectorFilter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,166 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import org.apache.asn1new.DecoderException;
+import org.apache.asn1new.EncoderException;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+/**
+ * This Filter abstract class is used to store a set of filters used by OR/AND/NOT
+ * filters. 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class ConnectorFilter extends Filter
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The set of filters used by And/Or filters */
+    protected ArrayList filterSet;
+    
+    /** The filters length */
+    protected transient int filtersLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * The constructor. We wont initialize the ArrayList as it may not be used. 
+     */
+    public ConnectorFilter()
+    {
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Add a new Filter to the list.
+     * @param filter The filter to add
+     */
+    public void addFilter( Filter filter ) throws DecoderException
+    {
+
+        if ( this.filterSet == null )
+        {
+            this.filterSet = new ArrayList();
+        }
+
+        this.filterSet.add( filter );
+    }
+
+    /**
+     * Get the list of filters stored in the composite filter
+     *
+     * @return And array of filters
+     */
+    public ArrayList getFilterSet()
+    {
+        return filterSet;
+    }
+
+    /**
+     * Compute the ConnectorFilter length
+     * 
+     * Length(ConnectorFilter) = sum(filterSet.computeLength())
+     * 
+     */
+    public int computeLength()
+    {
+        int connectorFilterLength = 0;
+        
+        if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+        {
+            Iterator filterIterator = filterSet.iterator();
+            
+            while ( filterIterator.hasNext() )
+            {
+                Filter filter = (Filter)filterIterator.next();
+                
+                connectorFilterLength += filter.computeLength();
+            }
+        }
+        
+        return connectorFilterLength;
+    }
+
+    /**
+     * Encode the ConnectorFilter message to a PDU.
+     * 
+     * ConnectorFilter :
+     * 
+     * filter.encode()
+     * ...
+     * filter.encode()
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        // encode each filter
+        if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+        {
+            Iterator filterIterator = filterSet.iterator();
+            
+            while ( filterIterator.hasNext() )
+            {
+                Filter filter = (Filter)filterIterator.next();
+                
+                filter.encode( buffer );
+            }
+        }
+            
+        return buffer;
+    }
+
+    /**
+     * Return a string compliant with RFC 2254 representing a composite
+     * filter, one of AND, OR and NOT
+     *
+     * @return The composite filter string
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        if ( ( filterSet != null ) && ( filterSet.size() != 0 ) )
+        {
+
+            Iterator filterIterator = filterSet.iterator();
+
+            while ( filterIterator.hasNext() )
+            {
+
+                Filter filter = ( Filter ) filterIterator.next();
+
+                sb.append( '(' ).append( filter.toString() ).append( ')' );
+            }
+        }
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,336 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+
+
+/**
+ * The search request filter Matching Rule assertion
+ * 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ExtensibleMatchFilter extends Filter
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The expected lenth of the Matching Rule Assertion */
+    private transient int expectedMatchingRuleLength;
+
+    /** Matching rule  */
+    private LdapString matchingRule;
+
+    /** Matching rule type */
+    private LdapString type;
+
+    /** Matching rule value */
+    private OctetString matchValue;
+
+    /** The dnAttributes flag */
+    private boolean dnAttributes;
+    
+    /** The extensible match length */
+    private transient int extensibleMatchLength;
+    
+    /** The matching Rule Assertion Length */
+    private transient int matchingRuleAssertionLength;
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ExtensibleMatchFilter object.
+     * The dnAttributes flag defaults to false.
+     */
+    public ExtensibleMatchFilter()
+    {
+        dnAttributes = false;
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the dnAttributes flag
+     *
+     * @return Returns the dnAttributes.
+     */
+    public boolean isDnAttributes()
+    {
+        return dnAttributes;
+    }
+
+    /**
+     * Set the dnAttributes flag
+     *
+     * @param dnAttributes The dnAttributes to set.
+     */
+    public void setDnAttributes( boolean dnAttributes )
+    {
+        this.dnAttributes = dnAttributes;
+    }
+
+    /**
+     * Get the matchingRule
+     *
+     * @return Returns the matchingRule.
+     */
+    public LdapString getMatchingRule()
+    {
+        return matchingRule;
+    }
+
+    /**
+     * Set the matchingRule
+     *
+     * @param matchingRule The matchingRule to set.
+     */
+    public void setMatchingRule( LdapString matchingRule )
+    {
+        this.matchingRule = matchingRule;
+    }
+
+    /**
+     * Get the matchValue
+     *
+     * @return Returns the matchValue.
+     */
+    public OctetString getMatchValue()
+    {
+        return matchValue;
+    }
+
+    /**
+     * Set the matchValue
+     *
+     * @param matchValue The matchValue to set.
+     */
+    public void setMatchValue( OctetString matchValue )
+    {
+        this.matchValue = matchValue;
+    }
+
+    /**
+     * Get the type
+     *
+     * @return Returns the type.
+     */
+    public LdapString getType()
+    {
+        return type;
+    }
+
+    /**
+     * Set the type
+     *
+     * @param type The type to set.
+     */
+    public void setType( LdapString type )
+    {
+        this.type = type;
+    }
+
+    /**
+     * get the expectedMatchingRuleLength
+     *
+     * @return Returns the expectedMatchingRuleLength.
+     */
+    public int getExpectedMatchingRuleLength()
+    {
+        return expectedMatchingRuleLength;
+    }
+
+    /**
+     * Set the expectedMatchingRuleLength
+     *
+     * @param expectedMatchingRuleLength The expectedMatchingRuleLength to set.
+     */
+    public void setExpectedMatchingRuleLength( int expectedMatchingRuleLength )
+    {
+        this.expectedMatchingRuleLength = expectedMatchingRuleLength;
+    }
+
+    /**
+     * Compute the ExtensibleMatchFilter length
+     * 
+     * ExtensibleMatchFilter :
+     * 
+     * 0xA9 L1
+     *  |
+     *  +--> 0x30 L2
+     *        |
+     *       [+--> 0x81 L3 matchingRule]
+     *       [+--> 0x82 L4 type]
+     *       [+--> 0x83 L5 matchValue]
+     *       [+--> 0x01 0x01 dnAttributes]
+     *  
+     */
+    public int computeLength()
+    {
+        if ( matchingRule != null )
+        {
+            matchingRuleAssertionLength = 1 + Length.getNbBytes( matchingRule.getLength() ) + matchingRule.getLength(); 
+        }
+        
+        if ( type != null )
+        {
+            matchingRuleAssertionLength += 1 + Length.getNbBytes( type.getLength() ) + type.getLength();
+        }
+        
+        if ( matchValue != null )
+        {
+            matchingRuleAssertionLength += 1 + Length.getNbBytes( matchValue.getLength() ) + matchValue.getLength(); 
+        }
+        
+        if ( dnAttributes == true )
+        {
+            matchingRuleAssertionLength += 1 + 1 + 1;
+        }
+
+        extensibleMatchLength = 1 + Length.getNbBytes( matchingRuleAssertionLength ) + matchingRuleAssertionLength;
+        
+        return 1 + Length.getNbBytes( extensibleMatchLength ) + extensibleMatchLength;
+    }
+    
+    /**
+     * Encode the ExtensibleMatch Filters to a PDU. 
+     * 
+     * ExtensibleMatch filter :
+     * 
+     * 0xA9 LL 
+     * 0x30 LL matchingRuleAssertion
+     *  |     0x81 LL matchingRule
+     *  |    / |   0x82 LL Type  
+     *  |   /  |  /0x83 LL matchValue
+     *  +--+   +-+
+     *  |   \     \
+     *  |    \     0x83 LL MatchValue
+     *  |     0x82 LL type
+     *  |     0x83 LL matchValue
+     *  +--[0x84 0x01 dnAttributes]
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The ExtensibleMatch Tag
+            buffer.put( (byte)LdapConstants.EXTENSIBLE_MATCH_FILTER_TAG );
+            buffer.put( Length.getBytes( extensibleMatchLength ) );
+
+            // The MatchingRuleAssertion sequence tag
+            buffer.put( UniversalTag.SEQUENCE_TAG );
+            buffer.put( Length.getBytes( matchingRuleAssertionLength ) );
+
+            if ( ( matchingRule == null ) && ( type == null ) ) 
+            {
+                throw new EncoderException("Cannot have a null matching rule and a null type");
+            }
+            
+            // The matching rule
+            if ( matchingRule != null ) 
+            {
+                buffer.put( (byte)LdapConstants.SEARCH_MATCHING_RULE_TAG );
+                buffer.put( Length.getBytes( matchingRule.getLength() ) );
+                buffer.put( matchingRule.getData() );                
+            }
+            
+            // The type
+            if ( type != null ) 
+            {
+                buffer.put( (byte)LdapConstants.SEARCH_TYPE_TAG );
+                buffer.put( Length.getBytes( type.getLength() ) );
+                buffer.put( type.getData() );                
+            }
+            
+            // The match value
+            if ( matchValue != null ) 
+            {
+                buffer.put( (byte)LdapConstants.SEARCH_MATCH_VALUE_TAG );
+                buffer.put( Length.getBytes( matchValue.getLength() ) );
+                buffer.put( matchValue.getValue() );                
+            }
+
+            // The dnAttributes flag, if true only
+            if ( dnAttributes == true )
+            {
+                buffer.put( (byte)LdapConstants.DN_ATTRIBUTES_FILTER_TAG );
+                buffer.put( (byte)1 );
+                buffer.put( Value.TRUE_VALUE );                
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        return buffer;
+    }
+
+    /**
+     * Return a String representing an extended filter as of RFC 2254
+     *
+     * @return An Extened Filter String
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        if ( type != null )
+        {
+            sb.append( type.toString() );
+        }
+
+        if ( dnAttributes == true )
+        {
+            sb.append( ":dn" );
+        }
+
+        if ( matchingRule == null )
+        {
+
+            if ( type == null )
+            {
+                return "Extended Filter wrong syntax";
+            }
+        }
+        else
+        {
+            sb.append( ':' ).append( matchingRule.toString() );
+        }
+
+        sb.append( ":=" ).append( matchValue.toString() );
+
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/Filter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/Filter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/Filter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/Filter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,41 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import org.apache.asn1new.Asn1Object;
+
+
+/**
+ * An abstract Asn1Object used to store the filter. A filter is seen as a tree with a root.
+ * This class does nothing, it's just the root of all the different filters.
+ * 
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class Filter extends Asn1Object
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * The constructor.  
+     */
+    public Filter()
+    {
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/NotFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/NotFilter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/NotFilter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/NotFilter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,147 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1new.DecoderException;
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+/**
+ * Not Filter Object to store the Not filter.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class NotFilter extends ConnectorFilter
+{
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * The constructor. 
+     */
+    public NotFilter()
+    {
+    }
+    
+    /**
+     * Subclass the addFilterMethod, as this is specific for a NotFilter
+     * (we cannot have more than one elements).
+     * @param Filter The Filter to add
+     */
+    public void addFilter( Filter filter ) throws DecoderException
+    {
+        if ( filterSet != null )
+        {
+            throw new DecoderException("Cannot have more than one Filter within a Not Filter");
+        }
+        
+        super.addFilter( filter );
+    }
+
+    /**
+     * Get the NotFilter
+     *
+     * @return Returns the notFilter.
+     */
+    public Filter getNotFilter()
+    {
+        return (Filter)filterSet.get(0);
+    }
+
+    /**
+     * Set the NotFilter
+     *
+     * @param not The notFilter to set.
+     */
+    public void setNotFilter( Filter notFilter ) throws DecoderException
+    {
+        if ( filterSet != null )
+        {
+            throw new DecoderException("Cannot have more than one Filter within a Not Filter");
+        }
+        
+        super.addFilter( notFilter );
+    }
+    
+    /**
+     * Compute the NotFilter length
+     * 
+     * NotFilter :
+     * 
+     * 0xA2 L1 super.computeLength()
+     * 
+     * Length(NotFilter) = Length(0xA2) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        filtersLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+    }
+
+    /**
+     * Encode the NotFilter message to a PDU.
+     * 
+     * NotFilter :
+     * 
+     * 0xA2 LL 
+     * filter.encode()
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The NotFilter Tag
+            buffer.put( (byte)LdapConstants.NOT_FILTER_TAG );
+            buffer.put( Length.getBytes( filtersLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        super.encode( buffer );
+            
+        return buffer;
+    }
+
+    /**
+     * Return a string compliant with RFC 2254 representing a NOT filter
+     *
+     * @return The NOT filter string
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append('!').append(super.toString());
+        
+        return sb.toString();
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/OrFilter.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/OrFilter.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/OrFilter.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/OrFilter.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,121 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1new.ldap.pojo.filters;
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+
+import org.apache.asn1new.EncoderException;
+import org.apache.asn1new.ber.tlv.Length;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+
+
+/**
+ * Or Filter Object to store the Or filter.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OrFilter extends ConnectorFilter
+{
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * The constructor. We wont initialize the ArrayList as they may not be used. 
+     */
+    public OrFilter()
+    {
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the OrFilter
+     *
+     * @return Returns the orFilter.
+     */
+    public ArrayList getOrFilter()
+    {
+        return filterSet;
+    }
+
+    /**
+     * Compute the OrFilter length
+     * 
+     * OrFilter :
+     * 
+     * 0xA1 L1 super.computeLength()
+     * 
+     * Length(OrFilter) = Length(0xA1) + Length(super.computeLength()) + super.computeLength()
+     * 
+     */
+    public int computeLength()
+    {
+        filtersLength = super.computeLength();
+        
+        return 1 + Length.getNbBytes( filtersLength ) + filtersLength;
+    }
+    
+    /**
+     * Encode the OrFilter message to a PDU.
+     * 
+     * OrFilter :
+     * 
+     * 0xA1 LL 
+     * filter.encode()
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if (buffer == null)
+        {
+            throw new EncoderException("Cannot put a PDU in a null buffer !");
+        }
+
+        try 
+        {
+            // The OrFilter Tag
+            buffer.put( (byte)LdapConstants.OR_FILTER_TAG );
+            buffer.put( Length.getBytes( filtersLength ) );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException("The PDU buffer size is too small !"); 
+        }
+        
+        super.encode( buffer );
+            
+        return buffer;
+    }
+
+    /**
+     * Return a string compliant with RFC 2254 representing an OR filter
+     *
+     * @return The OR filter string
+     */
+    public String toString()
+    {
+
+        StringBuffer sb = new StringBuffer();
+
+        sb.append( '|' ).append( super.toString() );
+
+        return sb.toString();
+    }
+}



Mime
View raw message