You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/10/08 07:15:47 UTC

svn commit: rev 54047 - in incubator/directory/eve/trunk/backend/tools/src: java/org/apache/eve/tools/schema test/org/apache/eve/tools/schema

Author: akarasulu
Date: Thu Oct  7 22:15:47 2004
New Revision: 54047

Modified:
   incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypes.template
   incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java
Log:
template only needs setting names

Modified: incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypes.template
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypes.template	(original)
+++ incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypes.template	Thu Oct  7 22:15:47 2004
@@ -17,8 +17,17 @@
 package $package;
 
 
+import java.util.ArrayList;
+import javax.naming.NamingException;
+
 import org.apache.ldap.common.schema.*;
-//import org.apache.eve.schema.config.*;
+
+#if ( $package != "org.apache.eve.schema" )
+import org.apache.eve.schema.*;
+#end
+#if ( $package != "org.apache.eve.schema.config" )
+import org.apache.eve.schema.config.*;
+#end
 
 
 /**
@@ -80,70 +89,105 @@
     // ------------------------------------------------------------------------
 
 
-    public AttributeType[] load( AttributeTypeRegistry attrTypeReg,
-                                 MatchingRuleRegistry mruleReg )
+    public AttributeType[] load( SyntaxRegistry syntaxReg,
+                                 MatchingRuleRegistry mruleReg,
+                                 AttributeTypeRegistry attrTypeReg )
         throws NamingException
     {
-        String usage;
-        String mruleOid;
-        String superiorOid;
-        MatchingRule mrule;
-        AttributeType superior;
-        AttributeType[] attributeTypes = new AttributeType[$attrTypeCount];
+        MutableAttributeType[] attributeTypes = new MutableAttributeType[$attrTypeCount];
 
         #foreach ( $attrType in $attrTypes )
         #set ( $ii = $velocityCount - 1 )
-attributeTypes[$ii] = new MutableAttributeType( "$attrType.getOid()" );
+
+        // --------------------------------------------------------------------
+        // AttributeType $attrType.getOid()
+        // --------------------------------------------------------------------
+
+
+        attributeTypes[$ii] = new MutableAttributeType( "$attrType.getOid()" );
         attributeTypes[$ii].setSingleValue( $attrType.isSingleValue() );
         attributeTypes[$ii].setCollective( $attrType.isCollective() );
         attributeTypes[$ii].setObsolete( $attrType.isObsolete() );
         attributeTypes[$ii].setCanUserModify( $attrType.isCanUserModify() );
         attributeTypes[$ii].setLength( $attrType.getLength() );
+        attributeTypes[$ii].setUsage( UsageEnum.getUsage( "$attrType.getUsage().getName()" ) );
+#if ( $attrType.getSuperiorOid() )        attributeTypes[$ii].setSuperior( attrTypeReg.lookup( "$attrType.getSuperiorOid()" ) ); #end
+#if ( $attrType.getEqualityOid() )        attributeTypes[$ii].setEquality( mruleReg.lookup( "$attrType.getEqualityOid()" ) );#end
+#if ( $attrType.getSubstrOid() )        attributeTypes[$ii].setSubstr( mruleReg.lookup( "$attrType.getSubstrOid()" ) );#end
+#if ( $attrType.getOrderingOid() )        attributeTypes[$ii].setOrdering( mruleReg.lookup( "$attrType.getOrderingOid()" ) );#end
+#if ( $attrType.getSyntaxOid() )        attributeTypes[$ii].setSyntax( syntaxReg.lookup( "$attrType.getSyntaxOid()" ) );#end
+
+        #end
+
+        return attributeTypes;
+    }
+
 
-        // set the superior attribute type
-        superiorOid = "$!attrType.getSuperiorOid()";
-        if ( ! superiorOid.equals("") )
+    private static class MutableAttributeType extends BaseAttributeType
+    {
+        public MutableAttributeType( String oid )
         {
-            attributeTypes[$ii].setSuperior( attrTypeReg.lookup( superiorOid ) );
+            super( oid );
         }
 
-        // set usage enumeration value
-        usage = "$attrType.getUsage().getName()";
-        attributeTypes[$ii].setUsageEnum( UsageEnum.getUsageEnum( usage ) );
+        protected void setSuperior( AttributeType superior )
+        {
+            super.setSuperior( superior );
+        }
 
-        // set the equality matching rule
-        mruleOid = "$!attrType.getEqualityOid()";
-        if ( ! mruleOid.equals("") )
+        protected void setNameList( ArrayList nameList )
         {
-            attributeTypes[$ii].setEquality( mruleReg.lookup( mruleOid ) );
+            super.setNameList( nameList );
         }
 
-        // set the substr matching rule
-        mruleOid = "$!attrType.getSubstrOid()";
-        if ( ! mruleOid.equals("") )
+        protected void setEquality( MatchingRule equality )
         {
-            attributeTypes[$ii].setSubstr( mruleReg.lookup( mruleOid ) );
+            super.setEquality( equality );
         }
 
-        // set the ordering matching rule
-        mruleOid = "$!attrType.getOrderingOid()";
-        if ( ! mruleOid.equals("") )
+        protected void setSubstr( MatchingRule substr )
         {
-            attributeTypes[$ii].setOrdering( mruleReg.lookup( mruleOid ) );
+            super.setSubstr( substr );
         }
 
+        protected void setOrdering( MatchingRule ordering )
+        {
+            super.setOrdering( ordering );
+        }
 
-        #end
+        protected void setSyntax( Syntax syntax )
+        {
+            super.setSyntax( syntax );
+        }
 
-        return attributeTypes;
-    }
+        protected void setSingleValue( boolean singleValue )
+        {
+            super.setSingleValue( singleValue );
+        }
 
+        protected void setCollective( boolean collective )
+        {
+            super.setCollective( collective );
+        }
 
-    private static class MutableAttributeType extends BaseAttributeType
-    {
-        public MutableAttributeType( String oid )
+        protected void setCanUserModify( boolean canUserModify )
         {
-            super( oid );
+            super.setCanUserModify( canUserModify );
+        }
+
+        protected void setObsolete( boolean obsolete )
+        {
+            super.setObsolete( obsolete );
+        }
+
+        protected void setUsage( UsageEnum usage )
+        {
+            super.setUsage( usage );
+        }
+
+        protected void setLength( int length )
+        {
+            super.setLength( length );
         }
     }
 }

Modified: incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java	(original)
+++ incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypesTemplateTest.java	Thu Oct  7 22:15:47 2004
@@ -78,9 +78,37 @@
 
     public void testGeneration() throws Exception
     {
+        Syntax syntax = new Syntax(){
+            public boolean isHumanReadable()
+            {
+                return false;
+            }
+
+            public String getName()
+            {
+                return null;
+            }
+
+            public String getOid()
+            {
+                return "2.3.3.6";
+            }
+
+            public SyntaxChecker getSyntaxChecker()
+            {
+                return null;
+            }
+
+            public String getDescription()
+            {
+                return null;
+            }
+        };
+
         TestAttributeType[] attributeTypes = new TestAttributeType[2];
         attributeTypes[0] = new TestAttributeType( "1.1.1.1" );
-        attributeTypes[0].setUsage( UsageEnum.DIRECTORYOPERATION );
+        attributeTypes[0].setUsage( UsageEnum.USERAPPLICATIONS );
+        attributeTypes[0].setSyntax( syntax );
 
         attributeTypes[1] = new TestAttributeType( "1.1.1.2" );
         attributeTypes[1].setUsage( UsageEnum.DIRECTORYOPERATION );
@@ -190,6 +218,11 @@
         public String getEqualityOid()
         {
             return super.getEquality() != null ? super.getEquality().getOid() : null;
+        }
+
+        public String getSyntaxOid()
+        {
+            return super.getSyntax() != null ? super.getSyntax().getOid() : null;
         }
     }
 }