directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r718193 - in /directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm: NameClassPair.java SourceGenerator.java
Date Mon, 17 Nov 2008 08:52:28 GMT
Author: kayyagari
Date: Mon Nov 17 00:52:28 2008
New Revision: 718193

URL: http://svn.apache.org/viewvc?rev=718193&view=rev
Log:
added a new falg to identify multivalued attributes during code generation

Modified:
    directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/NameClassPair.java
    directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/SourceGenerator.java

Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/NameClassPair.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/NameClassPair.java?rev=718193&r1=718192&r2=718193&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/NameClassPair.java
(original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/NameClassPair.java
Mon Nov 17 00:52:28 2008
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.olm;
 
+
 /**
  * 
  * A simple pojo internally used while gerating the source code.
@@ -31,66 +32,84 @@
     private String name;
     private String className;
     private String javaType;
-    
+    private boolean multiValued = false;
+
+
     public NameClassPair( String name, String className, String javaType )
     {
-        if( name == null || className == null || javaType == null )
+        if ( name == null || className == null || javaType == null )
         {
             throw new IllegalArgumentException( "Null value cannot be accepted" );
         }
-        
+
         this.name = name;
         this.className = className;
         this.javaType = javaType;
     }
 
+
     public String getName()
     {
         return name;
     }
 
+
     public String getClassName()
     {
         return className;
     }
 
-    
+
     public String getJavaType()
     {
         return javaType;
     }
 
+
     public String getClassSimpleName()
     {
         return className.substring( className.lastIndexOf( '.' ) + 1 );
     }
-    
-    
+
+
+    public boolean isMultiValued()
+    {
+        return multiValued;
+    }
+
+
+    public void setMultiValued( boolean isMultiValued )
+    {
+        this.multiValued = isMultiValued;
+    }
+
+
     public int compareTo( Object o )
     {
         NameClassPair that = ( NameClassPair ) o;
-        
+
         return getName().compareTo( that.getName() );
     }
 
-    
+
     @Override
     public boolean equals( Object obj )
     {
         return getName().equals( ( ( NameClassPair ) obj ).getName() );
     }
 
+
     @Override
     public int hashCode()
     {
         return name.hashCode();
     }
 
+
     @Override
     public String toString()
     {
         return name + "=" + className;
     }
-    
-    
+
 }

Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/SourceGenerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/SourceGenerator.java?rev=718193&r1=718192&r2=718193&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/SourceGenerator.java
(original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/java/org/apache/directory/olm/SourceGenerator.java
Mon Nov 17 00:52:28 2008
@@ -189,26 +189,17 @@
         {
             if ( attrLiteral.getEquality() == null )
             {
-                LOG.debug( "Equality is null for " + attrLiteral.getNames()[0] + " ordering
is : "
+                LOG.info( "Equality is null for " + attrLiteral.getNames()[0] + " ordering
is : "
                     + attrLiteral.getOrdering() );
 
-                LOG.debug( "and substr is : " + attrLiteral.getSubstr() + "\n\n" );
+                LOG.info( "and substr is : " + attrLiteral.getSubstr() + "\n\n" );
             }
 
-            if ( attrLiteral.getOid().equals( "2.5.4.45" ) )
-            {
-                System.out.println( "breakpoint" );
-            }
             generateAttributeSource( attrLiteral );
         }
 
         for ( ObjectClassLiteral objClass : objClassLiterals )
         {
-            if ( objClass.getOid().equals( "2.16.840.1.113730.3.2.2" ) )
-            {
-                System.out.println( "breakpoint" );
-            }
-
             generateObjectClassSource( objClass );
         }
 
@@ -288,18 +279,22 @@
 
         for ( String s : mustAttrs )
         {
-            mustAttrNameClassSet.add( new NameClassPair( s.replace( "-", "_" ), attrNameToClassNameMap.get(
s.toLowerCase() ),
-                attrNameToJavaTypeMap.get( s.toLowerCase() ) ) );
+            NameClassPair ncp = new NameClassPair( s.replace( "-", "_" ), attrNameToClassNameMap.get(
s.toLowerCase() ),
+                attrNameToJavaTypeMap.get( s.toLowerCase() ) );
+            
+            ncp.setMultiValued( ! getAttribute( s ).isSingleValue() );
+            mustAttrNameClassSet.add( ncp );
         }
 
         for ( String s : mayAttrs )
         {
             //TODO remove this debug statement
             LOG.debug( s + ": " + attrNameToClassNameMap.get( s.toLowerCase() ) );
-            NameClassPair np = new NameClassPair( s.replace( "-", "_" ), attrNameToClassNameMap.get(
s.toLowerCase() ),
+            NameClassPair ncp = new NameClassPair( s.replace( "-", "_" ), attrNameToClassNameMap.get(
s.toLowerCase() ),
                 attrNameToJavaTypeMap.get( s.toLowerCase() ) );
 
-            mayAttrNameClassSet.add( np );
+            ncp.setMultiValued( ! getAttribute( s ).isSingleValue() );
+            mayAttrNameClassSet.add( ncp );
         }
 
         List<NameClassPair> allAttrList = new ArrayList<NameClassPair>();
@@ -426,21 +421,21 @@
 
     /**
      * 
-     * gets the superior attribute with the given name.
+     * gets the attribute with the given name.
      *
-     * @param supAttrName name of the attribute
+     * @param attrName name of the attribute
      * @return an <i>AttributeTypeLiteral</i> with the given name, null if not
found
      */
-    private AttributeTypeLiteral getSupAttribute( String supAttrName )
+    private AttributeTypeLiteral getAttribute( String attrName )
     {
-        LOG.debug( "getting the SUP with name " + supAttrName );
+        LOG.debug( "getting the SUP with name " + attrName );
 
         for ( AttributeTypeLiteral attrLiteral : attrLiterals )
         {
             String[] names = attrLiteral.getNames();
             for ( String name : names )
             {
-                if ( supAttrName.equals( name ) )
+                if ( attrName.equalsIgnoreCase( name ) )
                 {
                     return attrLiteral;
                 }
@@ -462,7 +457,7 @@
     {
         if ( attrLiteral.getSuperior() != null )
         {
-            generateAttributeSource( getSupAttribute( attrLiteral.getSuperior() ) );
+            generateAttributeSource( getAttribute( attrLiteral.getSuperior() ) );
         }
 
         for ( String name : attrLiteral.getNames() )
@@ -534,7 +529,7 @@
 
         if ( superior != null )
         {
-            AttributeTypeLiteral superiorAttr = getSupAttribute( superior );
+            AttributeTypeLiteral superiorAttr = getAttribute( superior );
             if ( superiorAttr.getSyntax() != null )
             {
                 syntax = superiorAttr.getSyntax();



Mime
View raw message