directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r713428 - /directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st
Date Wed, 12 Nov 2008 17:29:22 GMT
Author: kayyagari
Date: Wed Nov 12 09:29:19 2008
New Revision: 713428

URL: http://svn.apache.org/viewvc?rev=713428&view=rev
Log:
o added support for auxiliary entries and optional attributes
o modified the way null value is set for attribute
o using map instead of set for holding additional/DSA attributes


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

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=713428&r1=713427&r2=713428&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st (original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st Wed Nov 12
09:29:19 2008
@@ -22,10 +22,12 @@
 import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
 import java.util.Set;
 import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Collections;
 
-public $if(abstract)$ abstract $endif$ class $className$ implements Entry
+public $if(abstract)$ abstract $endif$ class $className$ implements $if(extensible)$ ExtensibleEntry
$else$ Entry $endif$
 {
 
    $allAttrs: { attr | private $attr.className$ $attr.name$;}; separator="\n\n"$
@@ -36,7 +38,7 @@
    private Set<Entry> additionalEntries;
    
    // contains the dSAOperation specific attributes
-   private Set<Attribute> opAttributes;
+   private Map<String,Attribute> opAttributes;
 
 
    private static final String[] SUPERIORS = { $superiorClassNames: { s | "$s$"}; separator=",
"$ };
@@ -53,12 +55,19 @@
        $mustAttrs: { attr | set$attr.classSimpleName$( $attr.name$ );}; separator="\n"$
    }
    $endif$
+
    
   $allAttrs: { attr | public void set$attr.classSimpleName$( $attr.javaType$ $attr.name$
)
    {
+      if( $attr.name$ == null )
+      {
+         this.$attr.name$ = null;
+         return;
+      }
+      
       this.$attr.name$ = new $attr.className$( $attr.name$ );
    }
-   
+
    
    public $attr.className$ get$attr.classSimpleName$()
    {
@@ -99,7 +108,7 @@
       
       if( opAttributes != null )
       {
-        for( Attribute attr : opAttributes )
+        for( Attribute attr : opAttributes.values() )
         {
            allAttrs.add( attr );
         }
@@ -152,8 +161,54 @@
        return null;
    }
    
+   $if(extensible)$
+   public Attribute getAttribute( String name )
+   {
+      return opAttributes.get( name.toLowerCase() );
+   }
+
+   public void removeAttribute( String name )
+   {
+       opAttributes.remove( name.toLowerCase() );
+   }
+   $else$
+   public Attribute getAttribute( String name )
+   {
+      Attribute attr = getAttribute( this, name );
+      
+      if( attr == null && additionalEntries != null )
+      {
+        for( Entry e : additionalEntries )
+        {
+          attr = getAttribute( e, name );
+          if( attr != null )
+          {
+            break;
+          }
+        }
+      }
+      
+      return attr;
+   }
+   
    
-   private void addAttribute( Attribute attr )
+   private Attribute getAttribute( Entry entry, String name )
+   {
+      Set<Attribute> attributes = entry.getAttributes();
+      
+      for( Attribute attr : attributes )
+      {
+         if( attr.getName().equalsIgnoreCase( name ) )
+         {
+            return attr;
+         }
+      } 
+      
+      return null;
+   }
+   $endif$
+   
+   $if(extensible)$ public $else$ private $endif$ void addAttribute( Attribute attr )
    {
       if( attr == null || ( ! attr.isNoUserModification() ) )
       {
@@ -162,13 +217,18 @@
       
       if( opAttributes == null )
       {
-         opAttributes = new HashSet<Attribute>();
+         opAttributes = new HashMap<String,Attribute>();
       }
       
-      opAttributes.add( attr );
+      String attrName = attr.getName().toLowerCase();
+      
+      if( opAttributes.get( attrName ) == null )
+      {
+         opAttributes.put( attrName, attr );
+      }
    }
    
-      
+
    public void addEntry( Entry entry )
    {
       if( entry == null )



Mime
View raw message