Author: akarasulu
Date: Sat Oct 9 21:29:41 2004
New Revision: 54215
Modified:
incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
Log:
started to generalize parser for entire schema to include objectClasses
Modified: incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g
(original)
+++ incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g Sat Oct
9 21:29:41 2004
@@ -111,8 +111,45 @@
{
public static final String[] EMPTY = new String[0];
+
+ private Map attributeTypes = new HashMap();
+ private Map objectClasses = new HashMap();
private ParserMonitor monitor = null;
- OidRegistry registry = null;
+ private OidRegistry registry = null;
+
+
+ // ------------------------------------------------------------------------
+ // Public Methods
+ // ------------------------------------------------------------------------
+
+
+ public Map getAttributeTypes()
+ {
+ return Collections.unmodifiableMap( attributeTypes );
+ }
+
+
+ public Map getObjectClasses()
+ {
+ return Collections.unmodifiableMap( objectClasses );
+ }
+
+
+ public void setParserMonitor( ParserMonitor monitor )
+ {
+ this.monitor = monitor;
+ }
+
+
+ public void setOidRegistry( OidRegistry registry )
+ {
+ this.registry = registry;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Private Methods
+ // ------------------------------------------------------------------------
private final String resolve( String name )
@@ -133,25 +170,18 @@
}
- public final void matchedProduction( String msg )
+ private void matchedProduction( String msg )
{
if ( null != monitor )
{
monitor.matchedProduction( msg );
}
}
-
-
- public void setParserMonitor( ParserMonitor monitor )
- {
- this.monitor = monitor;
- }
- public void setOidRegistry( OidRegistry registry )
- {
- this.registry = registry;
- }
+ // ------------------------------------------------------------------------
+ // Static Classes
+ // ------------------------------------------------------------------------
private static class MutableAttributeType extends BaseAttributeType
@@ -272,10 +302,17 @@
}
-attributeType returns [MutableAttributeType type]
+parseSchema
+{
+}
+ :
+ ( attributeType )*
+ ;
+
+attributeType
{
- matchedProduction( "attributeType()" ) ;
- type = null ;
+ matchedProduction( "attributeType()" );
+ MutableAttributeType type = null;
UsageEnum usageEnum;
}
:
@@ -297,7 +334,11 @@
( "NO-USER-MODIFICATION" { type.setCanUserModify( true ); } )?
( usage[type] )?
- CLOSE_PAREN ;
+ CLOSE_PAREN
+ {
+ attributeTypes.put( type.getOid(), type );
+ }
+ ;
desc [MutableAttributeType type]
Modified:
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
==============================================================================
---
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
(original)
+++
incubator/directory/eve/trunk/backend/tools/src/test/org/apache/eve/tools/schema/AttributeTypeParserTest.java
Sat Oct 9 21:29:41 2004
@@ -19,10 +19,11 @@
import junit.framework.TestCase;
+import java.util.Map;
import java.io.ByteArrayInputStream;
-import org.apache.ldap.common.schema.AttributeType;
import org.apache.eve.schema.DefaultOidRegistry;
+import org.apache.ldap.common.schema.AttributeType;
/**
@@ -54,8 +55,12 @@
DefaultOidRegistry registry = new DefaultOidRegistry();
registry.register( "caseIgnoreMatch", "1.1.1.1.1.1" );
parser.setOidRegistry( registry );
- AttributeType type = parser.attributeType();
+ Map attributeTypes = parser.getAttributeTypes();
+ parser.attributeType();
+ AttributeType type = ( AttributeType ) attributeTypes.get( "2.5.4.2" );
+
+ assertNotNull( type );
assertEquals( "2.5.4.2", type.getOid() );
assertEquals( "knowledgeInformation", type.getName() );
assertEquals( "RFC2256: knowledge information", type.getDescription()
);