ObjectClass.java revision 407bb81fb935e713a4a1ae1b9189b81488a944d5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2013-2014 ForgeRock AS.
*/
/**
* This class defines a data structure for storing and interacting
* with an objectclass, which contains a collection of attributes that
* <p>
* Any methods which accesses the set of names associated with this
* object class, will retrieve the primary name as the first name,
* regardless of whether or not it was contained in the original set
* of <code>names</code> passed to the constructor.
* <p>
* Where ordered sets of names, attribute types, or extra properties
* are provided, the ordering will be preserved when the associated
* fields are accessed via their getters or via the
* {@link #toString()} methods.
*/
mayInstantiate=false,
mayExtend=false,
mayInvoke=true)
public final class ObjectClass
extends CommonSchemaElements
{
// The set of optional attribute types for this objectclass.
// The set of optional attribute types for this objectclass and its
// superclasses.
// The set of required attribute types for this objectclass.
// The set of required attribute types for this objectclass and its
// superclasses.
// The set of required and optional attributes for this objectclass
// and its superclasses.
// The reference to one or more superior objectclasses.
// The objectclass type for this objectclass.
private final ObjectClassType objectClassType;
// Indicates whether or not this object class is allowed to
// contain any attribute.
private final boolean isExtensibleObject;
// The definition string used to create this objectclass.
private final String definition;
// True once this object class has been removed from the schema.
private volatile boolean isDirty = false;
/**
* Creates a new objectclass definition with the provided
* information.
* <p>
* If no <code>primaryName</code> is specified, but a set of
* <code>names</code> is specified, then the first name retrieved
* from the set of <code>names</code> will be used as the primary
* name.
*
* @param definition
* The definition string used to create this objectclass.
* It must not be {@code null}.
* @param primaryName
* The primary name for this objectclass, or
* {@code null} if there is no primary name.
* @param names
* The set of names that may be used to reference this
* objectclass.
* @param oid
* The OID for this objectclass. It must not be
* {@code null}.
* @param description
* The description for this objectclass, or {@code null} if
* there is no description.
* @param superiorClasses
* The superior classes for this objectclass, or
* {@code null} if there is no superior object class.
* @param requiredAttributes
* The set of required attribute types for this
* objectclass.
* @param optionalAttributes
* The set of optional attribute types for this
* objectclass.
* @param objectClassType
* The objectclass type for this objectclass, or
* {@code null} to default to structural.
* @param isObsolete
* Indicates whether this objectclass is declared
* "obsolete".
* @param extraProperties
* A set of extra properties for this objectclass.
*/
boolean isObsolete,
{
// Construct unmodifiable views of the superior classes.
if (superiorClasses != null) {
this.superiorClasses = Collections
} else {
}
if (schemaFilePos > 0)
{
try
{
firstQuotePos+1);
}
catch (Exception e)
{
logger.traceException(e);
defStr = definition;
}
this.definition = defStr;
}
else
{
this.definition = definition;
}
// Set flag indicating whether or not this object class allows any
// attributes.
this.isExtensibleObject = true;
} else {
this.isExtensibleObject = false;
}
// Construct unmodifiable views of the required attributes.
if (requiredAttributes != null) {
this.requiredAttributes = Collections
} else {
}
if (this.superiorClasses.isEmpty()) {
this.requiredAttributesChain = this.requiredAttributes;
} else {
this.requiredAttributes);
{
}
}
// Construct unmodifiable views of the optional attributes.
if (optionalAttributes != null) {
this.optionalAttributes = Collections
} else {
}
if (this.superiorClasses.isEmpty()) {
this.optionalAttributesChain = this.optionalAttributes;
} else {
this.optionalAttributes);
{
}
}
// Construct unmodifiable views of the required and optional
// attribute chains.
// Object class type defaults to structural.
if (objectClassType != null) {
this.objectClassType = objectClassType;
} else {
}
}
/**
* Retrieves an unmodifiable view of the set of direct superior
* classes for this objectclass.
*
* @return An unmodifiable view of the set of direct superior
* classes for this objectclass,
*/
return superiorClasses;
}
/**
* Indicates whether this objectclass is a descendant of the
* provided class.
*
* @param objectClass
* The objectClass for which to make the determination.
* @return <code>true</code> if this objectclass is a descendant
* of the provided class, or <code>false</code> if not.
*/
return true;
}
}
return false;
}
/**
* Retrieves an unmodifiable view of the set of required attributes
* for this objectclass. Note that this set will not automatically
* include any required attributes for superior objectclasses.
*
* @return Returns an unmodifiable view of the set of required
* attributes for this objectclass.
*/
return requiredAttributes;
}
/**
* Retrieves an unmodifiable view of the set of all required
* attributes for this objectclass and any superior objectclasses
* that it might have.
*
* @return Returns an unmodifiable view of the set of all required
* attributes for this objectclass and any superior
* objectclasses that it might have.
*/
return requiredAttributesChain;
}
/**
* Indicates whether the provided attribute type is included in the
* required attribute list for this or any of its superior
* objectclasses.
*
* @param attributeType
* The attribute type for which to make the determination.
* @return <code>true</code> if the provided attribute type is
* required by this objectclass or any of its superior
* classes, or <code>false</code> if not.
*/
}
/**
* Retrieves an unmodifiable view of the set of optional attributes
* for this objectclass. Note that this list will not automatically
* include any optional attributes for superior objectclasses.
*
* @return Returns an unmodifiable view of the set of optional
* attributes for this objectclass.
*/
return optionalAttributes;
}
/**
* Retrieves an unmodifiable view of the set of optional attributes
* for this objectclass and any superior objectclasses that it might
* have.
*
* @return Returns an unmodifiable view of the set of optional
* attributes for this objectclass and any superior
* objectclasses that it might have.
*/
return optionalAttributesChain;
}
/**
* Indicates whether the provided attribute type is included in the
* optional attribute list for this or any of its superior
* objectclasses.
*
* @param attributeType
* The attribute type for which to make the determination.
* @return <code>true</code> if the provided attribute type is
* optional for this objectclass or any of its superior
* classes, or <code>false</code> if not.
*/
return true;
}
// FIXME -- Do we need to do other checks here, like whether the
// attribute type is actually defined in the schema?
// What about DIT content rules?
return true;
}
return false;
}
/**
* Indicates whether the provided attribute type is in the list of
* required or optional attributes for this objectclass or any of
* its superior classes.
*
* @param attributeType
* The attribute type for which to make the determination.
* @return <code>true</code> if the provided attribute type is
* required or allowed for this objectclass or any of its
* superior classes, or <code>false</code> if it is not.
*/
// FIXME -- Do we need to do any other checks here, like whether
// the attribute type is actually defined in the schema?
return (isExtensibleObject ||
}
/**
* Retrieves the objectclass type for this objectclass.
*
* @return The objectclass type for this objectclass.
*/
public ObjectClassType getObjectClassType() {
return objectClassType;
}
/**
* Indicates whether this objectclass is the extensibleObject
* objectclass.
*
* @return <code>true</code> if this objectclass is the
* extensibleObject objectclass, or <code>false</code> if
* it is not.
*/
public boolean isExtensibleObject() {
return isExtensibleObject;
}
/** {@inheritDoc} */
{
return definition;
}
/**
* Marks this object class as dirty, indicating that it has been removed or
* replaced in the schema.
*
* @return A reference to this object class.
*/
public ObjectClass setDirty()
{
isDirty = true;
return this;
}
/**
* Returns {@code true} if this object class has been removed or replaced in
* the schema.
*
* @return {@code true} if this object class has been removed or replaced in
* the schema.
*/
public boolean isDirty()
{
return isDirty;
}
}