You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/10/10 08:55:24 UTC

svn commit: rev 54220 - in incubator/directory/eve/trunk/backend/tools/src: antlr java/org/apache/eve/tools/schema

Author: akarasulu
Date: Sat Oct  9 23:55:23 2004
New Revision: 54220

Added:
   incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/ObjectClassLiteral.java   (contents, props changed)
Modified:
   incubator/directory/eve/trunk/backend/tools/src/antlr/openldap.g
   incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypeLiteral.java
Log:
Commit changes ...

 o added new bean for collecting literal objectClass definition data
 o added all productions for processing objectClass definitions
 o cleaned up various conflicting production names for ATypes verses ObjClasses



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 23:55:23 2004
@@ -66,6 +66,9 @@
 DIGIT              : '0' .. '9'
     ;
 
+DOLLAR             : '$'
+    ;
+
 OPEN_PAREN         : '('
     ;
 
@@ -154,6 +157,11 @@
 }
 
 
+// ----------------------------------------------------------------------------
+// Main Entry Point Production
+// ----------------------------------------------------------------------------
+
+
 parseSchema
 {
 }
@@ -161,11 +169,157 @@
     ( attributeType )*
     ;
 
+
+// ----------------------------------------------------------------------------
+// AttributeType Productions
+// ----------------------------------------------------------------------------
+
+
+objectClass
+{
+    matchedProduction( "objectClass()" );
+    ObjectClassLiteral objectClass = null;
+}
+    :
+    "objectclass"
+    OPEN_PAREN oid:NUMERICOID
+    {
+        objectClass = new ObjectClassLiteral( oid.getText() );
+    }
+    ( objectClassNames[objectClass] )?
+    ( objectClassDesc[objectClass] )?
+    ( "OBSOLETE" { objectClass.setObsolete( true ); } )?
+    ( objectClassSuperiors[objectClass] )?
+    ( 
+        "ABSTRACT"   { objectClass.setClassType( ObjectClassTypeEnum.ABSTRACT ); } |
+        "STRUCTURAL" { objectClass.setClassType( ObjectClassTypeEnum.STRUCTURAL ); } |
+        "AUXILIARY"  { objectClass.setClassType( ObjectClassTypeEnum.AUXILIARY ); }
+    )?
+    ( must[objectClass] )?
+    ( may[objectClass] )?
+    ;
+
+
+may [ObjectClassLiteral objectClass]
+{
+    matchedProduction( "may(ObjectClassLiteral)" ) ;
+    ArrayList list = null;
+}
+    : "MAY" list=woidlist
+    {
+        objectClass.setMay( ( String[] ) list.toArray( EMPTY ) );
+    }
+    ;
+
+
+must [ObjectClassLiteral objectClass]
+{
+    matchedProduction( "must(ObjectClassLiteral)" ) ;
+    ArrayList list = null;
+}
+    : "MUST" list=woidlist
+    {
+        objectClass.setMust( ( String[] ) list.toArray( EMPTY ) );
+    }
+    ;
+
+
+objectClassSuperiors [ObjectClassLiteral objectClass]
+{
+    matchedProduction( "objectClassSuperiors(ObjectClassLiteral)" ) ;
+    ArrayList list = null;
+}
+    : "SUP" list=woidlist
+    {
+        objectClass.setSuperiors( ( String[] ) list.toArray( EMPTY ) );
+    }
+    ;
+
+
+woid returns [String oid]
+{
+    oid = null;
+    matchedProduction( "woid()" ) ;
+}
+    :
+    (
+        opt1:NUMERICOID
+        {
+            oid = opt1.getText();
+        }
+        |
+        opt2:IDENTIFIER
+        {
+            oid = opt2.getText();
+        }
+    )
+    ;
+
+
+woidlist returns [ArrayList list]
+{
+    matchedProduction( "woidlist()" ) ;
+    list = new ArrayList( 2 );
+    String oid = null;
+}
+    :
+    (
+        oid=woid { list.add( oid ); } |
+        (
+            OPEN_PAREN
+            oid=woid { list.add( oid ); } ( DOLLAR oid=woid { list.add( oid ); } )*
+            CLOSE_PAREN
+        )
+    )
+    ;
+
+objectClassDesc [ObjectClassLiteral objectClass]
+{
+    matchedProduction( "desc(ObjectClassLiteral)" ) ;
+}
+    : d:DESC
+    {
+        objectClass.setDescription( d.getText().split( "'" )[1] );
+    }
+    ;
+
+
+objectClassNames [ObjectClassLiteral objectClass]
+{
+    matchedProduction( "names(ObjectClassLiteral)" ) ;
+    ArrayList list = new ArrayList();
+}
+    :
+    (
+        "NAME" QUOTE id0:IDENTIFIER QUOTE
+        {
+            list.add( id0.getText() );
+        }
+        |
+        ( OPEN_PAREN QUOTE id1:IDENTIFIER
+        {
+            list.add( id1.getText() );
+        } QUOTE
+        ( QUOTE id2:IDENTIFIER QUOTE
+        {
+            list.add( id2.getText() );
+        } )* CLOSE_PAREN )
+    )
+    {
+        objectClass.setNames( ( String[] ) list.toArray( EMPTY ) );
+    }
+    ;
+
+
+// ----------------------------------------------------------------------------
+// AttributeType Productions
+// ----------------------------------------------------------------------------
+
+
 attributeType
 {
     matchedProduction( "attributeType()" );
     AttributeTypeLiteral type = null;
-    UsageEnum usageEnum;
 }
     :
     "attributetype"
