directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r707831 - /directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/util/EntryFieldInterceptor.java
Date Sat, 25 Oct 2008 10:08:16 GMT
Author: kayyagari
Date: Sat Oct 25 03:08:15 2008
New Revision: 707831

URL: http://svn.apache.org/viewvc?rev=707831&view=rev
Log:
o fixed a bug related to setting the the Attribute changes in dirtyAttrMap
o added javadoc

Modified:
    directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/util/EntryFieldInterceptor.java

Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/util/EntryFieldInterceptor.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/util/EntryFieldInterceptor.java?rev=707831&r1=707830&r2=707831&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/util/EntryFieldInterceptor.java
(original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/util/EntryFieldInterceptor.java
Sat Oct 25 03:08:15 2008
@@ -19,11 +19,13 @@
  */
 package org.apache.directory.olm.util;
 
+
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.olm.Attribute;
 
+
 /**
  * 
  * A field interceptor for Entry implementations.
@@ -35,11 +37,12 @@
 {
     /** map to hold all the dirty <i>Attribute</i>s*/
     private Map<String, Attribute> dirtyAttrMap = new HashMap<String, Attribute>();
-    
-    //TODO need to have a @NoIntercept annotation for better handling of
-    // fields which doesn't need interception or which are not of type Attribute
+
+    //TODO would be better to have a @NoIntercept annotation for better handling of
+    // fields which doesn't need interception
     private Map<String, Object> dirtyFieldMap = new HashMap<String, Object>();
 
+
     /**
      * 
      * tells if the Entity's any Attributes are changed (dirty).
@@ -48,43 +51,64 @@
      */
     public boolean isDirty()
     {
-        return ( ! dirtyAttrMap.isEmpty() );
+        return ( !dirtyAttrMap.isEmpty() );
     }
-    
+
+
     /**
-     * 
+     * @see FieldInterceptor#interceptWrite(Object, String, Object, Object)
      */
     protected void interceptWrite( Object obj, String name, Object oldValue, Object newValue
)
     {
         System.out.println( "intercept obj:" + obj + ", name: " + name + ", oldValue: " +
oldValue + ", newValue: "
             + newValue );
-        
-        if( obj instanceof Attribute )
+
+        if ( oldValue == null && newValue == null )
+        {
+            return;
+        }
+
+        if ( ( oldValue instanceof Attribute ) || ( newValue instanceof Attribute ) )
         {
-            if ( ( ! dirtyAttrMap.containsKey( name ) ) && oldValue != newValue )
+            if ( ( !dirtyAttrMap.containsKey( name ) ) && oldValue != newValue )
             {
-                    dirtyAttrMap.put( name, ( Attribute ) oldValue );
+                dirtyAttrMap.put( name, ( Attribute ) oldValue );
             }
         }
-        else if ( ( ! dirtyFieldMap.containsKey( name ) ) && oldValue != newValue
)
+        else if ( ( !dirtyFieldMap.containsKey( name ) ) && oldValue != newValue
)
         {
             dirtyFieldMap.put( name, oldValue );
         }
     }
 
-    
+
+    /**
+     * 
+     * gives the changed attributes with their field names in the Entry object
+     *
+     * @return a map of modified Attribute field names and the corresponding Attributes'
old values
+     */
     public Map<String, Attribute> getDirtyAttrMap()
     {
         return dirtyAttrMap;
     }
 
-    
+
+    /**
+     * 
+     * gives the changed non-attribute fields.
+     *
+     * @return a map of modified non-attribute fields and their old values
+     */
     public Map<String, Object> getDirtyFieldMap()
     {
         return dirtyFieldMap;
     }
-    
-    
+
+
+    /**
+     * @see FieldInterceptor#interceptRead(Object, String, Object)
+     */
     @Override
     protected void interceptRead( Object obj, String name, Object oldValue )
     {



Mime
View raw message