directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r474615 - in /directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap: codec/ message/ schema/ util/
Date Tue, 14 Nov 2006 00:55:35 GMT
Author: elecharny
Date: Mon Nov 13 16:55:34 2006
New Revision: 474615

URL: http://svn.apache.org/viewvc?view=rev&rev=474615
Log:
Remove almost all old TypeSafe enums and replaced them by enum.
It still don't compile, because of ProducersTypeEnum.

Removed:
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/Enum.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/EnumUtils.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/ValuedEnum.java
Modified:
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ScopeEnum.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
Mon Nov 13 16:55:34 2006
@@ -600,15 +600,15 @@
         switch ( searchRequest.getScope() )
         {
             case LdapConstants.SCOPE_BASE_OBJECT:
-                snickersMessage.setScope( ScopeEnum.BASEOBJECT );
+                snickersMessage.setScope( ScopeEnum.BASE_OBJECT );
                 break;
 
             case LdapConstants.SCOPE_SINGLE_LEVEL:
-                snickersMessage.setScope( ScopeEnum.SINGLELEVEL );
+                snickersMessage.setScope( ScopeEnum.SINGLE_LEVEL );
                 break;
 
             case LdapConstants.SCOPE_WHOLE_SUBTREE:
-                snickersMessage.setScope( ScopeEnum.WHOLESUBTREE );
+                snickersMessage.setScope( ScopeEnum.WHOLE_SUBTREE );
                 break;
         }
 

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResultCodeEnum.java
Mon Nov 13 16:55:34 2006
@@ -659,7 +659,7 @@
 
     // -- 81-90 reserved for APIs --
 
-	private int resultCode;
+	private int value;
 	
 	public static final Set<ResultCodeEnum> EMPTY_RESULT_CODE_SET = new HashSet<ResultCodeEnum>();
 	
@@ -1471,12 +1471,12 @@
      * Private construct so no other instances can be created other than the
      * public static constants in this class.
      * 
-     * @param resultCode
+     * @param value
      *            the integer value of the enumeration.
      */
-    private ResultCodeEnum( int resultCode )
+    private ResultCodeEnum( int value )
     {
-    	this.resultCode = resultCode;
+    	this.value = value;
     }
     
     /**
@@ -1484,7 +1484,109 @@
      */
     public int getResultCode()
     {
-    	return resultCode;
+    	return value;
+    }
+    
+    /**
+     * @return The integer associated with the result code
+     */
+    public static ResultCodeEnum getResultCode( int value )
+    {
+        switch ( value )
+        {
+            case 0 : return SUCCESS;
+            case 1 : return OPERATIONS_ERROR;
+            case 2 : return PROTOCOL_ERROR;
+            case 3 : return TIME_LIMIT_EXCEEDED;
+            case 4 : return SIZE_LIMIT_EXCEEDED;
+            case 5 : return COMPARE_FALSE;
+            case 6 : return COMPARE_TRUE;
+            case 7 : return AUTH_METHOD_NOT_SUPPORTED;
+            case 8 : return STRONG_AUTH_REQUIRED;
+            case 9 : return PARTIAL_RESULTS;
+            case 10 : return REFERRAL;
+            case 11 : return ADMIN_LIMIT_EXCEEDED;
+            case 12 : return UNAVAILABLE_CRITICAL_EXTENSION;
+            case 13 : return CONFIDENTIALITY_REQUIRED;
+            case 14 : return SASL_BIND_IN_PROGRESS;
+            case 15 : return null;
+            case 16 : return NO_SUCH_ATTRIBUTE;
+            case 17 : return UNDEFINED_ATTRIBUTE_TYPE;
+            case 18 : return INAPPROPRIATE_MATCHING;
+            case 19 : return CONSTRAINT_VIOLATION;
+            case 20 : return ATTRIBUTE_OR_VALUE_EXISTS;
+            case 21 : return INVALID_ATTRIBUTE_SYNTAX;
+            case 22 : return null;
+            case 23 : return null;
+            case 24 : return null;
+            case 25 : return null;
+            case 26 : return null;
+            case 27 : return null;
+            case 28 : return null;
+            case 29 : return null;
+            case 30 : return null;
+            case 31 : return null;
+            case 32 : return NO_SUCH_OBJECT;
+            case 33 : return ALIAS_PROBLEM;
+            case 34 : return INVALID_DN_SYNTAX;
+            case 35 : return null;
+            case 36 : return ALIAS_DEREFERENCING_PROBLEM;
+            case 37 : return null;
+            case 38 : return null;
+            case 39 : return null;
+            case 40 : return null;
+            case 41 : return null;
+            case 42 : return null;
+            case 43 : return null;
+            case 44 : return null;
+            case 45 : return null;
+            case 46 : return null;
+            case 47 : return null;
+            case 48 : return INAPPROPRIATE_AUTHENTICATION; 
+            case 49 : return INVALID_CREDENTIALS;
+            case 50 : return INSUFFICIENT_ACCESS_RIGHTS;
+            case 51 : return BUSY;
+            case 52 : return UNAVAILABLE;
+            case 53 : return UNWILLING_TO_PERFORM;
+            case 54 : return LOOP_DETECT;
+            case 55 : return null;
+            case 56 : return null;
+            case 57 : return null;
+            case 58 : return null;
+            case 59 : return null;
+            case 60 : return null;
+            case 61 : return null;
+            case 62 : return null;
+            case 63 : return null;
+            case 64 : return NAMING_VIOLATION;
+            case 65 : return OBJECT_CLASS_VIOLATION;
+            case 66 : return NOT_ALLOWED_ON_NON_LEAF;
+            case 67 : return NOT_ALLOWED_ON_RDN;
+            case 68 : return ENTRY_ALREADY_EXISTS;
+            case 69 : return OBJECT_CLASS_MODS_PROHIBITED;
+            case 70 : return null;
+            case 71 : return AFFECTS_MULTIPLE_DSAS;
+            case 72 : return null;
+            case 73 : return null;
+            case 74 : return null;
+            case 75 : return null;
+            case 76 : return null;
+            case 77 : return null;
+            case 78 : return null;
+            case 79 : return null;
+            case 80 : return OTHER;
+            case 81 : return null;
+            case 82 : return null;
+            case 83 : return null;
+            case 84 : return null;
+            case 85 : return null;
+            case 86 : return null;
+            case 87 : return null;
+            case 88 : return null;
+            case 89 : return null;
+            case 90 : return null;
+            default : return null;
+        }
     }
     
 

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ScopeEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ScopeEnum.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ScopeEnum.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/message/ScopeEnum.java
Mon Nov 13 16:55:34 2006
@@ -22,59 +22,35 @@
 
 import javax.naming.directory.SearchControls;
 
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
-
 /**
  * Type-safe scope parameter enumeration.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
  */
