directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r407046 [1/3] - in /directory/branches/elecharny: apacheds/core/src/main/java/org/apache/directory/server/core/configuration/ shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/ shared/ldap/src/test/java/org/apache/directory/sh...
Date Tue, 16 May 2006 20:09:01 GMT
Author: elecharny
Date: Tue May 16 13:09:00 2006
New Revision: 407046

URL: http://svn.apache.org/viewcvs?rev=407046&view=rev
Log:
Fixed tabs/space mixing

Modified:
    directory/branches/elecharny/apacheds/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java
    directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
    directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
    directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/branches/elecharny/shared/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java

Modified: directory/branches/elecharny/apacheds/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java
URL: http://svn.apache.org/viewcvs/directory/branches/elecharny/apacheds/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java?rev=407046&r1=407045&r2=407046&view=diff
==============================================================================
--- directory/branches/elecharny/apacheds/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java
(original)
+++ directory/branches/elecharny/apacheds/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java
Tue May 16 13:09:00 2006
@@ -18,7 +18,6 @@
  */
 package org.apache.directory.server.core.configuration;
 
-
 import java.beans.PropertyEditor;
 import java.beans.PropertyEditorSupport;
 import java.io.BufferedReader;
@@ -42,13 +41,12 @@
 import org.apache.directory.shared.ldap.util.MultiMap;
 import org.apache.directory.shared.ldap.util.StringTools;
 
-
 /**
- * A JavaBeans {@link PropertyEditor} that can convert {@link Attributes}
- * to LDIF string and vice versa.  This class is useful when you're going
- * to configure a {@link DirectoryService} with 3rd party containers
- * such as <a href="http://www.springframework.org/">Spring Framework</a>.
- *
+ * A JavaBeans {@link PropertyEditor} that can convert {@link Attributes} to
+ * LDIF string and vice versa. This class is useful when you're going to
+ * configure a {@link DirectoryService} with 3rd party containers such as <a
+ * href="http://www.springframework.org/">Spring Framework</a>.
+ * 
  * @author The Apache Directory Project
  * @version $Rev$, $Date$
  */
@@ -63,16 +61,14 @@
         super();
     }
 
-
     /**
      * Creates a new instance with source object.
      */
-    public AttributesPropertyEditor(Object source)
+    public AttributesPropertyEditor( Object source )
     {
         super( source );
     }
 
-
     /**
      * Returns LDIF string of {@link Attributes} object.
      */
@@ -84,92 +80,79 @@
             // FIXME Stop forking commons-collections.
             private final MultiHashMap map = new MultiHashMap();
 
-
             public Object remove( Object arg0, Object arg1 )
             {
                 return map.remove( arg0, arg1 );
             }
 
-
             public int size()
             {
                 return map.size();
             }
 
-
             public Object get( Object arg0 )
             {
                 return map.get( arg0 );
             }
 
-
             public boolean containsValue( Object arg0 )
             {
                 return map.containsValue( arg0 );
             }
 
-
             public Object put( Object arg0, Object arg1 )
             {
                 return map.put( arg0, arg1 );
             }
 
-
             public Object remove( Object arg0 )
             {
                 return map.remove( arg0 );
             }
 
-
             public Collection values()
             {
                 return map.values();
             }
 
-
             public boolean isEmpty()
             {
                 return map.isEmpty();
             }
 
-
             public boolean containsKey( Object key )
             {
                 return map.containsKey( key );
             }
 
-
             public void putAll( Map arg0 )
             {
                 map.putAll( arg0 );
             }
 
-
             public void clear()
             {
                 map.clear();
             }
 
-
             public Set keySet()
             {
                 return map.keySet();
             }
 
-
             public Set entrySet()
             {
                 return map.entrySet();
             }
         };
 
