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/09/29 02:33:52 UTC
svn commit: rev 47437 - in incubator/directory: eve/trunk/backend/core/src/java/org/apache/eve/schema ldap/trunk/common/src/java/org/apache/ldap/common/schema
Author: akarasulu
Date: Tue Sep 28 17:33:52 2004
New Revision: 47437
Added:
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/DefaultAttributeType.java
- copied, changed from rev 47435, incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/DefaultAttributeType.java
Removed:
incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/DefaultAttributeType.java
Modified:
incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/AttributeType.java
Log:
moving a copy of AttributeType impl to the right place
Modified: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/AttributeType.java
==============================================================================
--- incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/AttributeType.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/AttributeType.java Tue Sep 28 17:33:52 2004
@@ -16,6 +16,8 @@
*/
package org.apache.ldap.common.schema;
+import java.util.List;
+
/**
* An attributeType specification. attributeType specifications describe the
@@ -144,7 +146,7 @@
*
* @return String names for this AttributeType
*/
- String[] getAllNames();
+ List getAllNames();
/**
* Gets a description for this AttributeType.
Copied: incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/DefaultAttributeType.java (from rev 47435, incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/DefaultAttributeType.java)
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/DefaultAttributeType.java (original)
+++ incubator/directory/ldap/trunk/common/src/java/org/apache/ldap/common/schema/DefaultAttributeType.java Tue Sep 28 17:33:52 2004
@@ -1,32 +1,35 @@
-package org.apache.ldap.common.schema ;
-
-
-import java.io.Serializable ;
-
-import java.util.ArrayList ;
-import java.util.Collection ;
-import java.util.Comparator ;
+/*
+ * 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.ldap.common.schema;
-import javax.naming.NamingException ;
-import javax.naming.directory.Attribute ;
-import javax.naming.directory.Attributes ;
-import org.apache.avalon.framework.configuration.Configuration ;
-import org.apache.avalon.framework.configuration.ConfigurationException ;
+import java.io.Serializable;
-import org.apache.ldap.server.schema.syntax.Syntax ;
-import org.apache.ldap.common.NotImplementedException ;
-import org.apache.ldap.server.schema.matching.Normalizer ;
-import org.apache.ldap.server.schema.syntax.SyntaxChecker ;
-import org.apache.ldap.server.schema.syntax.SyntaxManager ;
-import org.apache.ldap.server.schema.matching.MatchingRule ;
-import org.apache.ldap.server.schema.matching.MatchingRuleManager ;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
/**
* Attribute specification bean used to store the schema information for an
* attribute definition.
- *
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
*/
public class DefaultAttributeType implements Serializable, AttributeType
{
@@ -34,725 +37,227 @@
// Specification Attributes
// ------------------------------------------------------------------------
- /** */
- private String m_oid ;
- /** */
- private ArrayList m_nameList = new ArrayList() ;
- /** */
- private String m_desc ;
- /** */
- private MatchingRule m_equality ;
- /** */
- private MatchingRule m_substr ;
- /** */
- private MatchingRule m_ordering ;
- /** */
- private Syntax m_syntax ;
- /** */
- private boolean m_isSingleValue = false ;
- /** */
- private boolean m_isCollective = false ;
- /** */
- private boolean m_canUserModify = true ;
- /** */
- private UsageEnum m_usage ;
- /** */
- private String m_superior ;
- /** */
- private int m_length = Integer.MAX_VALUE ;
-
-
- // ------------------------------------------------------------------------
- // Inferred Attributes
- // ------------------------------------------------------------------------
-
-
- /** Directly references other child AttributeSpecs */
- private ArrayList m_children = new ArrayList() ;
-
+ /** the object identifier for this attributeType */
+ private String oid;
+ /** the optional superior attributeType */
+ private AttributeType superior;
+ /** a list of names for this attribute of this type */
+ private ArrayList nameList = new ArrayList();
+ /** the optional description for this attributeType*/
+ private String desc;
+ /** the equality matching rule for this attributeType */
+ private MatchingRule equality;
+ /** the substring matching rule for this attributeType */
+ private MatchingRule substr;
+ /** the ordering matching rule for this attributeType */
+ private MatchingRule ordering;
+ /** the syntax for this attributeType */
+ private Syntax syntax;
+ /** whether or not this type is single valued */
+ private boolean isSingleValue = false;
+ /** whether or not this type is a collective attribute */
+ private boolean isCollective = false;
+ /** whether or not this type can be modified by directory users */
+ private boolean canUserModify = true;
+ /** whether or not this type has been obsoleted */
+ private boolean isObsolete = true;
+ /** the usage for this attributeType */
+ private UsageEnum usage;
+ /** the length of this attribute in bytes */
+ private int length = Integer.MAX_VALUE;
- // ------------------------------------------------------------------------
- // C O N S T R U C T O R S
- // ------------------------------------------------------------------------
-
-
- /**
- * TODO Document me!
- *
- * @param a_oid TODO
- */
- protected DefaultAttributeType( String a_oid )
- {
- m_oid = a_oid ;
- }
-
// ------------------------------------------------------------------------
// Accessor Methods for Specification Properties
// ------------------------------------------------------------------------
- /**
- * Gets the unique IANA registered Object IDentifier (OID) associated with
- * this attribute specification.
- *
- * @return String the object identifier.
- */
public String getOid()
{
- return m_oid ;
+ return oid;
}
- /**
- * Gets the first name in the list of names for this AttributeTypeImpl.
- *
- * @return the first name in the list of names
- */
public String getName()
{
- return ( String ) m_nameList.get( 0 ) ;
+ return ( String ) nameList.get( 0 );
}
-
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public Collection getAllNames()
- {
- return m_nameList ;
- }
-
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public String getDescription()
+ public List getAllNames()
{
- return m_desc ;
+ return Collections.unmodifiableList( nameList );
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public String getSyntaxOid()
+ public boolean isObsolete()
{
- return m_syntax.getOid() ;
+ return isObsolete;
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public boolean isSingleValue()
+ public String getDescription()
{
- return m_isSingleValue ;
+ return desc;
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public boolean isCanUserModify()
+ public String getSyntaxOid()
{
- return m_canUserModify ;
+ return syntax.getOid();
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public UsageEnum getUsage()
+ public boolean isSingleValue()
{
- return m_usage ;
+ return isSingleValue;
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public String getSuperior()
+ public boolean isCollective()
{
- return m_superior ;
+ return isCollective;
}
-
- /**
- * Returns the OID of this attribute.
- *
- * @see java.lang.Object#toString()
- */
- public String toString()
+ public boolean isCanUserModify()
{
- return m_oid ;
+ return canUserModify;
}
- // ------------------------------------------------------------------------
- //
- // ------------------------------------------------------------------------
-
-
- /**
- * Gets whether or not his attribute
- *
- * @return TODO
- */
- public boolean isBinary()
- {
- throw new NotImplementedException() ;
- }
-
-
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public boolean isInteger()
+ public UsageEnum getUsage()
{
- throw new NotImplementedException() ;
+ return usage;
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public boolean isDecimal()
+ public AttributeType getSuperior()
{
- throw new NotImplementedException() ;
+ return superior;
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public boolean isString()
- {
- throw new NotImplementedException() ;
- }
-
-
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public Normalizer getNormalizer()
+ public String getDesc()
{
- return m_equality.getNormalizer() ;
- }
-
-
- /**
- * TODO Document me!
- *
- * @return the sytax checker
- */
- public SyntaxChecker getSyntaxChecker()
- {
- return m_syntax.getSyntaxChecker() ;
+ return desc;
}
- /**
- *
- * TODO Document me!
- *
- * @return TODO
- */
- public Comparator getComparator()
- {
- if ( null != m_ordering )
- {
- return m_ordering.getComparator() ;
- }
- else if ( null != m_equality )
- {
- return m_equality.getComparator() ;
- }
-
- throw new IllegalStateException( "Must have a comparator for "
- + "AttributeTypeImpl " + m_oid ) ;
- }
-
-
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public ArrayList getChildren()
- {
- return m_children ;
+ public MatchingRule getEquality()
+ {
+ return equality;
}
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public String getDesc()
+ public MatchingRule getOrdering()
{
- return m_desc ;
+ return ordering;
}
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public MatchingRule getEquality()
+ public MatchingRule getSubstr()
{
- return m_equality ;
+ return substr;
}
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public ArrayList getNameList()
+ public Syntax getSyntax()
{
- return m_nameList ;
+ return syntax;
}
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public MatchingRule getOrdering()
- {
- return m_ordering ;
- }
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public MatchingRule getSubstr()
+ public int getLength()
{
- return m_substr ;
+ return length;
}
- /**
- * TODO Document me!
- *
- * @return TODO
- */
- public Syntax getSyntax()
- {
- return m_syntax ;
- }
-
-
// ------------------------------------------------------------------------
// M U T A T O R S
// ------------------------------------------------------------------------
- /**
- * TODO Document me!
- *
- * @param a_b TODO
- */
- public void setCanUserModify( boolean a_b )
+ public void setOid( String oid )
{
- m_canUserModify = a_b ;
+ this.oid = oid;
}
- /**
- * TODO Document me!
- *
- * @param a_list TODO
- */
- public void setChildren( ArrayList a_list )
- {
- m_children = a_list ;
- }
- /**
- * TODO Document me!
- *
- * @param a_string TODO
- */
- public void setDesc( String a_string )
+ public void setSuperior( AttributeType superior )
{
- m_desc = a_string ;
+ this.superior = superior;
}
- /**
- * TODO Document me!
- *
- * @param a_rule TODO
- */
- public void setEquality( MatchingRule a_rule )
+ public void setNameList( ArrayList nameList )
{
- m_equality = a_rule ;
+ this.nameList = nameList;
}
- /**
- * TODO Document me!
- *
- * @param a_b TODO
- */
- public void setSingleValue( boolean a_b )
+ public void setDesc( String desc )
{
- m_isSingleValue = a_b ;
+ this.desc = desc;
}
- /**
- * TODO Document me!
- *
- * @param a_list TODO
- */
- public void setNameList( ArrayList a_list )
+ public void setEquality( MatchingRule equality )
{
- m_nameList = a_list ;
+ this.equality = equality;
}
- /**
- * TODO Document me!
- *
- * @param a_rule TODO
- */
- public void setOrdering( MatchingRule a_rule )
+ public void setSubstr( MatchingRule substr )
{
- m_ordering = a_rule ;
+ this.substr = substr;
}
- /**
- * TODO Document me!
- *
- * @param a_rule TODO
- */
- public void setSubstr( MatchingRule a_rule )
+
+ public void setOrdering( MatchingRule ordering )
{
- m_substr = a_rule ;
+ this.ordering = ordering;
}
- /**
- * TODO Document me!
- *
- * @param a_string TODO
- */
- public void setSuperior( String a_string )
+ public void setSyntax( Syntax syntax )
{
- m_superior = a_string ;
+ this.syntax = syntax;
}
- /**
- * TODO Document me!
- *
- * @param a_syntax TODO
- */
- public void setSyntax( Syntax a_syntax )
+ public void setSingleValue( boolean singleValue )
{
- m_syntax = a_syntax ;
+ isSingleValue = singleValue;
}
- /**
- * TODO Document me!
- *
- * @param a_usage TODO
- */
- public void setUsage( UsageEnum a_usage )
+ public void setCollective( boolean collective )
{
- m_usage = a_usage ;
+ isCollective = collective;
}
- /**
- * TODO Document me!
- *
- * @return the length of the attribute
- */
- public int getLength()
+ public void setCanUserModify( boolean canUserModify )
{
- return m_length ;
+ this.canUserModify = canUserModify;
}
- /**
- * TODO Document me!
- *
- * @param a_length the length of the attribute
- */
- public void setLength( int a_length )
+ public void setObsolete( boolean obsolete )
{
- m_length = a_length ;
- }
-
-
- /**
- * TODO Document me!
- *
- * @return true if the attribute is collective, false otherwise
- */
- public boolean isCollective()
- {
- return m_isCollective ;
+ isObsolete = obsolete;
}
- /**
- * TODO Document me!
- *
- * @param a_isCollective true if the attribute is collective, false
- * otherwise
- */
- public void setCollective( boolean a_isCollective )
- {
- m_isCollective = a_isCollective ;
- }
-
-
- /**
- * @see org.apache.ldap.server.schema.attribute.AttributeType#
- * getAttributeTypeDescription()
- */
- public String getAttributeTypeDescription()
+ public void setUsage( UsageEnum usage )
{
- return "Not implemented yet" ;
+ this.usage = usage;
}
- // ------------------------------------------------------------------------
- // Attribute Specification Configuration
- // ------------------------------------------------------------------------
-
-
- /**
- * An AttributeTypeImpl bean builder.
- */
- public static class Builder
- {
- /**
- * Factory method that builds an AttributeTypeImpl form a configuration.
- *
- * @param a_config the spec configuration
- * @param a_ruleManager $todo Doc me!
- * @param a_syntaxManager $todo Doc me!
- * @return the attribute type definition stored in a configuration
- * @throws ConfigurationException if the configuration is incomplete
- */
- public static AttributeTypeImpl create( Configuration a_config,
- MatchingRuleManager a_ruleManager, SyntaxManager a_syntaxManager )
- throws ConfigurationException
- {
- AttributeTypeImpl l_type = new AttributeTypeImpl( a_config
- .getChild( "oid" ).getValue() ) ;
-
- l_type.setCanUserModify( a_config
- .getChild( "can-user-modify" ).getValueAsBoolean( true ) ) ;
- l_type.setCollective( a_config
- .getChild( "collective" ).getValueAsBoolean( false ) ) ;
- l_type.setDesc( a_config
- .getChild( "description" ).getValue( null ) ) ;
-
- try
- {
- l_type.setEquality( a_ruleManager.lookup( a_config
- .getChild( "equality" ).getValue() ) ) ;
- }
- catch ( NamingException e )
- {
- throw new ConfigurationException(
- "Failed on satisfing dependency for equality MatchingRule "
- + a_config.getChild( "equality" ).getValue()
- + " on AttributeType " + l_type.getOid(), e ) ;
- }
-
- l_type.setLength( a_config
- .getChild( "length" ).getValueAsInteger( Integer.MAX_VALUE ) ) ;
-
-
- Configuration l_ordering = a_config.getChild( "ordering", false ) ;
- if ( null == l_ordering )
- {
- l_type.setOrdering( l_type.getEquality() ) ;
- }
- else
- {
- try
- {
- l_type.setOrdering( a_ruleManager.lookup(
- l_ordering.getValue() ) ) ;
- }
- catch ( NamingException e )
- {
- throw new ConfigurationException( "MatchingRule "
- + l_ordering.getValue() + " does not exist for "
- + "attributeType " + l_type.getName(), e ) ;
- }
- }
-
- l_type.setSingleValue( a_config
- .getChild( "single-value" ).getValueAsBoolean( false ) ) ;
-
- Configuration l_substr = a_config.getChild( "substr", false ) ;
- if ( null == l_substr )
- {
- l_type.setSubstr( l_type.getEquality() ) ;
- }
- else
- {
- try
- {
- l_type.setSubstr( a_ruleManager.lookup(
- l_substr.getValue( null ) ) ) ;
- }
- catch ( NamingException e )
- {
- throw new ConfigurationException(
- "Failed satisfing dependency for substr MatchingRule "
- + a_config.getChild( "substr" ).getValue()
- + " on AttributeType " + l_type.getOid(), e ) ;
- }
- }
-
- l_type.setSuperior( a_config
- .getChild( "superior", true ).getValue( null ) ) ;
-
- try
- {
- l_type.setSyntax( a_syntaxManager.lookup( a_config
- .getChild( "syntax" ).getValue() ) ) ;
- }
- catch ( NamingException e )
- {
- throw new ConfigurationException(
- "Failed on satisfing dependency for Syntax "
- + a_config.getChild( "syntax" ).getValue()
- + " on AttributeType " + l_type.getOid(), e ) ;
- }
-
- l_type.setUsage( UsageEnum.getUsage( a_config
- .getChild( "usage" ).getValue(
- UsageEnum.USERAPPLICATIONS.getName() ) ) ) ;
-
- Configuration [] l_names = a_config
- .getChild( "names" ).getChildren() ;
- ArrayList l_list = new ArrayList( 2 ) ;
-
- for ( int ii = 0; ii < l_names.length; ii++ )
- {
- l_list.add( l_names[ii].getValue() ) ;
- }
-
- l_type.setNameList( l_list ) ;
- return l_type ;
- }
-
-
- /**
- * Factory method that builds an AttributeTypeImpl form a configuration.
- *
- * @param a_attributes $todo Doc me!
- * @param a_ruleManager $todo Doc me!
- * @param a_syntaxManager $todo Doc me!
- * @return the attribute type definition stored in a configuration
- * @throws NamingException if the required attributes are not found
- */
- public static AttributeTypeImpl create( Attributes a_attributes,
- MatchingRuleManager a_ruleManager, SyntaxManager a_syntaxManager )
- throws NamingException
- {
- AttributeTypeImpl l_type = null ;
- Attribute l_oid = a_attributes.get( "oid" ) ;
-
- if ( null == l_oid )
- {
- throw new NamingException( "OID required for attributeType" ) ;
- }
-
- l_type = new AttributeTypeImpl( ( String ) l_oid.get() ) ;
- l_type.setCanUserModify( getBoolean(
- a_attributes.get( "can-user-modify" ) ) ) ;
- l_type.setCollective( getBoolean(
- a_attributes.get( "collective" ) ) ) ;
- l_type.setDesc( ( String )
- a_attributes.get( "description" ).get() ) ;
- l_type.setEquality( a_ruleManager.lookup( ( String )
- a_attributes.get( "equality" ).get() ) ) ;
- l_type.setLength( Integer.parseInt( ( String )
- a_attributes.get( "length" ).get() ) ) ;
- l_type.setOrdering( a_ruleManager.lookup( ( String )
- a_attributes.get( "ordering" ).get() ) ) ;
- l_type.setSingleValue( getBoolean(
- a_attributes.get( "single-value" ) ) ) ;
- l_type.setSubstr( a_ruleManager.lookup( ( String )
- a_attributes.get( "substr" ).get() ) ) ;
- l_type.setSuperior( ( String )
- a_attributes.get( "superior" ).get() ) ;
- l_type.setSyntax( a_syntaxManager.lookup( ( String )
- a_attributes.get( "syntax" ).get() ) ) ;
- l_type.setUsage( UsageEnum.getUsage( ( String )
- a_attributes.get( "usage" ).get() ) ) ;
-
- return l_type ;
- }
-
-
- /**
- * Gets a boolean from an Attribute.
- *
- * @param a_attr the attribute to convert to a boolean
- * @return true if attribute has a '1', 'true' or 'yes' value false
- * otherwise
- * @throws NamingException on failure to access attribute data
- */
- private static boolean getBoolean( Attribute a_attr )
- throws NamingException
- {
- String l_value = ( String ) a_attr.get() ;
-
- return l_value.equals( "1" ) ||
- l_value.equalsIgnoreCase( "true" ) ||
- l_value.equalsIgnoreCase( "yes" ) ;
- }
+ public void setLength( int length )
+ {
+ this.length = length;
}
}