You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/12/26 11:24:49 UTC
svn commit: r359051 -
/directory/shared/ldap/branches/DN-refactoring/common/src/antlr/subtree-specification.g
Author: elecharny
Date: Mon Dec 26 02:24:45 2005
New Revision: 359051
URL: http://svn.apache.org/viewcvs?rev=359051&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/subtree-specification.g
Modified: directory/shared/ldap/branches/DN-refactoring/common/src/antlr/subtree-specification.g
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/DN-refactoring/common/src/antlr/subtree-specification.g?rev=359051&r1=359050&r2=359051&view=diff
==============================================================================
--- directory/shared/ldap/branches/DN-refactoring/common/src/antlr/subtree-specification.g (original)
+++ directory/shared/ldap/branches/DN-refactoring/common/src/antlr/subtree-specification.g Mon Dec 26 02:24:45 2005
@@ -25,10 +25,12 @@
import java.util.ArrayList;
import javax.naming.Name;
+import javax.naming.NameParser;
import javax.naming.NamingException;
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.filter.ExprNode;
import org.apache.ldap.common.filter.LeafNode;
import org.apache.ldap.common.filter.SimpleNode;
@@ -75,10 +77,6 @@
{
private static final Logger log = LoggerFactory.getLogger( AntlrSubtreeSpecificationParser.class );
- private DnParser dnParser;
-
- private boolean isNormalizing = false;
- private NameComponentNormalizer normalizer;
private Set chopBeforeExclusions = new HashSet();
private Set chopAfterExclusions = new HashSet();
@@ -87,46 +85,6 @@
private ComponentsMonitor subtreeSpecificationComponentsMonitor = null;
- /**
- * Creates a (normalizing) subordinate DnParser for parsing LocalNames.
- * 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 LocalNames
- */
- 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 AntlrSubtreeSpecificationParser";
-
- // 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;
@@ -327,14 +285,15 @@
:
token:SAFEUTF8STRING
{
- name = dnParser.parse( token.getText() );
+ name = (Name)DnNormalizer.normalize( new LdapDN( token.getText() ) );
+
log.debug( "recognized a DistinguishedName: " + token.getText() );
}
;
exception
catch [Exception e]
{
- throw new RecognitionException( "dnParser failed for " + token.getText() + " " + e.getMessage() );
+ throw new RecognitionException( "DnParser failed for " + token.getText() + " " + e.getMessage() );
}
baseDistance returns [ int distance ]