NameForm.java revision 66be6c035cb58baccacb6831f7403d5c2247f4b2
/*
* 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 2009 Sun Microsystems, Inc.
* Portions copyright 2011-2013 ForgeRock AS
*/
import static com.forgerock.opendj.ldap.CoreMessages.ERR_ATTR_SYNTAX_NAME_FORM_STRUCTURAL_CLASS_NOT_STRUCTURAL1;
import static com.forgerock.opendj.ldap.CoreMessages.ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR1;
import static com.forgerock.opendj.ldap.CoreMessages.ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR1;
import static com.forgerock.opendj.ldap.CoreMessages.ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_STRUCTURAL_CLASS1;
/**
* This class defines a data structure for storing and interacting with a name
* RDN of an entry with a given structural objectclass.
*/
public final class NameForm extends SchemaElement {
/**
* A fluent API for incrementally constructing name forms.
*/
private boolean isObsolete = false;
private String structuralObjectClassOID;
}
super(builder);
}
/**
* Adds this name form to the schema overwriting any existing name form
* with the same numeric OID.
*
* @return The parent schema builder.
*/
public SchemaBuilder addToSchemaOverwrite() {
}
/**
* Adds this name form to the schema, throwing an
* {@code ConflictingSchemaElementException} if there is an existing
* name form with the same numeric OID.
*
* @return The parent schema builder.
* @throws ConflictingSchemaElementException
* If there is an existing name form with the same numeric
* OID.
*/
public SchemaBuilder addToSchema() {
}
return description0(description);
}
return extraProperties0(extraProperties);
}
}
/**
* Adds the provided user friendly names.
*
* @param names
* The user friendly names.
* @return This builder.
*/
return this;
}
/**
* Adds the provided user friendly names.
*
* @param names
* The user friendly names.
* @return This builder.
*/
}
/**
* Specifies whether or not this schema element is obsolete.
*
* @param isObsolete
* {@code true} if this schema element is obsolete (default
* is {@code false}).
* @return This builder.
*/
this.isObsolete = isObsolete;
return this;
}
/**
* Sets the numeric OID which uniquely identifies this name form.
*
* @param oid
* The numeric OID.
* @return This builder.
*/
return this;
}
/**
* Adds the provided optional attributes.
*
* @param nameOrOIDs
* The list of optional attributes.
* @return This builder.
*/
return this;
}
/**
* Adds the provided optional attributes.
*
* @param nameOrOIDs
* The list of optional attributes.
* @return This builder.
*/
}
public Builder removeAllExtraProperties() {
return removeAllExtraProperties0();
}
/**
* Removes all user friendly names.
*
* @return This builder.
*/
public Builder removeAllNames() {
return this;
}
/**
* Removes all optional attributes.
*
* @return This builder.
*/
public Builder removeAllOptionalAttributes() {
this.optionalAttributes.clear();
return this;
}
/**
* Removes all required attributes.
*
* @return This builder.
*/
public Builder removeAllRequiredAttributes() {
this.requiredAttributes.clear();
return this;
}
final String... extensionValues) {
}
/**
* Removes the provided user friendly name.
*
* @param name
* The user friendly name to be removed.
* @return This builder.
*/
return this;
}
/**
* Removes the specified optional attribute.
*
* @param nameOrOID
* The optional attribute to be removed.
* @return This builder.
*/
return this;
}
/**
* Removes the specified required attribute.
*
* @param nameOrOID
* The required attribute to be removed.
* @return This builder.
*/
return this;
}
/**
* Adds the provided required attributes.
*
* @param nameOrOIDs
* The list of required attributes.
* @return This builder.
*/
return this;
}
/**
* Adds the provided required attributes.
*
* @param nameOrOIDs
* The list of required attributes.
* @return This builder.
*/
}
/**
* Sets the structural object class.
*
* @param nameOrOID
* The structural object class.
* @return This builder.
*/
this.structuralObjectClassOID = nameOrOID;
return this;
}
return this;
}
}
/** Indicates whether this definition is declared "obsolete". */
private final boolean isObsolete;
/** The set of user defined names for this definition. */
/** The OID that may be used to reference this definition. */
/** The set of optional attribute types for this name form. */
/** The set of required attribute types for this name form. */
/** The reference to the structural objectclass for this name form. */
private ObjectClass structuralClass;
private final String structuralClassOID;
super(builder);
// Checks for required attributes.
throw new IllegalArgumentException("An OID must be specified.");
}
throw new IllegalArgumentException("A structural class OID must be specified.");
}
throw new IllegalArgumentException("Required attribute must be specified.");
}
}
/**
* Returns {@code true} if the provided object is a name form having the
* same numeric OID as this name form.
*
* @param o
* The object to be compared.
* @return {@code true} if the provided object is a name form having the
* same numeric OID as this name form.
*/
if (this == o) {
return true;
} else if (o instanceof NameForm) {
} else {
return false;
}
}
/**
* Returns the name or numeric OID of this name form. If it has one or more
* names, then the primary name will be returned. If it does not have any
* names, then the numeric OID will be returned.
*
* @return The name or numeric OID of this name form.
*/
public String getNameOrOID() {
return oid;
}
}
/**
* Returns an unmodifiable list containing the user-friendly names that may
* be used to reference this name form.
*
* @return An unmodifiable list containing the user-friendly names that may
* be used to reference this name form.
*/
return names;
}
/**
* Returns the numeric OID of this name form.
*
* @return The numeric OID of this name form.
*/
return oid;
}
/**
* Returns an unmodifiable set containing the optional attributes of this
* name form.
*
* @return An unmodifiable set containing the optional attributes of this
* name form.
*/
return optionalAttributes;
}
/**
* Returns an unmodifiable set containing the required attributes of this
* name form.
*
* @return An unmodifiable set containing the required attributes of this
* name form.
*/
return requiredAttributes;
}
/**
* Returns the structural objectclass of this name form.
*
* @return The structural objectclass of this name form.
*/
public ObjectClass getStructuralClass() {
return structuralClass;
}
/**
* Returns the hash code for this name form. It will be calculated as the
* hash code of the numeric OID.
*
* @return The hash code for this name form.
*/
public int hashCode() {
}
/**
* Returns {@code true} if this name form has the specified user-friendly
* name.
*
* @param name
* The name.
* @return {@code true} if this name form has the specified user-friendly
* name.
*/
if (n.equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
/**
* Returns {@code true} if this name form has the specified user-friendly
* name or numeric OID.
*
* @param nameOrOID
* The name or numeric OID.
* @return {@code true} if this name form has the specified user-friendly
* name or numeric OID.
*/
}
/**
* Returns {@code true} if this name form is "obsolete".
*
* @return {@code true} if this name form is "obsolete".
*/
public boolean isObsolete() {
return isObsolete;
}
/**
* Returns {@code true} if the provided attribute type is included in the
* list of optional attributes for this name form.
*
* @param attributeType
* The attribute type.
* @return {@code true} if the provided attribute type is included in the
* list of optional attributes for this name form.
*/
}
/**
* Returns {@code true} if the provided attribute type is included in the
* list of required attributes for this name form.
*
* @param attributeType
* The attribute type.
* @return {@code true} if the provided attribute type is included in the
* list of required attributes for this name form.
*/
}
/**
* Returns {@code true} if the provided attribute type is included in the
* list of optional or required attributes for this name form.
*
* @param attributeType
* The attribute type.
* @return {@code true} if the provided attribute type is included in the
* list of optional or required attributes for this name form.
*/
}
}
} else {
}
}
if (isObsolete) {
}
if (!requiredAttributeOIDs.isEmpty()) {
}
} else {
}
}
if (!optionalAttributeOIDs.isEmpty()) {
}
} else {
}
}
}
throws SchemaException {
try {
} catch (final UnknownSchemaElementException e) {
final LocalizableMessage message =
throw new SchemaException(message, e);
}
// This is bad because the associated structural class type is not
// structural.
final LocalizableMessage message =
.getObjectClassType()));
throw new SchemaException(message);
}
try {
} catch (final UnknownSchemaElementException e) {
// This isn't good because it means that the name form requires
// an attribute type that we don't know anything about.
final LocalizableMessage message =
throw new SchemaException(message, e);
}
}
if (!optionalAttributeOIDs.isEmpty()) {
try {
} catch (final UnknownSchemaElementException e) {
// This isn't good because it means that the name form
// requires an attribute type that we don't know anything
// about.
final LocalizableMessage message =
oid);
throw new SchemaException(message, e);
}
}
}
}
}