directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r485956 - in /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/schema: DescriptionUtils.java SchemaUtils.java UsageEnum.java
Date Mon, 11 Dec 2006 23:58:52 GMT
Author: elecharny
Date: Mon Dec 11 15:58:51 2006
New Revision: 485956

URL: http://svn.apache.org/viewvc?view=rev&rev=485956
Log:
Added a method in UsageEnum to return a rendered string for USAGE. When someone ask for 
the AttributeTypeDescription, the USAGE value should be return as a lowercased string.

Modified accordingly the two places where this rendering is constructed.

Modified:
    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/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=485956&r1=485955&r2=485956
==============================================================================
--- 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
Mon Dec 11 15:58:51 2006
@@ -143,7 +143,7 @@
         }
 
         buf.append( "USAGE " );
-        buf.append( attributeType.getUsage() );
+        buf.append( UsageEnum.render( 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=485956&r1=485955&r2=485956
==============================================================================
--- 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
Mon Dec 11 15:58:51 2006
@@ -418,7 +418,7 @@
 
         if ( at.getUsage() != null )
         {
-            buf.append( " USAGE " ).append( at.getUsage() );
+            buf.append( " USAGE " ).append( UsageEnum.render( 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=485956&r1=485955&r2=485956
==============================================================================
--- 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
Mon Dec 11 15:58:51 2006
@@ -78,32 +78,52 @@
      */
     public static UsageEnum getUsage( String usage )
     {
-        UsageEnum result = valueOf( usage );
-        
-        if ( result != null )
+        try
         {
+            UsageEnum result = valueOf( usage );
+            
             return result;
         }
-        
-    	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;
-    	}
+        catch( IllegalArgumentException iae )
+        {
+        	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;
+        	}
+        }
+    }
+    
+    /**
+     * Get the string representation for UsageEnum, which will be
+     * used by the AttributeType rendering 
+     * @param usage The UsageEnum of which we want the rendering string
+     * @return The rendering stringe
+     */
+    public static String render( UsageEnum usage )
+    {
+        switch ( usage )
+        {
+            case DIRECTORY_OPERATION    : return "directoryOperation";
+            case DISTRIBUTED_OPERATION  : return "distributedOperation";
+            case DSA_OPERATION          : return "dsaOperation";
+            case USER_APPLICATIONS      : return "userApplications";
+            default : return "";
+        }
     }
 }



Mime
View raw message