| | |
| | | |
| | | |
| | | |
| | | import static com.sun.opends.sdk.messages.Messages.*; |
| | | import static com.sun.opends.sdk.messages.Messages.ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR; |
| | | import static com.sun.opends.sdk.messages.Messages.ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_MATCHING_RULE; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting with |
| | | * a matching rule use definition, which may be used to restrict the set |
| | | * of attribute types that may be used for a given matching rule. |
| | | * This class defines a data structure for storing and interacting with a |
| | | * matching rule use definition, which may be used to restrict the set of |
| | | * attribute types that may be used for a given matching rule. |
| | | */ |
| | | public final class MatchingRuleUse extends SchemaElement |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | MatchingRuleUse(String oid, List<String> names, String description, |
| | | boolean obsolete, Set<String> attributeOIDs, |
| | | Map<String, List<String>> extraProperties, String definition) |
| | | MatchingRuleUse(final String oid, final List<String> names, |
| | | final String description, final boolean obsolete, |
| | | final Set<String> attributeOIDs, |
| | | final Map<String, List<String>> extraProperties, final String definition) |
| | | { |
| | | super(description, extraProperties); |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the set of attributes associated with this matching rule |
| | | * use. |
| | | * |
| | | * @return The set of attributes associated with this matching rule |
| | | * use. |
| | | * Returns an unmodifiable set containing the attributes associated with this |
| | | * matching rule use. |
| | | * |
| | | * @return An unmodifiable set containing the attributes associated with this |
| | | * matching rule use. |
| | | */ |
| | | public Iterable<AttributeType> getAttributes() |
| | | public Set<AttributeType> getAttributes() |
| | | { |
| | | return attributes; |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the matching rule for this matching rule use. |
| | | * |
| | | * Returns the matching rule for this matching rule use. |
| | | * |
| | | * @return The matching rule for this matching rule use. |
| | | */ |
| | | public MatchingRule getMatchingRule() |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the matching rule OID for this schema definition. |
| | | * |
| | | * Returns the matching rule OID for this schema definition. |
| | | * |
| | | * @return The OID for this schema definition. |
| | | */ |
| | | public String getMatchingRuleOID() |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the name or matching rule OID for this schema definition. |
| | | * If it has one or more names, then the primary name will be |
| | | * returned. If it does not have any names, then the OID will be |
| | | * returned. |
| | | * |
| | | * Returns the name or matching rule OID for this schema definition. If it has |
| | | * one or more names, then the primary name will be returned. If it does not |
| | | * have any names, then the OID will be returned. |
| | | * |
| | | * @return The name or OID for this schema definition. |
| | | */ |
| | | public String getNameOrOID() |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves an iterable over the set of user-defined names that may |
| | | * be used to reference this schema definition. |
| | | * |
| | | * @return Returns an iterable over the set of user-defined names that |
| | | * Returns an unmodifiable list containing the user-defined names that may be |
| | | * used to reference this schema definition. |
| | | * |
| | | * @return Returns an unmodifiable list containing the user-defined names that |
| | | * may be used to reference this schema definition. |
| | | */ |
| | | public Iterable<String> getNames() |
| | | public List<String> getNames() |
| | | { |
| | | return names; |
| | | } |
| | |
| | | /** |
| | | * Indicates whether the provided attribute type is referenced by this |
| | | * matching rule use. |
| | | * |
| | | * |
| | | * @param attributeType |
| | | * The attribute type for which to make the determination. |
| | | * @return {@code true} if the provided attribute type is referenced |
| | | * by this matching rule use, or {@code false} if it is not. |
| | | * @return {@code true} if the provided attribute type is referenced by this |
| | | * matching rule use, or {@code false} if it is not. |
| | | */ |
| | | public boolean hasAttribute(AttributeType attributeType) |
| | | public boolean hasAttribute(final AttributeType attributeType) |
| | | { |
| | | return attributes.contains(attributeType); |
| | | } |
| | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition has the specified name. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name for which to make the determination. |
| | | * @return <code>true</code> if the specified name is assigned to this |
| | | * schema definition, or <code>false</code> if not. |
| | | * @return <code>true</code> if the specified name is assigned to this schema |
| | | * definition, or <code>false</code> if not. |
| | | */ |
| | | public boolean hasName(String name) |
| | | public boolean hasName(final String name) |
| | | { |
| | | for (final String n : names) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition has the specified name or |
| | | * matching rule OID. |
| | | * |
| | | * Indicates whether this schema definition has the specified name or matching |
| | | * rule OID. |
| | | * |
| | | * @param value |
| | | * The value for which to make the determination. |
| | | * @return <code>true</code> if the provided value matches the OID or |
| | | * one of the names assigned to this schema definition, or |
| | | * <code>false</code> if not. |
| | | * @return <code>true</code> if the provided value matches the OID or one of |
| | | * the names assigned to this schema definition, or <code>false</code> |
| | | * if not. |
| | | */ |
| | | public boolean hasNameOrOID(String value) |
| | | public boolean hasNameOrOID(final String value) |
| | | { |
| | | return hasName(value) || oid.equals(value); |
| | | } |
| | |
| | | |
| | | /** |
| | | * Indicates whether this schema definition is declared "obsolete". |
| | | * |
| | | * @return <code>true</code> if this schema definition is declared |
| | | * "obsolete", or <code>false</code> if not. |
| | | * |
| | | * @return <code>true</code> if this schema definition is declared "obsolete", |
| | | * or <code>false</code> if not. |
| | | */ |
| | | public boolean isObsolete() |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the string representation of this schema definition in |
| | | * the form specified in RFC 2252. |
| | | * |
| | | * @return The string representation of this schema definition in the |
| | | * form specified in RFC 2252. |
| | | * Returns the string representation of this schema definition in the form |
| | | * specified in RFC 2252. |
| | | * |
| | | * @return The string representation of this schema definition in the form |
| | | * specified in RFC 2252. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | |
| | | |
| | | |
| | | @Override |
| | | void toStringContent(StringBuilder buffer) |
| | | void toStringContent(final StringBuilder buffer) |
| | | { |
| | | buffer.append(oid); |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | void validate(List<LocalizableMessage> warnings, Schema schema) |
| | | void validate(final List<LocalizableMessage> warnings, final Schema schema) |
| | | throws SchemaException |
| | | { |
| | | try |
| | |
| | | { |
| | | // This is bad because the matching rule use is associated with a |
| | | // matching rule that we don't know anything about. |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_MATCHING_RULE.get(definition, |
| | | oid); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_MATCHING_RULE |
| | | .get(definition, oid); |
| | | throw new SchemaException(message, e); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, attribute); |
| | | final LocalizableMessage message = ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR |
| | | .get(oid, attribute); |
| | | throw new SchemaException(message, e); |
| | | } |
| | | attributes.add(attributeType); |
| | | } |
| | | attributes = Collections.unmodifiableSet(attributes); |
| | | } |
| | | } |