-public class ScopeEnum extends ValuedEnum
+public enum ScopeEnum
 {
-    static final long serialVersionUID = 6354503944147675151L;
-
     /** Search scope parameter value for base object search */
-    public static final int BASEOBJECT_VAL = SearchControls.OBJECT_SCOPE;
+    BASE_OBJECT( SearchControls.OBJECT_SCOPE ),
 
     /** Search scope parameter value for single level search */
-    public static final int SINGLELEVEL_VAL = SearchControls.ONELEVEL_SCOPE;
+    SINGLE_LEVEL( SearchControls.ONELEVEL_SCOPE ),
 
     /** Search scope parameter value for whole subtree level search */
-    public static final int WHOLESUBTREE_VAL = SearchControls.SUBTREE_SCOPE;
-
-    /** LDAP search scope parameter value for base object search */
-    public static final int BASEOBJECT_LDAPVAL = 0;
-
-    /** LDAP search scope parameter value for single level search */
-    public static final int SINGLELEVEL_LDAPVAL = 1;
-
-    /** LDAP search scope parameter value for whole subtree level search */
-    public static final int WHOLESUBTREE_LDAPVAL = 2;
-
-    /** Search scope parameter enum for base object search */
-    public static final ScopeEnum BASEOBJECT = new ScopeEnum( "BASEOBJECT", BASEOBJECT_VAL
);
-
-    /** Search scope parameter enum for single level search */
-    public static final ScopeEnum SINGLELEVEL = new ScopeEnum( "SINGLELEVEL", SINGLELEVEL_VAL
);
-
-    /** Search scope parameter enum for whole subtree level search */
-    public static final ScopeEnum WHOLESUBTREE = new ScopeEnum( "WHOLESUBTREE", WHOLESUBTREE_VAL
);
+    WHOLE_SUBTREE( SearchControls.SUBTREE_SCOPE );
 
+    private int value;
 
     /**
      * Private construct so no other instances can be created other than the
      * public static constants in this class.
      * 
-     * @param a_name
-     *            a string name for the enumeration value.
-     * @param a_value
+     * @param value
      *            the integer value of the enumeration.
      */
-    private ScopeEnum(final String a_name, final int a_value)
+    private ScopeEnum( int value )
     {
-        super( a_name, a_value );
+        this.value = value;
     }
 
 
@@ -82,23 +58,26 @@
      * Gets the type safe enumeration constant corresponding to a SearchControls
      * scope value.
      * 
-     * @param a_controls
+     * @param controls
      *            the SearchControls whose scope value we convert to enum
      * @return the SopeEnum for the scope int value
      */
-    public static ScopeEnum getScope( SearchControls a_controls )
+    public static ScopeEnum getScope( SearchControls controls )
     {
-        switch ( a_controls.getSearchScope() )
+        switch ( controls.getSearchScope() )
         {
             case ( SearchControls.OBJECT_SCOPE  ):
-                return BASEOBJECT;
+                return BASE_OBJECT;
+            
             case ( SearchControls.ONELEVEL_SCOPE  ):
-                return SINGLELEVEL;
+                return SINGLE_LEVEL;
+            
             case ( SearchControls.SUBTREE_SCOPE  ):
-                return WHOLESUBTREE;
+                return WHOLE_SUBTREE;
+            
             default:
                 throw new IllegalArgumentException( "Unrecognized search scope in SearchControls:
"
-                    + a_controls.getSearchScope() );
+                    + controls.getSearchScope() );
         }
     }
 
