directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r718189 - in /directory/sandbox/kayyagari/apacheds-olm/src/main/resources: AttributeClass.st ObjectClass.st
Date Mon, 17 Nov 2008 08:47:51 GMT
Author: kayyagari
Date: Mon Nov 17 00:47:50 2008
New Revision: 718189

URL: http://svn.apache.org/viewvc?rev=718189&view=rev
Log:
o used generics for multi valued attributes
o modified templates to fit to the newly defined XXXAttribute interfaces

Modified:
    directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st
    directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st

Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st?rev=718189&r1=718188&r2=718189&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st (original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st Mon Nov
17 00:47:50 2008
@@ -19,22 +19,26 @@
  */!$
 package $package$;
 
+$if(!singleValue)$
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
+$endif$
 
-public class $className$ implements Attribute
+public class $className$ implements $if(singleValue)$ SingleValueAttribute $else$ MultiValueAttribute
$endif$
 {
 
     // if no syntax is defined or inherited then the default argument type will be java.lang.String
 
+    $if(singleValue)$
     private $argType$ $paramName$;
-    
+    $else$
     private Set<$argType$> _attrValues;
+    $endif$
     
     public static final String OID = "$oid$";
     
-    public static final String ATTRIBUTE_NAME = "$paramName$";
+    public static final String NAME = "$paramName$";
         
     public $className$() {}
     
@@ -43,15 +47,28 @@
     * Creates a new instance of with the MUST fields.
     *
     */
+   $if(singleValue)$
     public $className$( $argType$ $paramName$ )
     {
-        $if(singleValue)$
         setValue( $paramName$ );
-        $else$
-        this.$paramName$ = $paramName$;
-        addValue( this.$paramName$ );
-        $endif$
     }
+    $else$
+    public $className$( $argType$... $paramName$ )
+    {
+      Set<$argType$> values = new HashSet<$argType$>();
+      
+      for ( $argType$ arg : $paramName$ )
+      {
+         if( arg == null )
+         {
+            throw new IllegalArgumentException( "Attribute value cannot be null" );
+         }
+         values.add( arg );
+      }
+      
+      setValues( values );
+    }
+   $endif$
     
     
     $if(singleValue)$
@@ -65,17 +82,18 @@
        this.$paramName$ = $paramName$;
     }
     
-    
-    $!public $argType$ get$mArgName$()
+    public $argType$ getValue()
     {
-       return $paramName$; 
-    }!$
+        return $paramName$;
+    }
     $else$
-    public void setValues( Set<$argType$> _attrValues )
+    $! cannot use Set<$argType$> here cause the compiler complains about 
+     name class due to generics erasure in inerface method setValues( Set values )!$
+    public void setValues( Set _attrValues )
     {
-       if( _attrValues == null )
+       if( _attrValues == null || _attrValues.isEmpty() )
        {
-          throw new IllegalArgumentException( "Attribute values cannot be null" );
+          throw new IllegalArgumentException( "Attribute values cannot be null or of zero
size" );
        }
        
        this._attrValues = _attrValues;
@@ -96,10 +114,21 @@
        _attrValues.add( $paramName$ );
        
        // for enabling the field interception
-       Set set = new HashSet<java.lang.String>();
+       Set set = new HashSet<$argType$>();
        set.addAll( _attrValues );
        _attrValues = set;
     }
+    
+    
+    public Iterator<$argType$> getValues()
+    {
+        if( _attrValues == null )
+        {
+           return null;
+        }
+        
+        return _attrValues.iterator();
+    }
     $endif$
     
     public boolean isObsolete()
@@ -134,7 +163,7 @@
     
     public String getName()
     {
-        return ATTRIBUTE_NAME;
+        return NAME;
     }
         
     
@@ -148,26 +177,9 @@
     }
     
     
-    public Class getJavaType()
+    public Class<$argType$> getJavaType()
     {
        return $argType$.class;
     }
     
-    
-    public $argType$ getValue()
-    {
-        return $paramName$;
-    }
-    
-    
-    public Iterator<$argType$> getValues()
-    {
-        if( _attrValues == null )
-        {
-           return null;
-        }
-        
-        return _attrValues.iterator();
-    }
-    
 }

Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st?rev=718189&r1=718188&r2=718189&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st (original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st Mon Nov 17
00:47:50 2008
@@ -45,7 +45,7 @@
 
    public static final String OID = "$oid$";
 
-   public static final String OBJCLASS_NAME = "$objClassName$";
+   public static final String NAME = "$objClassName$";
    
    public $className$() { }
     
@@ -57,7 +57,7 @@
    $endif$
 
    
-  $allAttrs: { attr | public void set$attr.classSimpleName$( $attr.javaType$ $attr.name$
)
+  $allAttrs: { attr | public void set$attr.classSimpleName$( $attr.javaType$$if(attr.multiValued)$...$endif$
$attr.name$ )
    {
       if( $attr.name$ == null )
       {
@@ -78,7 +78,7 @@
    
    public String getName()
    {
-     return OBJCLASS_NAME;
+     return NAME;
    }
    
    



Mime
View raw message