directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r476873 - in /directory/trunks/shared/ldap: ./ src/main/java/org/apache/directory/shared/ldap/schema/
Date Sun, 19 Nov 2006 18:38:02 GMT
Author: elecharny
Date: Sun Nov 19 10:38:02 2006
New Revision: 476873

URL: http://svn.apache.org/viewvc?view=rev&rev=476873
Log:
Changed the UsageTypeEnum to become an enum instead of an subclass
of ValuedEnum (Java 5 migration)

Modified:
    directory/trunks/shared/ldap/pom.xml
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java

Modified: directory/trunks/shared/ldap/pom.xml
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/pom.xml?view=diff&rev=476873&r1=476872&r2=476873
==============================================================================
--- directory/trunks/shared/ldap/pom.xml (original)
+++ directory/trunks/shared/ldap/pom.xml Sun Nov 19 10:38:02 2006
@@ -131,8 +131,8 @@
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <source>1.4</source>
-          <target>1.4</target>
+          <source>1.5</source>
+          <target>1.5</target>
           <debug>true</debug>
           <optimize>true</optimize>
           <showDeprecations>true</showDeprecations>

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java?view=diff&rev=476873&r1=476872&r2=476873
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractAttributeType.java
Sun Nov 19 10:38:02 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/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java?view=diff&rev=476873&r1=476872&r2=476873
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DescriptionUtils.java
Sun Nov 19 10:38:02 2006
@@ -143,7 +143,7 @@
         }
 
         buf.append( "USAGE " );
-        buf.append( attributeType.getUsage().getName() );
+        buf.append( attributeType.getUsage() );
         buf.append( " ) " );
 
         return buf.toString();

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java?view=diff&rev=476873&r1=476872&r2=476873
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
Sun Nov 19 10:38:02 2006
@@ -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/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java?view=diff&rev=476873&r1=476872&r2=476873
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema/UsageEnum.java
Sun Nov 19 10:38:02 2006
@@ -20,13 +20,6 @@
 package org.apache.directory.shared.ldap.schema;
 
 
-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 +33,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
);
+    DSA_OPERATION( 3 );
 
+    private int value;
 
     /**
      * Private construct so no other instances can be created other than the
@@ -79,9 +58,9 @@
      * @param value
      *            the integer value of the enumeration.
      */
-    private UsageEnum(final String name, final int value)
+    private UsageEnum( int value )
     {
-        super( name, value );
+        this.value = value;
     }
 
 
@@ -95,48 +74,34 @@
      */
     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 );
+    	if ( "directoryOperation".equals( usage ) )
+    	{
+    		return DIRECTORY_OPERATION;
+    	}
+    	else if ( "distributedOperation".equals( usage ) )
+    	{
+    		return DISTRIBUTED_OPERATION;
+    	}
+    	else if ( "dsaOperation".equals( usage ) )
+    	{
+    		return DSA_OPERATION;	
+    	}
+    	else if ( "userApplications".equals( usage ) ) 
+    	{
+    		return USER_APPLICATIONS;
+    	}
+    	else 
+    	{
+    		return null;
+    	}
     }
-
-
+    
     /**
-     * Gets the Map of UsageEnum objects by name using the UsageEnum class.
      * 
-     * @return the Map by name of UsageEnums
+     * @return The value associated with the current element.
      */
-    public static Map map()
+    public int getValue()
     {
-        return EnumUtils.getEnumMap( UsageEnum.class );
+    	return value;
     }
 }



Mime
View raw message