@@ -110,18 +89,8 @@
      * @return the LDAP enumeration value for the scope parameter on a search
      *         request.
      */
-    public int getLdapValue()
+    public int getValue()
     {
-        switch ( getValue() )
-        {
-            case ( BASEOBJECT_VAL ):
-                return BASEOBJECT_LDAPVAL;
-            case ( SINGLELEVEL_VAL ):
-                return SINGLELEVEL_LDAPVAL;
-            case ( WHOLESUBTREE_VAL ):
-                return WHOLESUBTREE_LDAPVAL;
-            default:
-                throw new IllegalArgumentException( "Unrecognized value: " + getValue() );
-        }
+        return value;
     }
 }

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
Mon Nov 13 16:55:34 2006
@@ -46,7 +46,7 @@
     private boolean canUserModify = true;
 
     /** the usage for this attributeType */
-    private UsageEnum usage = UsageEnum.USERAPPLICATIONS;
+    private UsageEnum usage = UsageEnum.USER_APPLICATIONS;
 
     /** the length of this attribute in bytes */
     private int length = -1;

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
Mon Nov 13 16:55:34 2006
@@ -143,7 +143,7 @@
         }
 
         buf.append( "USAGE " );
-        buf.append( attributeType.getUsage().getName() );
+        buf.append( attributeType.getUsage() );
         buf.append( " ) " );
 
         return buf.toString();
@@ -515,7 +515,7 @@
 
         if ( objectClass.getType() != null )
         {
-            buf.append( objectClass.getType().getName() );
+            buf.append( objectClass.getType() );
             buf.append( '\n' );
         }
 

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleEnum.java
Mon Nov 13 16:55:34 2006
@@ -23,10 +23,6 @@
 import java.util.Map;
 import java.util.List;
 
-import org.apache.directory.shared.ldap.util.EnumUtils;
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
-
 /**
  * Type safe enum for a matching rule's comparator and normalizer component
  * usage string. This can be take one of the following three values:
@@ -39,41 +35,29 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class MatchingRuleEnum extends ValuedEnum
+public enum MatchingRuleEnum
 {
-    static final long serialVersionUID = 5500272648097676014L;
-
     /** value for ordering usage */
-    public static final int ORDERING_VAL = 0;
+    ORDERING( 0 ),
 
     /** value for equality usage */
-    public static final int EQUALITY_VAL = 1;
+    EQUALITY( 1 ),
 
     /** value for substring usage */
-    public static final int SUBSTRING_VAL = 2;
-
-    /** enum for ordering comparator usage */
-    public static final MatchingRuleEnum ORDERING = new MatchingRuleEnum( "ORDERING", ORDERING_VAL
);
-
-    /** enum for equality comparator usage */
-    public static final MatchingRuleEnum EQUALITY = new MatchingRuleEnum( "EQUALITY", EQUALITY_VAL
);
-
-    /** enum for substring comparator usage */
-    public static final MatchingRuleEnum SUBSTRING = new MatchingRuleEnum( "SUBSTRING", SUBSTRING_VAL
);
-
+    SUBSTRING( 2 );
 
+    private int value;
+    
     /**
      * Private constructor so no other instances can be created other than the
      * public static constants in this class.
      * 
-     * @param name
-     *            a string name for the enumeration value.
      * @param value
      *            the integer value of the enumeration.
      */
