directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r201898 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/ModifyRequest.java
Date Sun, 26 Jun 2005 20:12:33 GMT
Author: elecharny
Date: Sun Jun 26 13:12:33 2005
New Revision: 201898

URL: http://svn.apache.org/viewcvs?rev=201898&view=rev
Log:
Added the ModifyRequest pojo

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

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/ModifyRequest.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/ModifyRequest.java?rev=201898&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/ModifyRequest.java
(added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/pojo/ModifyRequest.java
Sun Jun 26 13:12:33 2005
@@ -0,0 +1,173 @@
+/*
+ *   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;
+import javax.naming.directory.ModificationItem;
+
+
+/**
+ * A ModifyRequest Message. Its syntax is :
+ *   ModifyRequest ::= [APPLICATION 6] SEQUENCE {
+ *              object          LDAPDN,
+ *              modification    SEQUENCE OF SEQUENCE {
+ *                      operation       ENUMERATED {
+ *                                              add     (0),
+ *                                              delete  (1),
+ *                                              replace (2) },
+ *                      modification    AttributeTypeAndValues } }
+ *
+ *   AttributeTypeAndValues ::= SEQUENCE {
+ *              type    AttributeDescription,
+ *              vals    SET OF AttributeValue }
+ * 
+ *   AttributeValue ::= OCTET STRING
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyRequest extends Asn1Object
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+    /** The DN to be modified. */
+    private LdapDN object;
+    
+    /** The modifications list. This is an array of ModificationItem. */
+    private ArrayList modifications;
+
+    /** The current attribute being decoded */
+    private Attribute currentAttribute;
+    
+    /** A local storage for the operation */
+    private int currentOperation;
+    
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new ModifyRequest object.
+     */
+    public ModifyRequest()
+    {
+        super( );
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Initialize the ArrayList for modifications.
+     */
+    public void initModifications()
+    {
+        modifications = new ArrayList();
+    }
+    
+    /**
+     * Get the entry's attributes
+     *
+     * @return Returns the modifications.
+     */
+    public ArrayList getModifications()
+    {
+        return modifications;
+    }
+
+    /**
+     * Add a new modification to the list
+     *
+     */
+    public void addModification(int operation)
+    {
+        currentOperation = operation;
+        
+        if ( currentAttribute == null )
+        {
+            modifications = new ArrayList();
+        }
+    }
+
+    /**
+     * Create a new attributeValue
+     * @param type The attribute's name
+     */
+    public void addAttributeTypeAndValues( LdapString type )
+    {
+        currentAttribute = new BasicAttribute( type.toString() );
+        modifications.add(currentAttribute);
+    }
+
+    /**
+     * Set the modification opeation
+     * @param type The attribute's name
+     */
+    public void setOperations( int operation )
+    {
+        ModificationItem modification = new ModificationItem( operation, currentAttribute
);
+        modifications.add( modification );
+    }
+
+    /**
+     * Add a new value to the current attribute
+     * @param value
+     */
+    public void addAttributeValue( OctetString value )
+    {
+        currentAttribute.add( value );
+    }
+    
+    /**
+     * Get the modification's DN
+     * @return Returns the object.
+     */
+    public String getObject() 
+    {
+        return ( object == null ? "" : object.toString() );
+    }
+    
+    /**
+     * Set the modification DN.
+     * @param object The object to set.
+     */
+    public void setObject(LdapDN object) 
+    {
+        this.object = object;
+    }
+    
+    /**
+     * Get the current operation
+     * @return Returns the currentOperation.
+     */
+    public int getCurrentOperation() 
+    {
+        return currentOperation;
+    }
+    
+    /**
+     * Store the current operation
+     * @param currentOperation The currentOperation to set.
+     */
+    public void setCurrentOperation(int currentOperation) 
+    {
+        this.currentOperation = currentOperation;
+    }
+}



Mime
View raw message