-        Attributes attrs = ( Attributes ) getValue();
+        Attributes attrs = (Attributes) getValue();
         try
         {
             NamingEnumeration e = attrs.getAll();
             while ( e.hasMore() )
             {
-                Attribute attr = ( Attribute ) e.next();
+                Attribute attr = (Attribute) e.next();
                 NamingEnumeration e2 = attr.getAll();
                 while ( e2.hasMoreElements() )
                 {
@@ -180,7 +163,7 @@
 
             return composer.compose( map );
         }
-        catch ( Exception e )
+        catch (Exception e)
         {
             throw new ConfigurationException( e );
         }
@@ -188,62 +171,63 @@
 
     /**
      * Read an entry (without DN)
-     * @param text The ldif format file
+     * 
+     * @param text
+     *            The ldif format file
      * @return An Attributes.
      */
-	private Attributes readEntry( String text )
-	{
-		StringReader strIn = new StringReader( text );
+    private Attributes readEntry( String text )
+    {
+        StringReader strIn = new StringReader( text );
         BufferedReader in = new BufferedReader( strIn );
-		
-		String line = null;
-		Attributes attributes = new BasicAttributes();
-		
-		try
-		{
-			while ( ( line = ((BufferedReader)in).readLine() ) != null )
-			{
-				if ( line.length() == 0 )
-				{
-					continue;
-				}
-
-				String addedLine = line.trim();
-
-				if ( StringTools.isEmpty( addedLine ) )
-				{
-					continue;
-				}
-				
-				Attribute attribute = LdifReader.parseAttributeValue( addedLine );
-				Attribute oldAttribute = attributes.get( attribute.getID() );
-				
-				if ( oldAttribute != null )
-				{
-					try
-					{
-						oldAttribute.add( attribute.get() );
-						attributes.put( oldAttribute );
-					}
-					catch (NamingException ne )
-					{
-						// Do nothing
-					}
-				}
-				else
-				{
-					attributes.put( attribute );
-				}
-			}
-		}
-		catch ( IOException ioe )
-		{
-			// Do nothing : we can't reach this point !
-		}
 
-		return attributes;
-	}
+        String line = null;
+        Attributes attributes = new BasicAttributes();
 
+        try
+        {
+            while ( ( line = ( (BufferedReader) in ).readLine() ) != null )
+            {
+                if ( line.length() == 0 )
+                {
+                    continue;
+                }
+
+                String addedLine = line.trim();
+
+                if ( StringTools.isEmpty( addedLine ) )
+                {
+                    continue;
+                }
+
+                Attribute attribute = LdifReader.parseAttributeValue( addedLine );
+                Attribute oldAttribute = attributes.get( attribute.getID() );
+
+                if ( oldAttribute != null )
+                {
+                    try
+                    {
+                        oldAttribute.add( attribute.get() );
+                        attributes.put( oldAttribute );
+                    }
+                    catch (NamingException ne)
+                    {
+                        // Do nothing
+                    }
+                }
+                else
+                {
+                    attributes.put( attribute );
+                }
+            }
+        }
+        catch (IOException ioe)
+        {
+            // Do nothing : we can't reach this point !
+        }
+
+        return attributes;
+    }
 
     /**
      * Converts the specified LDIF string into {@link Attributes}.
@@ -255,6 +239,6 @@
             text = "";
         }
 
-       	setValue( readEntry( text ) );
+        setValue( readEntry( text ) );
     }
 }

Modified: directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
URL: http://svn.apache.org/viewcvs/directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java?rev=407046&r1=407045&r2=407046&view=diff
==============================================================================
--- directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
(original)
+++ directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
Tue May 16 13:09:00 2006
@@ -17,7 +17,6 @@
 
 package org.apache.directory.shared.ldap.ldif;
 
-
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -34,16 +33,11 @@
 import javax.naming.directory.ModificationItem;
 import javax.naming.ldap.Control;
 
-
 /**
  * A entry to be populated by an ldif parser.
  * 
- * We will have different kind of entries :
- *  - added entries
- *  - deleted entries
- *  - modified entries
- *  - RDN modified entries
- *  - DN modified entries
+ * We will have different kind of entries : - added entries - deleted entries -
+ * modified entries - RDN modified entries - DN modified entries
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -57,41 +51,46 @@
 
     /** the modification item list */
     private List modificationList;
+
     private Map modificationItems;
 
     /** the dn of the ldif entry */
     private String dn;
-    
+
     /** The new superior */
     private String newSuperior;
-    
+
     /** The new rdn */
     private String newRdn;
-    
+
     /** The delete old rdn flag */
     private boolean deleteOldRdn;
 
     /** attributes of the entry */
     private BasicAttributes attributeList;
-    
+
     /** The possible change types */
     public final static int ADD = 0;
+
     public final static int MODIFY = 1;
+
     public final static int MODDN = 2;
+
     public final static int MODRDN = 3;
+
     public final static int DELETE = 4;
-    
+
     /** The control */
     private Control control;
-    
+
     /**
      * Creates a new Entry object.
      */
     public Entry()
     {
-    	changeType = ADD; // Default LDIF content
-    	modificationList = new LinkedList();
-    	modificationItems = new HashMap();
+        changeType = ADD; // Default LDIF content
+        modificationList = new LinkedList();
+        modificationItems = new HashMap();
         dn = null;
         attributeList = new BasicAttributes( true );
         version = 1; // default version in ldif
@@ -101,7 +100,8 @@
     /**
      * Sets the version of this ldif
      * 
-     * @param version The version of this ldif
+     * @param version
+     *            The version of this ldif
      */
     public void setVersion( int version )
     {
@@ -109,9 +109,10 @@
     }
 
     /**
-     * Set the Distinguished Name 
+     * Set the Distinguished Name
      * 
-     * @param dn The Distinguished Name
+     * @param dn
+     *            The Distinguished Name
      */
     public void setDn( String dn )
     {
@@ -121,7 +122,8 @@
     /**
      * Set the modification type
      * 
-     * @param changeType The change type
+     * @param changeType
+     *            The change type
      * 
      */
     public void setChangeType( int changeType )
@@ -132,118 +134,122 @@
     /**
      * Set the change type
      * 
-     * @param changeType The change type
+     * @param changeType
+     *            The change type
      */
     public void setChangeType( String changeType )
     {
-    	if ( "add".equals( changeType ) )
-    	{
+        if ( "add".equals( changeType ) )
+        {
             this.changeType = ADD;
-    	} 
-    	else if ( "modify".equals( changeType ) )
-    	{
+        }
+        else if ( "modify".equals( changeType ) )
+        {
             this.changeType = MODIFY;
-    	}
-    	else if ( "moddn".equals( changeType ) )
-    	{
+        }
+        else if ( "moddn".equals( changeType ) )
+        {
             this.changeType = MODDN;
-    	}
-    	else if ( "modrdn".equals( changeType ) )
-    	{
+        }
+        else if ( "modrdn".equals( changeType ) )
+        {
             this.changeType = MODRDN;
-    	}
-    	else if ( "delete".equals( changeType ) )
-    	{
+        }
+        else if ( "delete".equals( changeType ) )
+        {
             this.changeType = DELETE;
-    	} 
+        }
     }
 
     /**
      * Add a modification item (used by modify operations)
      * 
-     * @param ModificationItem The modification to be added
+     * @param ModificationItem
+     *            The modification to be added
      */
     public void addModificationItem( ModificationItem modification )
     {
-    	if ( changeType == MODIFY )
-    	{
-    		modificationList.add( modification );
-    		modificationItems.put( modification.getAttribute().getID(), modification );
-    	}
+        if ( changeType == MODIFY )
+        {
+            modificationList.add( modification );
+            modificationItems.put( modification.getAttribute().getID(), modification );
+        }
     }
 
     /**
      * Add a modification item (used by modify operations)
      * 
-     * @param modOp The operation. One of : 
-     * 	DirContext.ADD_ATTRIBUTE
-     *  DirContext.REMOVE_ATTRIBUTE
-     *  DirContext.REPLACE_ATTRIBUTE
-     *  
-     * @param attr The attribute to be added
+     * @param modOp
+     *            The operation. One of : DirContext.ADD_ATTRIBUTE
+     *            DirContext.REMOVE_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE
+     * 
+     * @param attr
+     *            The attribute to be added
      */
     public void addModificationItem( int modOp, Attribute attr ) throws NamingException
     {
-    	if ( changeType == MODIFY )
-    	{
-    		if ( modificationItems.containsKey( attr.getID() ) )
-    		{
-    			ModificationItem item = (ModificationItem)modificationItems.get( attr.getID() );
-    			Attribute attribute = item.getAttribute();
-    			
-    			Enumeration attrs = attr.getAll();
-    			
-    			while ( attrs.hasMoreElements() )
-    			{
-    				attribute.add( attrs.nextElement() );
-    			}
-    		}
-    		else
-    		{
-		    	ModificationItem item = new ModificationItem( modOp, attr );
-		    	modificationList.add( item );
-	    		modificationItems.put( attr.getID(), item );
-    		}
-    	}
+        if ( changeType == MODIFY )
+        {
+            if ( modificationItems.containsKey( attr.getID() ) )
+            {
+                ModificationItem item = (ModificationItem) modificationItems.get( attr.getID()
);
+                Attribute attribute = item.getAttribute();
+
+                Enumeration attrs = attr.getAll();
+
+                while ( attrs.hasMoreElements() )
+                {
+                    attribute.add( attrs.nextElement() );
+                }
+            }
+            else
+            {
+                ModificationItem item = new ModificationItem( modOp, attr );
+                modificationList.add( item );
+                modificationItems.put( attr.getID(), item );
+            }
+        }
     }
 
     /**
      * Add a modification item
      * 
-     * @param modOp The operation. One of : 
-     * 	DirContext.ADD_ATTRIBUTE
-     *  DirContext.REMOVE_ATTRIBUTE
-     *  DirContext.REPLACE_ATTRIBUTE
-     *            
-     * @param id The attribute's ID
-     * @param value The attribute's value
+     * @param modOp
+     *            The operation. One of : DirContext.ADD_ATTRIBUTE
+     *            DirContext.REMOVE_ATTRIBUTE DirContext.REPLACE_ATTRIBUTE
+     * 
+     * @param id
+     *            The attribute's ID
+     * @param value
+     *            The attribute's value
      */
     public void addModificationItem( int modOp, String id, Object value )
     {
-    	if ( changeType == MODIFY )
-    	{
-	        BasicAttribute attr = new BasicAttribute( id, value );
-	        
-    		if ( modificationItems.containsKey( id ) )
-    		{
-    			ModificationItem item = (ModificationItem)modificationItems.get( id );
-    			Attribute attribute = item.getAttribute();
-    			
-   				attribute.add( value );
-    		}
-    		else
-    		{
-		        ModificationItem item = new ModificationItem( modOp, attr );
-		        modificationList.add( item );
-		        modificationItems.put( id, item );
-    		}
-    	}    
+        if ( changeType == MODIFY )
+        {
+            BasicAttribute attr = new BasicAttribute( id, value );
+
+            if ( modificationItems.containsKey( id ) )
+            {
+                ModificationItem item = (ModificationItem) modificationItems.get( id );
+                Attribute attribute = item.getAttribute();
+
+                attribute.add( value );
+            }
+            else
+            {
+                ModificationItem item = new ModificationItem( modOp, attr );
+                modificationList.add( item );
+                modificationItems.put( id, item );
+            }
+        }
     }
 
     /**
      * Add an attribute to the entry
      * 
-     * @param attr The attribute to be added
+     * @param attr
+     *            The attribute to be added
      */
     public void addAttribute( Attribute attr )
     {
@@ -253,56 +259,56 @@
     /**
      * Add an attribute to the entry
      * 
-     * @param id The attribute ID
-     *            
-     * @param value The attribute value
-     *            
+     * @param id
+     *            The attribute ID
+     * 
+     * @param value
+     *            The attribute value
+     * 
      */
     public void addAttribute( String id, Object value )
     {
-		Attribute attr = get( id );
-		
-		if ( attr != null )
-		{
-			attr.add( value );
-		}
-		else
-		{
-			attributeList.put( id, value );
-		}
+        Attribute attr = get( id );
+
+        if ( attr != null )
+        {
+            attr.add( value );
+        }
+        else
+        {
+            attributeList.put( id, value );
+        }
     }
 
     /**
      * Add an attribute value to an existing attribute
      * 
-     * @param id The attribute ID
-     *            
-     * @param value The attribute value
-     *            
+     * @param id
+     *            The attribute ID
+     * 
+     * @param value
+     *            The attribute value
+     * 
      */
     public void putAttribute( String id, Object value )
     {
         Attribute attribute = attributeList.get( id );
-        
+
         if ( attribute != null )
         {
-        	attribute.add( value );
+            attribute.add( value );
         }
         else
         {
-        	attributeList.put( id, value );
+            attributeList.put( id, value );
         }
     }
 
     /**
      * Get the change type
      * 
-     * @return The change type. One of : 
-     * 	ADD = 0;
-     *  MODIFY = 1;
-     *  MODDN = 2;
-     *  MODRDN = 3;
-     *  DELETE = 4;
+     * @return The change type. One of : ADD = 0; MODIFY = 1; MODDN = 2; MODRDN =
+     *         3; DELETE = 4;
      */
     public int getChangeType()
     {
@@ -332,226 +338,238 @@
     {
         return this.version;
     }
-    
+
     /**
      * @return The number of entry modifications
      */
     public int size()
     {
-    	return modificationList.size();
+        return modificationList.size();
     }
-    
+
     /**
      * Returns a attribute given it's id
      * 
-     * @param attributeId The attribute Id
+     * @param attributeId
+     *            The attribute Id
      * @return The attribute if it exists
      */
     public Attribute get( String attributeId )
     {
-    	if ( "dn".equalsIgnoreCase( attributeId ) )
-    	{
-    		return new BasicAttribute( "dn", dn );
-    	}
-    	
-  		return attributeList.get( attributeId );
+        if ( "dn".equalsIgnoreCase( attributeId ) )
+        {
+            return new BasicAttribute( "dn", dn );
+        }
+
+        return attributeList.get( attributeId );
     }
-    
+
     /**
-     * Get the entry's attributes 
+     * Get the entry's attributes
+     * 
      * @return An Attributes
      */
     public Attributes getAttributes()
     {
-    	if ( isEntry() )
-    	{
-    		return attributeList;
-    	}
-    	else
-    	{
-    		return null;
-    	}
+        if ( isEntry() )
+        {
+            return attributeList;
+        }
+        else
+        {
+            return null;
+        }
     }
 
     /**
      * @return True, if the old RDN should be deleted.
      */
-	public boolean isDeleteOldRdn() 
-	{
-		return deleteOldRdn;
-	}
-
-	/**
-	 * Set the flage deleteOldRdn
-	 * @param deleteOldRdn True if the old RDN should be deleted
-	 */
-	public void setDeleteOldRdn( boolean deleteOldRdn ) 
-	{
-		this.deleteOldRdn = deleteOldRdn;
-	}
-
-	/**
-	 * @return The new RDN
-	 */
-	public String getNewRdn() 
-	{
-		return newRdn;
-	}
-
-	/**
-	 * Set the new RDN
-	 * @param newRdn The new RDN
-	 */
-	public void setNewRdn( String newRdn ) 
-	{
-		this.newRdn = newRdn;
-	}
-
-	/**
-	 * @return The new superior
-	 */
-	public String getNewSuperior() 
-	{
-		return newSuperior;
-	}
-
-	/**
-	 * Set the new superior
-	 * @param newSuperior The new Superior
-	 */
-	public void setNewSuperior( String newSuperior ) 
-	{
-		this.newSuperior = newSuperior;
-	}
-	
-	/**
-	 * @return True if the entry is an ADD entry
-	 */
-	public boolean isChangeAdd()
-	{
-		return changeType == ADD;
-	}
-
-	/**
-	 * @return True if the entry is a DELETE entry
-	 */
-	public boolean isChangeDelete()
-	{
-		return changeType == DELETE;
-	}
-
-	/**
-	 * @return True if the entry is a MODDN entry
-	 */
-	public boolean isChangeModDn()
-	{
-		return changeType == MODDN;
-	}
-
-	/**
-	 * @return True if the entry is a MODRDN entry
-	 */
-	public boolean isChangeModRdn()
-	{
-		return changeType == MODRDN;
-	}
-
-	/**
-	 * @return True if the entry is a MODIFY entry
-	 */
-	public boolean isChangeModify()
-	{
-		return changeType == MODIFY;
-	}
-	
-	public boolean isEntry()
-	{
-		return changeType == ADD; 
-	}
-
-	/**
-	 * @return The associated control, if any
-	 */
-	public Control getControl() 
-	{
-		return control;
-	}
-
-	/**
-	 * Add a control to the entry 
-	 * @param control The control
-	 */
-	public void setControl( Control control ) 
-	{
-		this.control = control;
-	}
-	
-	/**
-	 * Clone method
-	 */
-	public Object clone() throws CloneNotSupportedException
-	{
-		Entry clone = (Entry)super.clone();
-		
-		if ( modificationList != null )
-		{
-			for ( Iterator iter = modificationList.iterator(); iter.hasNext(); )
-			{
-				ModificationItem modif = (ModificationItem)(iter.next());
-				ModificationItem modifClone = new ModificationItem( modif.getModificationOp(), (Attribute)modif.getAttribute().clone()
) ;
-				clone.modificationList.add( modifClone );
-			}
-		}
-		
-		if ( modificationItems != null )
-		{
-			for ( Iterator iter = modificationItems.entrySet().iterator(); iter.hasNext(); )
-			{
-				Object key = iter.next();
-				ModificationItem modif = (ModificationItem)(modificationItems.get( key ));
-				ModificationItem modifClone = new ModificationItem( modif.getModificationOp(), (Attribute)modif.getAttribute().clone()
) ;
-				clone.modificationItems.put( key, modifClone );
-			}
-			
-		}
-		
-		if ( attributeList != null )
-		{
-			try
-			{
-				NamingEnumeration attrs = attributeList.getAll();
-				
-				while ( attrs.hasMore() )
-				{
-					Attribute attribute = (BasicAttribute)attrs.nextElement();
-					Attribute attrClone = new BasicAttribute( attribute.getID() );
-					
-					for ( NamingEnumeration iter = attribute.getAll(); iter.hasMoreElements();)
-					{
-						Object value = iter.next();
-						
-						if ( value instanceof String )
-						{
-							attrClone.add( value );
-						}
-						else if ( value instanceof byte[] )
-						{
-							int length = ((byte[])value).length;
-							byte[] valueClone = new byte[ length ];
-							System.arraycopy( value, 0, valueClone, 0, length );
-							attrClone.add( valueClone );
-						}
-					}
-					
-					clone.attributeList.put( attrClone );
-				}
-			}
-			catch ( NamingException ne )
-			{
-				throw new CloneNotSupportedException( ne.getMessage() );
-			}
-		}
-		
-		return clone;
-	}
+    public boolean isDeleteOldRdn()
+    {
+        return deleteOldRdn;
+    }
+
+    /**
+     * Set the flage deleteOldRdn
+     * 
+     * @param deleteOldRdn
+     *            True if the old RDN should be deleted
+     */
+    public void setDeleteOldRdn( boolean deleteOldRdn )
+    {
+        this.deleteOldRdn = deleteOldRdn;
+    }
+
+    /**
+     * @return The new RDN
+     */
+    public String getNewRdn()
+    {
+        return newRdn;
+    }
+
+    /**
+     * Set the new RDN
+     * 
+     * @param newRdn
+     *            The new RDN
+     */
+    public void setNewRdn( String newRdn )
+    {
+        this.newRdn = newRdn;
+    }
+
+    /**
+     * @return The new superior
+     */
+    public String getNewSuperior()
+    {
+        return newSuperior;
+    }
+
+    /**
+     * Set the new superior
+     * 
+     * @param newSuperior
+     *            The new Superior
+     */
+    public void setNewSuperior( String newSuperior )
+    {
+        this.newSuperior = newSuperior;
+    }
+
+    /**
+     * @return True if the entry is an ADD entry
+     */
+    public boolean isChangeAdd()
+    {
+        return changeType == ADD;
+    }
+
+    /**
+     * @return True if the entry is a DELETE entry
+     */
+    public boolean isChangeDelete()
+    {
+        return changeType == DELETE;
+    }
+
+    /**
+     * @return True if the entry is a MODDN entry
+     */
+    public boolean isChangeModDn()
+    {
+        return changeType == MODDN;
+    }
+
+    /**
+     * @return True if the entry is a MODRDN entry
+     */
+    public boolean isChangeModRdn()
+    {
+        return changeType == MODRDN;
+    }
+
+    /**
+     * @return True if the entry is a MODIFY entry
+     */
+    public boolean isChangeModify()
+    {
+        return changeType == MODIFY;
+    }
+
+    public boolean isEntry()
+    {
+        return changeType == ADD;
+    }
+
+    /**
+     * @return The associated control, if any
+     */
+    public Control getControl()
+    {
+        return control;
+    }
+
+    /**
+     * Add a control to the entry
+     * 
+     * @param control
+     *            The control
+     */
+    public void setControl( Control control )
+    {
+        this.control = control;
+    }
+
+    /**
+     * Clone method
+     */
+    public Object clone() throws CloneNotSupportedException
+    {
+        Entry clone = (Entry) super.clone();
+
+        if ( modificationList != null )
+        {
+            for ( Iterator iter = modificationList.iterator(); iter.hasNext(); )
+            {
+                ModificationItem modif = (ModificationItem) ( iter.next() );
+                ModificationItem modifClone = new ModificationItem( modif.getModificationOp(),
(Attribute) modif.getAttribute()
+                        .clone() );
+                clone.modificationList.add( modifClone );
+            }
+        }
+
+        if ( modificationItems != null )
+        {
+            for ( Iterator iter = modificationItems.entrySet().iterator(); iter.hasNext();
)
+            {
+                Object key = iter.next();
+                ModificationItem modif = (ModificationItem) ( modificationItems.get( key
) );
+                ModificationItem modifClone = new ModificationItem( modif.getModificationOp(),
(Attribute) modif.getAttribute()
+                        .clone() );
+                clone.modificationItems.put( key, modifClone );
+            }
+
+        }
+
+        if ( attributeList != null )
+        {
+            try
+            {
+                NamingEnumeration attrs = attributeList.getAll();
+
+                while ( attrs.hasMore() )
+                {
+                    Attribute attribute = (BasicAttribute) attrs.nextElement();
+                    Attribute attrClone = new BasicAttribute( attribute.getID() );
+
+                    for ( NamingEnumeration iter = attribute.getAll(); iter.hasMoreElements();
)
+                    {
+                        Object value = iter.next();
+
+                        if ( value instanceof String )
+                        {
+                            attrClone.add( value );
+                        }
+                        else if ( value instanceof byte[] )
+                        {
+                            int length = ( (byte[]) value ).length;
+                            byte[] valueClone = new byte[length];
+                            System.arraycopy( value, 0, valueClone, 0, length );
+                            attrClone.add( valueClone );
+                        }
+                    }
+
+                    clone.attributeList.put( attrClone );
+                }
+            }
+            catch (NamingException ne)
+            {
+                throw new CloneNotSupportedException( ne.getMessage() );
+            }
+        }
+
+        return clone;
+    }
 }

Modified: directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
URL: http://svn.apache.org/viewcvs/directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java?rev=407046&r1=407045&r2=407046&view=diff
==============================================================================
--- directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
(original)
+++ directory/branches/elecharny/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
Tue May 16 13:09:00 2006
@@ -23,91 +23,96 @@
 import org.apache.directory.shared.ldap.util.StringTools;
 
 /**
- * The LdifControl class stores a control defined for an entry found in
- * a ldif file.
+ * The LdifControl class stores a control defined for an entry found in a ldif
+ * file.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class LdifControl implements Control
 {
-	static final long serialVersionUID = 1L;
-	
-	/** The control OID */
-	private OID oid;
-	
-	/** The control criticality */
-	private boolean criticality;
-	
-	/** The control BER encoded value */
-	private byte[] value;
-	
-	/**
-	 * Create a new Control
-	 * @param oid OID of the created control
-	 */
-	public LdifControl( OID oid )
-	{
-		this.oid = oid;
-		criticality = false;
-		value = null;
-	}
-
-	/**
-	 *	Returns the criticality of the current control 
-	 */
-	public boolean isCritical() 
-	{
-		return criticality;
-	}
-
-	/**
-	 * Set the criticality
-	 * @param criticality True or false.
-	 */
-	public void setCriticality( boolean criticality ) 
-	{
-		this.criticality = criticality;
-	}
-
-	/**
-	 * Return the control's OID as a String
-	 */
-	public String getID() 
-	{
-		return oid.toString();
-	}
-
-	/**
-	 * Set the control's OID
-	 * 
-	 * @param oid The control's OID
-	 */
-	public void setOid( OID oid ) 
-	{
-		this.oid = oid;
-	}
-
-	/**
-	 * Returns the BER encoded value of the control
-	 */
-	public byte[] getEncodedValue() 
-	{
-		return value;
-	}
-
-	/**
-	 * Set the BER encoded value of the control
-	 * 
-	 * @param value BER encodec value
-	 */
-	public void setValue( byte[] value ) 
-	{
-		this.value = value;
-	}
-	
-	public String toString()
-	{
-		return "LdifControl : {" + oid.toString() + ", " + criticality + ", " + 
-			StringTools.dumpBytes( value ) + "}";
-	}
+    static final long serialVersionUID = 1L;
+
+    /** The control OID */
+    private OID oid;
+
+    /** The control criticality */
+    private boolean criticality;
+
+    /** The control BER encoded value */
+    private byte[] value;
+
+    /**
+     * Create a new Control
+     * 
+     * @param oid
+     *            OID of the created control
+     */
+    public LdifControl( OID oid )
+    {
+        this.oid = oid;
+        criticality = false;
+        value = null;
+    }
+
+    /**
+     * Returns the criticality of the current control
+     */
+    public boolean isCritical()
+    {
+        return criticality;
+    }
+
+    /**
+     * Set the criticality
+     * 
+     * @param criticality
+     *            True or false.
+     */
+    public void setCriticality( boolean criticality )
+    {
+        this.criticality = criticality;
+    }
+
+    /**
+     * Return the control's OID as a String
+     */
+    public String getID()
+    {
+        return oid.toString();
+    }
+
+    /**
+     * Set the control's OID
+     * 
+     * @param oid
+     *            The control's OID
+     */
+    public void setOid( OID oid )
+    {
+        this.oid = oid;
+    }
+
+    /**
+     * Returns the BER encoded value of the control
+     */
+    public byte[] getEncodedValue()
+    {
+        return value;
+    }
+
+    /**
+     * Set the BER encoded value of the control
+     * 
+     * @param value
+     *            BER encodec value
+     */
+    public void setValue( byte[] value )
+    {
+        this.value = value;
+    }
+
+    public String toString()
+    {
+        return "LdifControl : {" + oid.toString() + ", " + criticality + ", " + StringTools.dumpBytes(
value ) + "}";
+    }
 }



Mime
View raw message