-    private MatchingRuleEnum(final String name, final int value)
+    private MatchingRuleEnum( int value )
     {
-        super( name, value );
+       this.value = value;
     }
 
 
@@ -86,44 +70,6 @@
      */
     public static MatchingRuleEnum getUsage( String usage )
     {
-        if ( usage.equalsIgnoreCase( MatchingRuleEnum.valueOf( EQUALITY ) ) );
-        {
-            return MatchingRuleEnum.EQUALITY;
-        }
-
-        if ( usage.equalsIgnoreCase( MatchingRuleEnum.ORDERING.getName() ) )
-        {
-            return MatchingRuleEnum.ORDERING;
-        }
-
-        if ( usage.equalsIgnoreCase( MatchingRuleEnum.SUBSTRING.getName() ) )
-        {
-            return MatchingRuleEnum.SUBSTRING;
-        }
-
-        throw new IllegalArgumentException( "Unknown matching rule usage string" + usage
);
-    }
-
-
-    /**
-     * Gets a List of the enumerations for matching rule usage.
-     * 
-     * @return the List of enumerations possible for matching rule usage
-     */
-    public static List list()
-    {
-        return EnumUtils.getEnumList( MatchingRuleEnum.class );
-    }
-
-
-    /**
-     * Gets the Map of MatchingRuleEnum objects by name using the
-     * MatchingRuleEnum class.
-     * 
-     * @return the Map by name of MatchingRuleEnums
-     */
-    public static Map map()
-    {
-        return EnumUtils.getEnumMap( MatchingRuleEnum.class );
+        return valueOf( usage );
     }
 }

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClassTypeEnum.java
Mon Nov 13 16:55:34 2006
@@ -23,10 +23,6 @@
 import java.util.Map;
 import java.util.List;
 
-import org.apache.directory.shared.ldap.util.EnumUtils;
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
-
 /**
  * Type safe enumerations for an objectClass' type. An ObjectClass type can be
  * one of the following types:
@@ -39,29 +35,19 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ObjectClassTypeEnum extends ValuedEnum
+public enum ObjectClassTypeEnum
 {
-    static final long serialVersionUID = -5916723482518366208L;
-
     /** The enumeration constant value for the abstract objectClasses */
-    public static final int ABSTRACT_VAL = 0;
+    ABSTRACT( 0 ),
 
     /** The enumeration constant value for the auxillary objectClasses */
-    public static final int AUXILLARY_VAL = 1;
+    AUXILIARY( 1 ),
 
     /** The enumeration constant value for the structural objectClasses */
-    public static final int STRUCTURAL_VAL = 2;
-
-    /** ValuedEnum for abstract objectClasses */
-    public static final ObjectClassTypeEnum ABSTRACT = new ObjectClassTypeEnum( "ABSTRACT",
ABSTRACT_VAL );
-
-    /** ValuedEnum for auxillary objectClasses */
-    public static final ObjectClassTypeEnum AUXILIARY = new ObjectClassTypeEnum( "AUXILIARY",
AUXILLARY_VAL );
-
-    /** ValuedEnum for structural objectClasses */
-    public static final ObjectClassTypeEnum STRUCTURAL = new ObjectClassTypeEnum( "STRUCTURAL",
STRUCTURAL_VAL );
-
+    STRUCTURAL( 2 );
 
+    private int value;
+    
     /**
      * Private constructor so no other instances can be created other than the
      * public static constants in this class.
@@ -71,9 +57,9 @@
      * @param value
      *            the integer value of the enumeration.
      */
-    private ObjectClassTypeEnum(final String name, final int value)
+    private ObjectClassTypeEnum( int value )
     {
-        super( name, value );
+        this.value = value;
     }
 
 
@@ -104,28 +90,5 @@
 
         throw new IllegalArgumentException( "Unknown objectClass type name '" + name
             + "': options are AUXILIARY, STRUCTURAL, ABSTRACT." );
-    }
-
-
-    /**
-     * Gets a List of the enumerations for the ObjectClass type.
-     * 
-     * @return the List of enumerations possible for ObjectClass types
-     */
-    public static List list()
-    {
-        return EnumUtils.getEnumList( ObjectClassTypeEnum.class );
-    }
-
-
-    /**
-     * Gets the Map of ClassTypeEnum objects by name using the ClassTypeEnum
-     * class.
-     * 
-     * @return the Map by name of ClassTypeEnums
-     */
-    public static Map map()
-    {
-        return EnumUtils.getEnumMap( ObjectClassTypeEnum.class );
     }
 }

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
Mon Nov 13 16:55:34 2006
@@ -273,7 +273,7 @@
 
         if ( oc.getType() != null )
         {
-            buf.append( " " ).append( oc.getType().getName() );
+            buf.append( " " ).append( oc.getType() );
         }
 
         if ( oc.getMustList() != null && oc.getMustList().length > 0 )
