directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r359048 - /directory/shared/ldap/branches/DN-refactoring/common/src/antlr/ACIItem.g
Date Mon, 26 Dec 2005 10:21:54 GMT
Author: elecharny
Date: Mon Dec 26 02:21:49 2005
New Revision: 359048

URL: http://svn.apache.org/viewcvs?rev=359048&view=rev
Log:
- We now use the LdapDN and DNNormalizer classes
- No more init() method

Modified:
    directory/shared/ldap/branches/DN-refactoring/common/src/antlr/ACIItem.g

Modified: directory/shared/ldap/branches/DN-refactoring/common/src/antlr/ACIItem.g
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/antlr/ACIItem.g?rev=359048&r1=359047&r2=359048&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/antlr/ACIItem.g (original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/antlr/ACIItem.g Mon Dec 26 02:21:49
2005
@@ -31,6 +31,7 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.BasicAttribute;
 import javax.naming.Name;
+import javax.naming.NameParser ;
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.filter.AbstractExprNode;
@@ -39,8 +40,8 @@
 import org.apache.ldap.common.filter.FilterParserImpl;
 import org.apache.ldap.common.filter.LeafNode;
 import org.apache.ldap.common.filter.SimpleNode;
-import org.apache.ldap.common.name.DnParser;
-import org.apache.ldap.common.name.NameComponentNormalizer;
+import org.apache.ldap.common.name.LdapDN;
+import org.apache.ldap.common.schema.DnNormalizer;
 import org.apache.ldap.common.subtree.SubtreeSpecification;
 import org.apache.ldap.common.subtree.SubtreeSpecificationModifier;
 import org.apache.ldap.common.util.ComponentsMonitor;
@@ -98,12 +99,8 @@
     private static final Logger log = LoggerFactory.getLogger( AntlrACIItemParser.class );
     
     // subordinate parser instances
-    private DnParser dnParser;
     private final FilterParserImpl filterParser = new FilterParserImpl();
     
-    private boolean isNormalizing = false;
-    NameComponentNormalizer normalizer;
-    
     // nonshared global data needed to avoid extensive pass/return stuff
     // these are only used by three first order components
     private String m_identificationTag;
@@ -131,47 +128,6 @@
     private ComponentsMonitor userPermissionComponentsMonitor;
     private ComponentsMonitor subtreeSpecificationComponentsMonitor;
     
-    
-    /**
-     * Creates a (normalizing) subordinate DnParser for parsing Names.
-     * This method MUST be called for each instance while we cannot do
-     * constructor overloading for this class.
-     *
-     * @return the DnParser to be used for parsing Names
-     */
-    public void init()
-    {
-        try
-        {
-            if( isNormalizing )
-            {
-                dnParser = new DnParser( normalizer );
-            }
-            else
-            {
-                dnParser = new DnParser();
-            }
-        }
-        catch ( NamingException e )
-        {
-            String msg = "Failed to initialize the subordinate DnParser for this AntlrACIItemParser";
-
-            // We throw a NPE since this variable cannot be null for proper operation
-            // so we can catch the null pointer before the dnParser is even used.
-
-            throw new NullPointerException( "dnParser is null: " + msg );
-        }
-    }
-
-    /**
-     * Sets the NameComponentNormalizer for this parser's dnParser.
-     */
-    public void setNormalizer(NameComponentNormalizer normalizer)
-    {
-        this.normalizer = normalizer;
-        this.isNormalizing = true;
-    }
-
     private int token2Integer( Token token ) throws RecognitionException
     {
         int i = 0;
@@ -508,8 +464,12 @@
     {
         // A Dn can be considered as a set of attributeTypeAndValues
         // So, parse the set as a Dn and extract each attributeTypeAndValue
-        Name attributeTypeAndValueSetAsDn = dnParser.parse( token.getText() );
+        Name attributeTypeAndValueSetAsDn = new LdapDN( token.getText() );
+        
+       	DnNormalizer.normalize( attributeTypeAndValueSetAsDn );
+        
         Enumeration attributeTypeAndValueSet = attributeTypeAndValueSetAsDn.getAll();
+        
         while ( attributeTypeAndValueSet.hasMoreElements() )
         {
             attributeTypeAndValue = ( String ) attributeTypeAndValueSet.nextElement();
@@ -518,6 +478,7 @@
             attributeSet.add( new BasicAttribute( attributeType, attributeValue ) );
             log.debug( "An attributeTypeAndValue from the set: " + attributeType + "=" +
 attributeValue);
         }
+        
         m_protectedItemsMap.put( "attributeValue", new ProtectedItem.AttributeValue( attributeSet
) );
     }
     ;
@@ -1172,7 +1133,9 @@
     :
     token:SAFEUTF8STRING
     {
-        name = dnParser.parse( token.getText() );
+        name = new LdapDN( token.getText() );
+       	name = (Name)DnNormalizer.normalize( name );
+        
         log.debug( "recognized a DistinguishedName: " + token.getText() );
     }
     ;



Mime
View raw message