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 2005/06/24 23:47:40 UTC

svn commit: r201681 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java

Author: elecharny
Date: Fri Jun 24 14:47:39 2005
New Revision: 201681

URL: http://svn.apache.org/viewcvs?rev=201681&view=rev
Log:
Created the SearchResultEntry POJO

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java?rev=201681&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java (added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/SearchResultEntry.java Fri Jun 24 14:47:39 2005
@@ -0,0 +1,160 @@
+/*
+ *   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.asn1.ldap.pojo;
+
+import org.apache.asn1.Asn1Object;
+import org.apache.asn1.ldap.codec.primitives.LdapDN;
+import org.apache.asn1.ldap.codec.primitives.LdapString;
+import org.apache.asn1.primitives.OctetString;
+
+import java.util.ArrayList;
+
+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 int       partialAttributesListExpectedLength;
+
+    /** The current attribute being decoded */
+    private Attribute currentAttributeValue;
+
+    //~ 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() );
+
+        partialAttributeList.add( currentAttributeValue );
+    }
+
+    /**
+     * Add a new value to the current attribute
+     * @param value
+     */
+    public void addAttributeValue( OctetString value )
+    {
+        currentAttributeValue.add( value );
+    }
+}