directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1062546 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif: LdifControl.java LdifEntry.java
Date Sun, 23 Jan 2011 22:12:14 GMT
Author: akarasulu
Date: Sun Jan 23 22:12:14 2011
New Revision: 1062546

URL: http://svn.apache.org/viewvc?rev=1062546&view=rev
Log:
Shared refactoring continued ...

  o breaking dependency from ldif package on codec
  o LdifControl implements Control now instead of extending AbstractControl
    in the codec. The codec should be able to transform this if this LDIF
    generated control needs to be handled by the codec. Otherwise we'll have
    to use a factory to generate the controls so the codec is happy.


Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java?rev=1062546&r1=1062545&r2=1062546&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
Sun Jan 23 22:12:14 2011
@@ -17,25 +17,35 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.shared.ldap.ldif;
 
 
-import org.apache.directory.shared.ldap.codec.controls.AbstractControl;
+import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.util.Strings;
 
 
 /**
- * The LdifControl class stores a control defined for an entry found in a ldif
+ * 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 extends AbstractControl
+public class LdifControl implements Control
 {
     /** The serial version UID */
     private static final long serialVersionUID = 1L;
 
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+    /** The control type */
+    private String oid;
+
+    /** The criticality (default value is false) */
+    private boolean criticality = false;
+
+    /** Optional control value */
+    protected byte[] value;
+
 
     /**
      * Create a new Control
@@ -44,7 +54,7 @@ public class LdifControl extends Abstrac
      */
     public LdifControl( String oid )
     {
-        super( oid );
+        this.oid = oid;
     }
 
 
@@ -53,6 +63,96 @@ public class LdifControl extends Abstrac
      */
     public String toString()
     {
-        return "LdifControl : {" + getOid() + ", " + isCritical() + ", " + Strings.dumpBytes(getValue())
+ "}";
+        return "LdifControl : {" + getOid() + ", " + isCritical() + ", " + Strings.dumpBytes(
getValue() ) + "}";
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOid()
+    {
+        return oid;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isCritical()
+    {
+        return criticality;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setCritical( boolean criticality )
+    {
+        this.criticality = criticality;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public byte[] getValue()
+    {
+        return value;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setValue( byte[] value )
+    {
+        this.value = value;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasValue()
+    {
+        return value != null;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o )
+    {
+        if ( o == this )
+        {
+            return true;
+        }
+
+        if ( o == null )
+        {
+            return false;
+        }
+
+        if ( !( o instanceof Control) )
+        {
+            return false;
+        }
+
+        Control otherControl = ( Control ) o;
+
+        if ( !oid.equalsIgnoreCase( otherControl.getOid() ) )
+        {
+            return false;
+        }
+
+        if ( criticality != otherControl.isCritical() )
+        {
+            return false;
+        }
+
+        return hasValue() == otherControl.hasValue();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=1062546&r1=1062545&r2=1062546&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
Sun Jan 23 22:12:14 2011
@@ -17,7 +17,6 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.shared.ldap.ldif;
 
 
@@ -31,7 +30,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
 import org.apache.directory.shared.ldap.entry.DefaultModification;
@@ -229,7 +227,7 @@ public class LdifEntry implements Clonea
     {
         if ( changeType == ChangeType.Modify )
         {
-            EntryAttribute attr = null;
+            EntryAttribute attr;
 
             if ( value == null )
             {
@@ -633,8 +631,8 @@ public class LdifEntry implements Clonea
         {
             for ( Modification modif : modificationList )
             {
-                Modification modifClone = new DefaultModification( modif.getOperation(),
( EntryAttribute ) modif
-                    .getAttribute().clone() );
+                Modification modifClone = new DefaultModification( modif.getOperation(),
+                        modif.getAttribute().clone() );
                 clone.modificationList.add( modifClone );
             }
         }
@@ -644,8 +642,8 @@ public class LdifEntry implements Clonea
             for ( String key : modificationItems.keySet() )
             {
                 Modification modif = modificationItems.get( key );
-                Modification modifClone = new DefaultModification( modif.getOperation(),
( EntryAttribute ) modif
-                    .getAttribute().clone() );
+                Modification modifClone = new DefaultModification( modif.getOperation(),
+                        modif.getAttribute().clone() );
                 clone.modificationItems.put( key, modifClone );
             }
 
@@ -941,8 +939,6 @@ public class LdifEntry implements Clonea
                     {
                         return false;
                     }
-
-                    continue;
                 }
                 else
                 {
@@ -1035,7 +1031,7 @@ public class LdifEntry implements Clonea
                     String controlOid = in.readUTF();
                     boolean isCritical = in.readBoolean();
                     boolean hasValue = in.readBoolean();
-                    Control control = new ControlImpl( controlOid );
+                    Control control = new LdifControl( controlOid );
                     control.setCritical( isCritical );
 
                     if ( hasValue )
@@ -1059,11 +1055,9 @@ public class LdifEntry implements Clonea
 
 
     /**
-     * @see Externalizable#readExternal(ObjectInput)<p>
-     *
-     *@param out The stream in which the ChangeLogEvent will be serialized. 
-     *
-     *@throws IOException If the serialization fail
+     * @see Externalizable#readExternal(ObjectInput)
+     * @param out The stream in which the ChangeLogEvent will be serialized.
+     * @throws IOException If the serialization fail
      */
     public void writeExternal( ObjectOutput out ) throws IOException
     {



Mime
View raw message