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 2011/07/28 17:57:07 UTC

svn commit: r1151902 - in /directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event: EventType.java NotificationCriteria.java

Author: elecharny
Date: Thu Jul 28 15:57:06 2011
New Revision: 1151902

URL: http://svn.apache.org/viewvc?rev=1151902&view=rev
Log:
o Added missing Javadoc
o Added toString() methods

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/EventType.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/NotificationCriteria.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/EventType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/EventType.java?rev=1151902&r1=1151901&r2=1151902&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/EventType.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/EventType.java Thu Jul 28 15:57:06 2011
@@ -34,13 +34,17 @@ import org.apache.directory.shared.ldap.
  */
 public enum EventType
 {
-    ADD(1), DELETE(2), MODIFY(4), RENAME(8), MOVE(16);
-    
+    ADD(1), 
+    DELETE(2), 
+    MODIFY(4), 
+    RENAME(8), 
+    MOVE(16);    
     
     public static final int ALL_EVENT_TYPES_MASK = getAllEventTypesMask();
-    public static final int MOVE_OR_RENAME_MASK = MOVE.mask | RENAME.mask;
+    public static final int MOVE_AND_RENAME_MASK = MOVE.mask | RENAME.mask;
     private static final EventType[] EMPTY_EVENT_ARRAY = new EventType[0];
     
+    // The internal value
     private int mask;
     
     
@@ -116,73 +120,67 @@ public enum EventType
     }
     
     
+    /**
+     * Tells if the EventType is an ADD
+     */
     public static boolean isAdd( int mask )
     {
-        if ( ( mask & ADD.mask ) > 0 )
-        {
-            return true;
-        }
-        
-        return false;
+        return ( ( mask & ADD.mask ) != 0 );
     }
     
     
+    /**
+     * Tells if the EventType is a DELETE
+     */
     public static boolean isDelete( int mask )
     {
-        if ( ( mask & DELETE.mask ) > 0 )
-        {
-            return true;
-        }
-        
-        return false;
+        return ( ( mask & DELETE.mask ) != 0 );
     }
     
     
+    /**
+     * Tells if the EventType is a MODIFY
+     */
     public static boolean isModify( int mask )
     {
-        if ( ( mask & MODIFY.mask ) > 0 )
-        {
-            return true;
-        }
-        
-        return false;
+        return ( ( mask & MODIFY.mask ) != 0 );
     }
     
     
+    /**
+     * Tells if the EventType is a MOVE
+     */
     public static boolean isMove( int mask )
     {
-        if ( ( mask & MOVE.mask ) > 0 )
-        {
-            return true;
-        }
-        
-        return false;
+        return ( ( mask & MOVE.mask ) != 0 );
     }
     
     
+    /**
+     * Tells if the EventType is a RENAME
+     */
     public static boolean isRename( int mask )
     {
-        if ( ( mask & RENAME.mask ) > 0 )
-        {
-            return true;
-        }
-        
-        return false;
+        return ( ( mask & RENAME.mask ) != 0 );
     }
     
     
+    /**
+     * Tells if the EventType is a MOVE and RENAME
+     */
     public static boolean isMoveAndRename( int mask )
     {
-        if ( ( mask & MOVE_OR_RENAME_MASK ) > 0 )
-        {
-            return true;
-        }
-        
-        return false;
+        return ( ( mask & MOVE_AND_RENAME_MASK) != 0 );
     }
     
     
-    public static int getMask( EventType ...eventTypes )
+    /**
+     * Compute the mask associated with the given eventTypes
+     * 
+     * @param eventTypes The eventTypes 
+     * @return The associated mask
+     */
+    public static int getMask( EventType... eventTypes )
     {
         int mask = 0;
         
@@ -204,7 +202,7 @@ public enum EventType
      */
     public static EventType getType( int mask )
     {
-        switch( mask )
+        switch ( mask )
         {
             case 1: return ADD;
             
@@ -215,8 +213,33 @@ public enum EventType
             case 8: return RENAME;
             
             case 16: return MOVE;
-            
+                        
             default: throw new IllegalArgumentException( "unknown mask value " + mask );
         }
     }
+    
+    
+    public String toString( int mask )
+    {
+        switch ( mask )
+        {
+            case 0 : return "no event";
+            
+            case 1: return "ADD";
+            
+            case 2: return "DELETE";
+            
+            case 4: return "MODIFY";
+            
+            case 8: return "RENAME";
+            
+            case 16: return "MOVE";
+            
+            case 24 : return "MOVE_AND_RENAME";
+            
+            case 31 : return "ALL EVENTS"; 
+            
+            default : return "Unknown";
+        }
+    }
 }

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/NotificationCriteria.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/NotificationCriteria.java?rev=1151902&r1=1151901&r2=1151902&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/NotificationCriteria.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/event/NotificationCriteria.java Thu Jul 28 15:57:06 2011
@@ -38,23 +38,33 @@ import org.apache.directory.shared.ldap.
  */
 public class NotificationCriteria
 {
-    public static final SearchScope DEFAULT_SCOPE = SearchScope.ONELEVEL;
-    public static final AliasDerefMode DEFAULT_ALIAS_DEREF_MODE = AliasDerefMode.DEREF_ALWAYS;
-    public static final Dn DEFAULT_BASE = null;
-    public static final ExprNode DEFAULT_FILTER = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
-    
-    private SearchScope scope = DEFAULT_SCOPE;
-    private AliasDerefMode aliasDerefMode = DEFAULT_ALIAS_DEREF_MODE;
-    private Dn base = DEFAULT_BASE;
-    private ExprNode filter = DEFAULT_FILTER;
+    /** The scope to use (default to ONE_LEVEL) */
+    private SearchScope scope = SearchScope.ONELEVEL;
+    
+    /** The AliasderefMode to use (default to DEREF_ALWAYS) */
+    private AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
+    
+    /** The Base DN to search from (default to null) */
+    private Dn base = null;
+    
+    /** The filter to use (default to '(ObjectClass=*)') */
+    private ExprNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
+    
+    /** The event mask to use (default to everything) */
     private int eventMask = EventType.ALL_EVENT_TYPES_MASK;
     
     
+    /**
+     * Create a new instance of a NotiticationCriteria
+     */
     public NotificationCriteria()
     {
     }
     
     
+    /**
+     * Create a new instance of a NotiticationCriteria initialized with a search request
+     */
     public NotificationCriteria( SearchRequest req )
     {
         this.scope = req.getScope();
@@ -155,7 +165,7 @@ public class NotificationCriteria
 
 
     /**
-     * @param eventMask the eventMask to set
+     * @param eventTypes the eventTypes to set
      */
     public void setEventMask( EventType ...eventTypes )
     {
@@ -170,4 +180,22 @@ public class NotificationCriteria
     {
         return eventMask;
     }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append( "Notification criteria : " );
+        sb.append( "(" ).append( base ).append( "), " );
+        sb.append( "(" ).append( filter ).append( "), " );
+        sb.append( "(" ).append( scope ).append( "), " );
+        sb.append( "(" ).append( aliasDerefMode ).append( "), " );
+        sb.append( "(" ).append( eventMask ).append( ")" );
+        
+        return sb.toString();
+    }
 }