@@ -418,7 +418,7 @@
 
         if ( at.getUsage() != null )
         {
-            buf.append( " USAGE " ).append( at.getUsage().getName() );
+            buf.append( " USAGE " ).append( at.getUsage() );
         }
 
         // @todo extensions are not presently supported and skipped

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java?view=diff&rev=474615&r1=474614&r2=474615
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
Mon Nov 13 16:55:34 2006
@@ -23,10 +23,6 @@
 import java.util.Map;
 import java.util.List;
 
-import org.apache.directory.shared.ldap.util.EnumUtils;
-import org.apache.directory.shared.ldap.util.ValuedEnum;
-
-
 /**
  * Type safe enum for an AttributeType definition's usage string. This can be
  * take one of the following four values:
@@ -40,35 +36,21 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class UsageEnum extends ValuedEnum
+public enum UsageEnum
 {
-    static final long serialVersionUID = -5838426429165435227L;
-
     /** value for attributes with userApplications usage */
-    public static final int USERAPPLICATIONS_VAL = 0;
+    USER_APPLICATIONS( 0 ),
 
     /** value for attributes with directoryOperation usage */
-    public static final int DIRECTORYOPERATION_VAL = 1;
+    DIRECTORY_OPERATION( 1 ),
 
     /** value for attributes with distributedOperation usage */
-    public static final int DISTRIBUTEDOPERATION_VAL = 2;
+    DISTRIBUTED_OPERATION( 2 ),
 
     /** value for attributes with dSAOperation usage */
-    public static final int DSAOPERATION_VAL = 3;
-
-    /** enum for attributes with userApplications usage */
-    public static final UsageEnum USERAPPLICATIONS = new UsageEnum( "userApplications", USERAPPLICATIONS_VAL
);
-
-    /** enum for attributes with directoryOperation usage */
-    public static final UsageEnum DIRECTORYOPERATION = new UsageEnum( "directoryOperation",
DIRECTORYOPERATION_VAL );
-
-    /** enum for attributes with distributedOperation usage */
-    public static final UsageEnum DISTRIBUTEDOPERATION = new UsageEnum( "distributedOperation",
-        DISTRIBUTEDOPERATION_VAL );
-
-    /** enum for attributes with dSAOperation usage */
-    public static final UsageEnum DSAOPERATION = new UsageEnum( "dSAOperation", DSAOPERATION_VAL
);
+    DS_AOPERATION( 3 );
 
+    private int usage;
 
     /**
      * Private construct so no other instances can be created other than the
@@ -79,9 +61,9 @@
      * @param value
      *            the integer value of the enumeration.
      */
-    private UsageEnum(final String name, final int value)
+    private UsageEnum( int usage )
     {
-        super( name, value );
+        this.usage = usage;
     }
 
 
@@ -95,48 +77,6 @@
      */
     public static UsageEnum getUsage( String usage )
     {
-        if ( usage.equalsIgnoreCase( UsageEnum.USERAPPLICATIONS.getName() ) )
-        {
-            return UsageEnum.USERAPPLICATIONS;
-        }
-
-        if ( usage.equalsIgnoreCase( UsageEnum.DIRECTORYOPERATION.getName() ) )
-        {
-            return UsageEnum.DIRECTORYOPERATION;
-        }
-
-        if ( usage.equalsIgnoreCase( UsageEnum.DISTRIBUTEDOPERATION.getName() ) )
-        {
-            return UsageEnum.DISTRIBUTEDOPERATION;
-        }
-
-        if ( usage.equalsIgnoreCase( UsageEnum.DSAOPERATION.getName() ) )
-        {
-            return UsageEnum.DSAOPERATION;
-        }
-
-        throw new IllegalArgumentException( "Unknown attributeType usage string" + usage
);
-    }
-
-
-    /**
-     * Gets a List of the enumerations for attributeType usage.
-     * 
-     * @return the List of enumerations possible for usage
-     */
-    public static List list()
-    {
-        return EnumUtils.getEnumList( UsageEnum.class );
-    }
-
-
-    /**
-     * Gets the Map of UsageEnum objects by name using the UsageEnum class.
-     * 
-     * @return the Map by name of UsageEnums
-     */
-    public static Map map()
-    {
-        return EnumUtils.getEnumMap( UsageEnum.class );
+        return valueOf( usage );
     }
 }



Mime
View raw message