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 2007/07/23 02:44:44 UTC
svn commit: r558570 -
/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/
Author: akarasulu
Date: Sun Jul 22 17:44:40 2007
New Revision: 558570
URL: http://svn.apache.org/viewvc?view=rev&rev=558570
Log:
svn integration in idea causing me problems with missing packages on ci - committing missing items now so all should compile
Added:
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/J2LConfiguration.java (with props)
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/MatchingRuleMappingRegistry.java (with props)
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidAssignmentConfiguration.java (with props)
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidGenerator.java (with props)
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMapping.java (with props)
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMappingRegistry.java (with props)
directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/SchemaConfiguration.java (with props)
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/J2LConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/J2LConfiguration.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/J2LConfiguration.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/J2LConfiguration.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class J2LConfiguration
+{
+ /**
+ * the target package into which all code is generated: uses default
+ * pkg if unspecified
+ */
+ private String targetPackage;
+
+ /**
+ * the prefix to use for schema entities like objectClasses and
+ * attributeTypes: uses bean package for objectClass profix along
+ * with additional class name for attributeType prefixes if unspecified
+ */
+ private String entityPrefix;
+
+ /**
+ * Configuration information about the schema to generate.
+ */
+ private SchemaConfiguration schemaConfiguration;
+
+ /**
+ * Used to lookup default syntax and matchingRule mappings for Java primitive types.
+ */
+ private PrimitiveMappingRegistry primitiveMappingRegistry;
+
+ /**
+ * If true will generate an OpenLDAP compatible schema file using the
+ * following pattern for the file name: [name].schema.
+ */
+ private boolean generateSchemaFile = false;
+
+ /**
+ * If true will generate an LDIF file which loads a schema on import
+ * using the following pattern for the file name: [name]-schema.ldif.
+ */
+ private boolean generateSchemaLdifFile = false;
+
+ /**
+ * If true will generate a class that will load the schema into an LDAP
+ * server using JNDI to perform the required schema addition tasks.
+ */
+ private boolean generateSchemaInstallerCode = false;
+
+ /**
+ * If true will create JNDI state factories for storing beans in LDAP
+ * entries based on their schema.
+ */
+ private boolean generateJndiStateFactories = false;
+
+ /**
+ * If true will create JNDI object factories for instantiating and setting
+ * properties on beans using LDAP entries based on their schema.
+ */
+ private boolean generateJndiObjectFactories = false;
+
+ /**
+ * If true will create DAO objects used to perform crude operations on beans
+ * backed by LDAP entries using the generated schema for the beans.
+ */
+ private boolean generateDaoObjects = false;
+
+ /**
+ * If true will use the modifier pattern to create immutable objects and modifiers
+ * that leverage JNDI to perfom CRUD operations on these beans backed by LDAP
+ * entries.
+ */
+ private boolean generateModifierObjects = false;
+
+
+ public String getTargetPackage()
+ {
+ return targetPackage;
+ }
+
+
+ public void setTargetPackage( String targetPackage )
+ {
+ this.targetPackage = targetPackage;
+ }
+
+
+ public String getEntityPrefix()
+ {
+ return entityPrefix;
+ }
+
+
+ public void setEntityPrefix( String entityPrefix )
+ {
+ this.entityPrefix = entityPrefix;
+ }
+
+
+ public SchemaConfiguration getSchemaConfiguration()
+ {
+ return schemaConfiguration;
+ }
+
+
+ public void setSchemaConfiguration( SchemaConfiguration schemaConfiguration )
+ {
+ this.schemaConfiguration = schemaConfiguration;
+ }
+
+
+ public boolean isGenerateSchemaFile()
+ {
+ return generateSchemaFile;
+ }
+
+
+ public void setGenerateSchemaFile( boolean generateSchemaFile )
+ {
+ this.generateSchemaFile = generateSchemaFile;
+ }
+
+
+ public boolean isGenerateSchemaLdifFile()
+ {
+ return generateSchemaLdifFile;
+ }
+
+
+ public void setGenerateSchemaLdifFile( boolean generateSchemaLdifFile )
+ {
+ this.generateSchemaLdifFile = generateSchemaLdifFile;
+ }
+
+
+ public boolean isGenerateSchemaInstallerCode()
+ {
+ return generateSchemaInstallerCode;
+ }
+
+
+ public void setGenerateSchemaInstallerCode( boolean generateSchemaInstallerCode )
+ {
+ this.generateSchemaInstallerCode = generateSchemaInstallerCode;
+ }
+
+
+ public boolean isGenerateJndiStateFactories()
+ {
+ return generateJndiStateFactories;
+ }
+
+
+ public void setGenerateJndiStateFactories( boolean generateJndiStateFactories )
+ {
+ this.generateJndiStateFactories = generateJndiStateFactories;
+ }
+
+
+ public boolean isGenerateJndiObjectFactories()
+ {
+ return generateJndiObjectFactories;
+ }
+
+
+ public void setGenerateJndiObjectFactories( boolean generateJndiObjectFactories )
+ {
+ this.generateJndiObjectFactories = generateJndiObjectFactories;
+ }
+
+
+ public boolean isGenerateDaoObjects()
+ {
+ return generateDaoObjects;
+ }
+
+
+ public void setGenerateDaoObjects( boolean generateDaoObjects )
+ {
+ this.generateDaoObjects = generateDaoObjects;
+ }
+
+
+ public boolean isGenerateModifierObjects()
+ {
+ return generateModifierObjects;
+ }
+
+
+ public void setGenerateModifierObjects( boolean generateModifierObjects )
+ {
+ this.generateModifierObjects = generateModifierObjects;
+ }
+
+ public PrimitiveMappingRegistry getPrimitiveMappingRegistry()
+ {
+ return primitiveMappingRegistry;
+ }
+
+ public void setPrimitiveMappingRegistry( PrimitiveMappingRegistry primitiveMappingRegistry )
+ {
+ this.primitiveMappingRegistry = primitiveMappingRegistry;
+ }
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/J2LConfiguration.java
------------------------------------------------------------------------------
svn:executable = *
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/MatchingRuleMappingRegistry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/MatchingRuleMappingRegistry.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/MatchingRuleMappingRegistry.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/MatchingRuleMappingRegistry.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+import java.util.Map;
+import java.util.List;
+import java.util.HashMap;
+
+/**
+ * A registry of matchingRules associated with various Java data type representations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MatchingRuleMappingRegistry
+{
+ private Map<Class, String> class2equality = new HashMap<Class,String>();
+ private Map<Class, String> class2substring = new HashMap<Class,String>();
+ private Map<Class, String> class2ordering = new HashMap<Class,String>();
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/MatchingRuleMappingRegistry.java
------------------------------------------------------------------------------
svn:executable = *
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidAssignmentConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidAssignmentConfiguration.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidAssignmentConfiguration.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidAssignmentConfiguration.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+/**
+ * Stores the configuration information on how J2L will handle OID
+ * assignments for newly generated schemas.
+ *
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OidAssignmentConfiguration
+{
+ private static final String DEFAULT_OID_BASE = "1.3.6.1.4.1.18060.0" ;
+
+ private String oidBase = DEFAULT_OID_BASE;
+ private String schemaBranch = "0";
+ private String syntaxBranch = "0";
+ private int syntaxSequenceStart = 0;
+ private String matchingRuleBranch = "1";
+ private int matchingRuleSequenceStart = 0;
+ private String attributeTypeBranch = "2";
+ private int attributeTypeSequenceStart = 0;
+ private String objectClassBranch = "3";
+ private int objectClassSequenceStart = 0;
+ private String ditStructureRuleBranch = "4";
+ private int ditStructureRuleSequenceStart = 0;
+ private String nameFormBranch = "5";
+ private int nameFormSequenceStart = 0;
+
+ public String getOidBase()
+ {
+ return oidBase;
+ }
+
+ public String getSchemaBranch()
+ {
+ return schemaBranch;
+ }
+
+ public String getSyntaxBranch()
+ {
+ return syntaxBranch;
+ }
+
+ public int getSyntaxSequenceStart()
+ {
+ return syntaxSequenceStart;
+ }
+
+ public String getMatchingRuleBranch()
+ {
+ return matchingRuleBranch;
+ }
+
+ public int getMatchingRuleSequenceStart()
+ {
+ return matchingRuleSequenceStart;
+ }
+
+ public String getAttributeTypeBranch()
+ {
+ return attributeTypeBranch;
+ }
+
+ public int getAttributeTypeSequenceStart()
+ {
+ return attributeTypeSequenceStart;
+ }
+
+ public String getObjectClassBranch()
+ {
+ return objectClassBranch;
+ }
+
+ public int getObjectClassSequenceStart()
+ {
+ return objectClassSequenceStart;
+ }
+
+ public String getDitStructureRuleBranch()
+ {
+ return ditStructureRuleBranch;
+ }
+
+ public int getDitStructureRuleSequenceStart()
+ {
+ return ditStructureRuleSequenceStart;
+ }
+
+ public String getNameFormBranch()
+ {
+ return nameFormBranch;
+ }
+
+ public int getNameFormSequenceStart()
+ {
+ return nameFormSequenceStart;
+ }
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidAssignmentConfiguration.java
------------------------------------------------------------------------------
svn:executable = *
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidGenerator.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidGenerator.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidGenerator.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidGenerator.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class OidGenerator
+{
+ private final String syntaxOidBase;
+ private final String matchingRuleOidBase;
+ private final String attributeTypeOidBase;
+ private final String objectClassOidBase;
+ private final String ditStructureRuleOidBase;
+ private final String nameFormOidBase;
+
+ private int syntaxSequence = -1;
+ private int matchingRuleSequence = -1;
+ private int attributeTypeSeqeunce = -1;
+ private int objectClassSequence = -1;
+ private int ditStructureRuleSequence = -1;
+ private int nameFormSequence = -1;
+
+
+ public OidGenerator( OidAssignmentConfiguration configuration )
+ {
+ syntaxSequence += configuration.getSyntaxSequenceStart();
+ matchingRuleSequence += configuration.getMatchingRuleSequenceStart();
+ attributeTypeSeqeunce += configuration.getAttributeTypeSequenceStart();
+ objectClassSequence += configuration.getAttributeTypeSequenceStart();
+ ditStructureRuleSequence += configuration.getDitStructureRuleSequenceStart();
+ nameFormSequence += configuration.getDitStructureRuleSequenceStart();
+
+ final String schemaOidBase;
+ if ( configuration.getSchemaBranch() == null )
+ {
+ schemaOidBase = configuration.getOidBase();
+ }
+ else
+ {
+ schemaOidBase = configuration.getOidBase() + "." + configuration.getSchemaBranch() + "." ;
+ }
+
+ syntaxOidBase = schemaOidBase + configuration.getSyntaxBranch();
+ matchingRuleOidBase = schemaOidBase + configuration.getMatchingRuleBranch();
+ attributeTypeOidBase = schemaOidBase + configuration.getAttributeTypeBranch();
+ objectClassOidBase = schemaOidBase + configuration.getObjectClassBranch();
+ ditStructureRuleOidBase = schemaOidBase + configuration.getDitStructureRuleBranch();
+ nameFormOidBase = schemaOidBase + configuration.getNameFormBranch();
+ }
+
+
+ public synchronized String nextSyntaxOid()
+ {
+ syntaxSequence++;
+ return syntaxOidBase + "." + syntaxSequence;
+ }
+
+
+ public synchronized String nextMatchingRuleOid()
+ {
+ matchingRuleSequence++;
+ return matchingRuleOidBase + "." + matchingRuleSequence;
+ }
+
+
+ public synchronized String nextAttributeTypeOid()
+ {
+ attributeTypeSeqeunce++;
+ return attributeTypeOidBase + "." + attributeTypeSeqeunce;
+ }
+
+
+ public synchronized String nextObjectClassOid()
+ {
+ objectClassSequence++;
+ return objectClassOidBase + "." + objectClassSequence;
+ }
+
+
+ public synchronized String nextDitStructureRuleOid()
+ {
+ ditStructureRuleSequence++;
+ return ditStructureRuleOidBase + "." + ditStructureRuleSequence;
+ }
+
+
+ public synchronized String nextNameFormOid()
+ {
+ nameFormSequence++;
+ return nameFormOidBase + "." + nameFormSequence;
+ }
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/OidGenerator.java
------------------------------------------------------------------------------
svn:executable = *
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMapping.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMapping.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMapping.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMapping.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+/**
+ * A means to map a Java class to an LDAP syntax.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PrimitiveMapping
+{
+ private Class javaType;
+ private String ldapSyntaxOid;
+ private String equalityMatchingRule;
+ private String orderingMatchingRule;
+ private String substringMatchingRule;
+
+
+ public PrimitiveMapping()
+ {
+ }
+
+ public PrimitiveMapping( Class javaType, String ldapSyntaxOid )
+ {
+ this.javaType = javaType;
+ this.ldapSyntaxOid = ldapSyntaxOid;
+ }
+
+ public PrimitiveMapping( Class javaType, String ldapSyntaxOid, String equalityMatchingRule )
+ {
+ this( javaType, ldapSyntaxOid );
+ this.equalityMatchingRule = equalityMatchingRule;
+ }
+
+ public PrimitiveMapping( Class javaType, String ldapSyntaxOid, String equalityMatchingRule,
+ String orderMatchingRule, String substringMatchingRule )
+ {
+ this( javaType, ldapSyntaxOid, equalityMatchingRule );
+ this.orderingMatchingRule = orderMatchingRule;
+ this.substringMatchingRule = substringMatchingRule;
+ }
+
+
+ public Class getJavaType()
+ {
+ return javaType;
+ }
+
+ public void setJavaType( Class javaType )
+ {
+ this.javaType = javaType;
+ }
+
+ public String getLdapSyntaxOid()
+ {
+ return ldapSyntaxOid;
+ }
+
+ public void setLdapSyntaxOid( String ldapSyntaxOid )
+ {
+ this.ldapSyntaxOid = ldapSyntaxOid;
+ }
+
+ public String getEqualityMatchingRule()
+ {
+ return equalityMatchingRule;
+ }
+
+ public void setEqualityMatchingRule( String equalityMatchingRule )
+ {
+ this.equalityMatchingRule = equalityMatchingRule;
+ }
+
+ public String getOrderingMatchingRule()
+ {
+ return orderingMatchingRule;
+ }
+
+ public void setOrderingMatchingRule( String orderingMatchingRule )
+ {
+ this.orderingMatchingRule = orderingMatchingRule;
+ }
+
+ public String getSubstringMatchingRule()
+ {
+ return substringMatchingRule;
+ }
+
+ public void setSubstringMatchingRule( String substringMatchingRule )
+ {
+ this.substringMatchingRule = substringMatchingRule;
+ }
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMapping.java
------------------------------------------------------------------------------
svn:executable = *
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMappingRegistry.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMappingRegistry.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMappingRegistry.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMappingRegistry.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.BitSet;
+import java.util.Date;
+import java.math.BigInteger;
+import java.net.URL;
+
+
+/**
+ * Map of Simple Java Classes (data types) to LDAP Syntax OIDs. This is
+ * more of a functional object used at runtime to map simple types to LDAP
+ * syntaxes. It's not a configuration object. Most likely these mappings
+ * will need a PrimitiveMapping list or or something.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PrimitiveMappingRegistry
+{
+ private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
+ private static final char[] EMPTY_CHAR_ARRAY = new char[0];
+
+ // ~~~~ Stock Primitive Mappings
+
+ private static final PrimitiveMapping STRING_MAPPING =
+ new PrimitiveMapping( String.class, SchemaConstants.DIRECTORY_STRING_SYNTAX,
+ SchemaConstants.CASE_EXACT_MR, null, SchemaConstants.CASE_EXACT_SUBSTRING_MR );
+
+ private static final PrimitiveMapping INT_MAPPING =
+ new PrimitiveMapping( Integer.class, SchemaConstants.JAVA_INT_SYNTAX,
+ SchemaConstants.INTEGER_MR, SchemaConstants.INTEGER_ORDERING_MR, null );
+
+ private static final PrimitiveMapping BYTE_MAPPING =
+ new PrimitiveMapping( Byte.class, SchemaConstants.JAVA_BYTE_SYNTAX,
+ SchemaConstants.INTEGER_MR, SchemaConstants.INTEGER_ORDERING_MR, null );
+
+ private static final PrimitiveMapping SHORT_MAPPING =
+ new PrimitiveMapping( Short.class, SchemaConstants.JAVA_SHORT_SYNTAX,
+ SchemaConstants.INTEGER_MR, SchemaConstants.INTEGER_ORDERING_MR, null );
+
+ private static final PrimitiveMapping LONG_MAPPING =
+ new PrimitiveMapping( Long.class, SchemaConstants.JAVA_LONG_SYNTAX,
+ SchemaConstants.INTEGER_MR, SchemaConstants.INTEGER_ORDERING_MR, null );
+
+ private static final PrimitiveMapping BIG_INT_MAPPING =
+ new PrimitiveMapping( BigInteger.class, SchemaConstants.INTEGER_SYNTAX,
+ SchemaConstants.INTEGER_MR, SchemaConstants.INTEGER_ORDERING_MR, null );
+
+ private static final PrimitiveMapping BIT_SET_MAPPING =
+ new PrimitiveMapping( BitSet.class, SchemaConstants.BIT_STRING_SYNTAX, SchemaConstants.BIT_STRING_MR );
+
+ private static final PrimitiveMapping BOOLEAN_MAPPING =
+ new PrimitiveMapping( Boolean.class, SchemaConstants.BOOLEAN_SYNTAX, SchemaConstants.BOOLEAN_MR );
+
+ private static final PrimitiveMapping BYTE_ARRAY_MAPPING =
+ new PrimitiveMapping( EMPTY_BYTE_ARRAY.getClass(), SchemaConstants.BINARY_SYNTAX );
+
+ private static final PrimitiveMapping CHAR_ARRAY_MAPPING =
+ new PrimitiveMapping( EMPTY_CHAR_ARRAY.getClass(), SchemaConstants.DIRECTORY_STRING_SYNTAX,
+ SchemaConstants.CASE_EXACT_MR, null, SchemaConstants.CASE_EXACT_SUBSTRING_MR );
+
+ private static final PrimitiveMapping DATE_MAPPING =
+ new PrimitiveMapping( Date.class, SchemaConstants.GENERALIZED_TIME_SYNTAX,
+ SchemaConstants.GENERALIZED_TIME_MR, SchemaConstants.GENERALIZED_TIME_ORDERING_MR, null );
+
+ private static final PrimitiveMapping SQL_DATE_MAPPING =
+ new PrimitiveMapping( java.sql.Date.class, SchemaConstants.GENERALIZED_TIME_SYNTAX,
+ SchemaConstants.GENERALIZED_TIME_MR, SchemaConstants.GENERALIZED_TIME_ORDERING_MR, null );
+
+ private static final PrimitiveMapping SQL_TIME_MAPPING =
+ new PrimitiveMapping( java.sql.Time.class, SchemaConstants.GENERALIZED_TIME_SYNTAX,
+ SchemaConstants.GENERALIZED_TIME_MR, SchemaConstants.GENERALIZED_TIME_ORDERING_MR, null );
+
+ private static final PrimitiveMapping SQL_TIMESTAMP_MAPPING =
+ new PrimitiveMapping( java.sql.Timestamp.class, SchemaConstants.GENERALIZED_TIME_SYNTAX,
+ SchemaConstants.GENERALIZED_TIME_MR, SchemaConstants.GENERALIZED_TIME_ORDERING_MR, null );
+
+ private static final PrimitiveMapping URL_MAPPING =
+ new PrimitiveMapping( URL.class, SchemaConstants.DIRECTORY_STRING_SYNTAX,
+ SchemaConstants.CASE_EXACT_MR, null, SchemaConstants.CASE_EXACT_SUBSTRING_MR );
+
+
+
+ private Map<Class, PrimitiveMapping> class2syntax = new HashMap<Class, PrimitiveMapping>();
+
+
+ public PrimitiveMappingRegistry( PrimitiveMapping[] overrides )
+ {
+ this();
+
+ for ( PrimitiveMapping mapping : overrides )
+ {
+ class2syntax.put( mapping.getJavaType(), mapping );
+ }
+ }
+
+
+ public PrimitiveMappingRegistry()
+ {
+ class2syntax.put( STRING_MAPPING.getJavaType(), STRING_MAPPING );
+ class2syntax.put( INT_MAPPING.getJavaType(), INT_MAPPING );
+ class2syntax.put( BYTE_MAPPING.getJavaType(), BYTE_MAPPING );
+ class2syntax.put( LONG_MAPPING.getJavaType(), LONG_MAPPING );
+ class2syntax.put( SHORT_MAPPING.getJavaType(), SHORT_MAPPING );
+ class2syntax.put( BIG_INT_MAPPING.getJavaType(), BIG_INT_MAPPING );
+ class2syntax.put( BIT_SET_MAPPING.getJavaType(), BIT_SET_MAPPING );
+ class2syntax.put( BOOLEAN_MAPPING.getJavaType(), BOOLEAN_MAPPING );
+ class2syntax.put( CHAR_ARRAY_MAPPING.getJavaType(), CHAR_ARRAY_MAPPING );
+ class2syntax.put( BYTE_ARRAY_MAPPING.getJavaType(), BYTE_ARRAY_MAPPING );
+ class2syntax.put( DATE_MAPPING.getJavaType(), DATE_MAPPING );
+ class2syntax.put( SQL_DATE_MAPPING.getJavaType(), SQL_DATE_MAPPING );
+ class2syntax.put( SQL_TIME_MAPPING.getJavaType(), SQL_TIME_MAPPING );
+ class2syntax.put( SQL_TIMESTAMP_MAPPING.getJavaType(), SQL_TIMESTAMP_MAPPING );
+ class2syntax.put( URL_MAPPING.getJavaType(), URL_MAPPING );
+
+ // Need a ASN.1 REAL syntax converstion to LDAP Syntax and matchingRules to do this
+ // class2syntax.put( FLOAT_MAPPING.getJavaType(), FLOAT_MAPPING );
+ // class2syntax.put( DOUBLE_MAPPING.getJavaType(), DOUBLE_MAPPING );
+ }
+
+
+ public void register( Class javaType, PrimitiveMapping mapping )
+ {
+ class2syntax.put( javaType, mapping );
+ }
+
+
+ public PrimitiveMapping lookup( Class javaType )
+ {
+ return class2syntax.get( javaType );
+ }
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/PrimitiveMappingRegistry.java
------------------------------------------------------------------------------
svn:executable = *
Added: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/SchemaConfiguration.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/SchemaConfiguration.java?view=auto&rev=558570
==============================================================================
--- directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/SchemaConfiguration.java (added)
+++ directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/SchemaConfiguration.java Sun Jul 22 17:44:40 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.directory.j2l.configuration;
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaConfiguration
+{
+ private OidAssignmentConfiguration oidAssignmentConfiguration = new OidAssignmentConfiguration();
+ private OidGenerator oidGenerator = new OidGenerator( oidAssignmentConfiguration );
+ private String name;
+ private String[] dependencies;
+ private String owner;
+
+ public OidAssignmentConfiguration getOidAssignmentConfiguration()
+ {
+ return oidAssignmentConfiguration;
+ }
+
+ public void setOidAssignmentConfiguration( OidAssignmentConfiguration oidAssignmentConfiguration )
+ {
+ this.oidAssignmentConfiguration = oidAssignmentConfiguration;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String[] getDependencies()
+ {
+ return dependencies;
+ }
+
+ public void setDependencies( String[] dependencies )
+ {
+ this.dependencies = dependencies;
+ }
+
+ public String getOwner()
+ {
+ return owner;
+ }
+
+ public void setOwner( String owner )
+ {
+ this.owner = owner;
+ }
+
+ public OidGenerator getOidGenerator()
+ {
+ return oidGenerator;
+ }
+
+ public void setOidGenerator( OidGenerator oidGenerator )
+ {
+ this.oidGenerator = oidGenerator;
+ }
+}
Propchange: directory/sandbox/akarasulu/j2l/trunk/runtime/src/main/java/org/apache/directory/j2l/configuration/SchemaConfiguration.java
------------------------------------------------------------------------------
svn:executable = *