@@ -195,6 +349,7 @@
 
 desc [AttributeTypeLiteral type]
 {
+    matchedProduction( "desc(AttributeTypeLiteral)" ) ;
 }
     : d:DESC
     {
@@ -205,7 +360,7 @@
 
 superior [AttributeTypeLiteral type]
 {
-    matchedProduction( "superior()" ) ;
+    matchedProduction( "superior(AttributeTypeLiteral)" ) ;
 }
     : "SUP"
     (
@@ -223,7 +378,7 @@
 
 equality [AttributeTypeLiteral type]
 {
-    matchedProduction( "equality()" ) ;
+    matchedProduction( "equality(AttributeTypeLiteral)" ) ;
 }
     : "EQUALITY"
     (
@@ -241,7 +396,7 @@
 
 substr [AttributeTypeLiteral type]
 {
-    matchedProduction( "substr()" ) ;
+    matchedProduction( "substr(AttributeTypeLiteral)" ) ;
 }
     : "SUBSTR"
     (
@@ -259,7 +414,7 @@
 
 ordering [AttributeTypeLiteral type]
 {
-    matchedProduction( "ordering()" ) ;
+    matchedProduction( "ordering(AttributeTypeLiteral)" ) ;
 }
     : "ORDERING"
     (
@@ -277,7 +432,7 @@
 
 names [AttributeTypeLiteral type]
 {
-    matchedProduction( "names()" ) ;
+    matchedProduction( "names(AttributeTypeLiteral)" ) ;
     ArrayList list = new ArrayList();
 }
     :
@@ -304,7 +459,7 @@
 
 syntax [AttributeTypeLiteral type]
 {
-    matchedProduction( "syntax()" ) ;
+    matchedProduction( "syntax(AttributeTypeLiteral)" ) ;
 }
     : token:SYNTAX
     {
@@ -328,7 +483,7 @@
 
 usage [AttributeTypeLiteral type]
 {
-    matchedProduction( "usage()" ) ;
+    matchedProduction( "usage(AttributeTypeLiteral)" ) ;
 }
     :
     "USAGE"

Modified: incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypeLiteral.java
==============================================================================
--- incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypeLiteral.java	(original)
+++ incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/AttributeTypeLiteral.java	Sat Oct  9 23:55:23 2004
@@ -16,11 +16,14 @@
  */
 package org.apache.eve.tools.schema;
 
-import org.apache.ldap.common.schema.UsageEnum;
+
 import org.apache.ldap.common.util.ArrayUtils;
+import org.apache.ldap.common.schema.UsageEnum;
+
 
 /**
- * Document me.
+ * A bean used to hold the literal values of an AttributeType parsed out of an
+ * OpenLDAP schema configuration file.
  *
  * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
  * @version $Rev$

Added: incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/ObjectClassLiteral.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/tools/src/java/org/apache/eve/tools/schema/ObjectClassLiteral.java	Sat Oct  9 23:55:23 2004
@@ -0,0 +1,174 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.eve.tools.schema;
+
+
+import org.apache.ldap.common.util.ArrayUtils;
+import org.apache.ldap.common.schema.ObjectClassTypeEnum;
+
+
+/**
+ * A bean used to encapsulate the literal String values of an ObjectClass
+ * definition found within an OpenLDAP schema configuration file.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class ObjectClassLiteral
+{
+    private boolean obsolete = false;
+
+    private String oid;
+    private String description;
+
+    private String[] names = ArrayUtils.EMPTY_STRING_ARRAY;
+    private String[] superiors = ArrayUtils.EMPTY_STRING_ARRAY;
+    private String[] must = ArrayUtils.EMPTY_STRING_ARRAY;
+    private String[] may = ArrayUtils.EMPTY_STRING_ARRAY;
+
+    private ObjectClassTypeEnum classType = ObjectClassTypeEnum.STRUCTURAL;
+
+
+    // ------------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // ------------------------------------------------------------------------
+
+
+    public ObjectClassLiteral( String oid )
+    {
+        this.oid = oid;
+    }
+
+
+    // ------------------------------------------------------------------------
+    // Accessors and mutators
+    // ------------------------------------------------------------------------
+
+
+    public boolean isObsolete()
+    {
+        return obsolete;
+    }
+
+    public void setObsolete( boolean obsolete )
+    {
+        this.obsolete = obsolete;
+    }
+
+    public String getOid()
+    {
+        return oid;
+    }
+
+    public void setOid( String oid )
+    {
+        this.oid = oid;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public String[] getNames()
+    {
+        return names;
+    }
+
+    public void setNames( String[] names )
+    {
+        this.names = names;
+    }
+
+    public String[] getSuperiors()
+    {
+        return superiors;
+    }
+
+    public void setSuperiors( String[] superiors )
+    {
+        this.superiors = superiors;
+    }
+
+    public String[] getMust()
+    {
+        return must;
+    }
+
+    public void setMust( String[] must )
+    {
+        this.must = must;
+    }
+
+    public String[] getMay()
+    {
+        return may;
+    }
+
+    public void setMay( String[] may )
+    {
+        this.may = may;
+    }
+
+    public ObjectClassTypeEnum getClassType()
+    {
+        return classType;
+    }
+
+    public void setClassType( ObjectClassTypeEnum classType )
+    {
+        this.classType = classType;
+    }
+
+
+    // ------------------------------------------------------------------------
+    // Object overrides
+    // ------------------------------------------------------------------------
+
+
+    public int hashCode()
+    {
+        return getOid().hashCode();
+    }
+
+
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+
+        if ( ! ( obj instanceof ObjectClassLiteral ) )
+        {
+            return false;
+        }
+
+        return getOid().equals( ( ( ObjectClassLiteral ) obj ).getOid() );
+    }
+
+
+    public String toString()
+    {
+        return getOid();
+    }
+}