Package org.forgerock.opendj.ldap.schema
Class Syntax
- java.lang.Object
-
- org.forgerock.opendj.ldap.schema.Syntax
-
- All Implemented Interfaces:
SchemaElement
public final class Syntax extends Object
This class defines a data structure for storing and interacting with an LDAP syntaxes, which constrain the structure of attribute values stored in an LDAP directory, and determine the representation of attribute and assertion values transferred in the LDAP protocol.Syntax implementations must extend the
SyntaxImplinterface so they can be used by OpenDJ to validate attribute values.Where ordered sets of names, or extra properties are provided, the ordering will be preserved when the associated fields are accessed via their getters or via the
Object.toString()methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSyntax.BuilderA fluent API for incrementally constructing syntaxes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Returnstrueif the provided object is an attribute syntax having the same numeric OID as this attribute syntax.ByteStringfromJson(Object value)Decodes the JSON representation of an attribute value with this syntax.MatchingRulegetApproximateMatchingRule()Retrieves the default approximate matching rule that will be used for attributes with this syntax.StringgetDescription()Returns the description of this schema element, or the empty string if it does not have a description.MatchingRulegetEqualityMatchingRule()Retrieves the default equality matching rule that will be used for attributes with this syntax.Map<String,List<String>>getExtraProperties()Returns an unmodifiable map containing all of the extra properties associated with this schema element.StringgetName()Retrieves the name for this attribute syntax.StringgetOid()Retrieves the OID for this attribute syntax.MatchingRulegetOrderingMatchingRule()Retrieves the default ordering matching rule that will be used for attributes with this syntax.MatchingRulegetSubstringMatchingRule()Retrieves the default substring matching rule that will be used for attributes with this syntax.inthashCode()Returns the hash code for this attribute syntax.booleanisBerEncodingRequired()Indicates whether this attribute syntax requires that values must be encoded using the Basic Encoding Rules (BER) used by X.500 directories and always include thebinaryattribute description option.booleanisHumanReadable()Indicates whether this attribute syntax would likely be a human readable string.ObjecttoJson(ByteString value)Encodes the JSON representation of an attribute value with this syntax.Map<String,Object>toJsonSchema()Returns the JSON schema describing this syntax.StringtoString()Returns the string representation of this schema element as defined in RFC 2252.booleanvalueIsAcceptable(ByteString value, LocalizableMessageBuilder invalidReason)Indicates whether the provided value is acceptable for use in an attribute with this syntax.
-
-
-
Method Detail
-
equals
public boolean equals(Object o)
Returnstrueif the provided object is an attribute syntax having the same numeric OID as this attribute syntax.- Parameters:
o- The object to be compared.- Returns:
trueif the provided object is an attribute syntax having the same numeric OID as this attribute syntax.
-
getApproximateMatchingRule
public MatchingRule getApproximateMatchingRule()
Retrieves the default approximate matching rule that will be used for attributes with this syntax.- Returns:
- The default approximate matching rule that will be used for
attributes with this syntax, or
nullif approximate matches will not be allowed for this type by default.
-
getEqualityMatchingRule
public MatchingRule getEqualityMatchingRule()
Retrieves the default equality matching rule that will be used for attributes with this syntax.- Returns:
- The default equality matching rule that will be used for
attributes with this syntax, or
nullif equality matches will not be allowed for this type by default.
-
getOid
public String getOid()
Retrieves the OID for this attribute syntax.- Returns:
- The OID for this attribute syntax.
-
getName
public String getName()
Retrieves the name for this attribute syntax.- Returns:
- The name for this attribute syntax.
-
getOrderingMatchingRule
public MatchingRule getOrderingMatchingRule()
Retrieves the default ordering matching rule that will be used for attributes with this syntax.- Returns:
- The default ordering matching rule that will be used for
attributes with this syntax, or
nullif ordering matches will not be allowed for this type by default.
-
getSubstringMatchingRule
public MatchingRule getSubstringMatchingRule()
Retrieves the default substring matching rule that will be used for attributes with this syntax.- Returns:
- The default substring matching rule that will be used for
attributes with this syntax, or
nullif substring matches will not be allowed for this type by default.
-
hashCode
public int hashCode()
Returns the hash code for this attribute syntax. It will be calculated as the hash code of the numeric OID.- Returns:
- The hash code for this attribute syntax.
-
isBerEncodingRequired
public boolean isBerEncodingRequired()
Indicates whether this attribute syntax requires that values must be encoded using the Basic Encoding Rules (BER) used by X.500 directories and always include thebinaryattribute description option.- Returns:
truethis attribute syntax requires that values must be BER encoded and always include thebinaryattribute description option, orfalseif not.- See Also:
- RFC 4522 - Lightweight Directory Access Protocol (LDAP): The Binary Encoding Option
-
isHumanReadable
public boolean isHumanReadable()
Indicates whether this attribute syntax would likely be a human readable string.- Returns:
trueif this attribute syntax would likely be a human readable string orfalseif not.
-
valueIsAcceptable
public boolean valueIsAcceptable(ByteString value, LocalizableMessageBuilder invalidReason)
Indicates whether the provided value is acceptable for use in an attribute with this syntax. If it is not, then the reason may be appended to the provided buffer.- Parameters:
value- The value for which to make the determination.invalidReason- The buffer to which the invalid reason should be appended.- Returns:
trueif the provided value is acceptable for use with this syntax, orfalseif not.
-
toJson
public Object toJson(ByteString value)
Encodes the JSON representation of an attribute value with this syntax.- Parameters:
value- The attribute value to be encoded.- Returns:
- The encoded JSON representation.
- Throws:
LocalizedIllegalArgumentException- If the provided attribute value does not conform to this syntax.
-
fromJson
public ByteString fromJson(Object value)
Decodes the JSON representation of an attribute value with this syntax.- Parameters:
value- The JSON representation to be decoded.- Returns:
- The decoded attribute value.
- Throws:
LocalizedIllegalArgumentException- If the provided JSON value does not conform to this syntax.
-
toJsonSchema
public Map<String,Object> toJsonSchema()
Returns the JSON schema describing this syntax.- Returns:
- The JSON schema.
-
getDescription
public final String getDescription()
Description copied from interface:SchemaElementReturns the description of this schema element, or the empty string if it does not have a description.- Specified by:
getDescriptionin interfaceSchemaElement- Returns:
- The description of this schema element, or the empty string if it does not have a description.
-
getExtraProperties
public final Map<String,List<String>> getExtraProperties()
Description copied from interface:SchemaElementReturns an unmodifiable map containing all of the extra properties associated with this schema element.- Specified by:
getExtraPropertiesin interfaceSchemaElement- Returns:
- An unmodifiable map containing all of the extra properties associated with this schema element.
-
-