Class SchemaUtils
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.SchemaUtils
-
public final class SchemaUtils extends Object
Various utility methods for schema functions and objects.- Author:
- Apache Directory Project
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<String>getOptions(String attributeId)Get the options from the attributeType.static EntrygetTargetEntry(List<? extends Modification> mods, Entry entry)Gets the target entry as it would look after a modification operation were performed on it.static booleanisAttributeNameValid(String attributeName)Tells if an AttributeType name is valid or not.static StringBuilderrender(StringBuilder buf, List<String> qdescrs)Renders qdescrs into an existing buffer.static StringBuilderrender(StringBuilder buf, AttributeType[] ats)Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format into an existing buffer.static StringBuilderrender(StringBuilder buf, ObjectClass[] ocs)Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format into an existing buffer.static StringBuilderrender(Map<String,List<String>> extensions)Renders the schema extensions into a new StringBuffer.static StringBuilderrender(AttributeType[] ats)Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format.static Stringrender(LoadableSchemaObject description)Returns a String description of a schema.static StringBuilderrender(ObjectClass[] ocs)Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format.(package private) static StringBuilderrenderQDescrs(StringBuilder buf, List<String> qdescrs)Renders qdescrs into a new buffer.static StringstripOptions(String attributeId)Remove the options from the attributeType, and returns the ID.static byte[]uuidToBytes(UUID uuid)Transform an UUID in a byte array
-
-
-
Method Detail
-
getTargetEntry
public static Entry getTargetEntry(List<? extends Modification> mods, Entry entry) throws LdapException
Gets the target entry as it would look after a modification operation were performed on it.- Parameters:
mods- the modifications performed on the entryentry- the source entry that is modified- Returns:
- the resultant entry after the modifications have taken place
- Throws:
LdapException- if there are problems accessing attributes
-
render
public static StringBuilder render(StringBuilder buf, List<String> qdescrs)
Renders qdescrs into an existing buffer.- Parameters:
buf- the string buffer to render the quoted description strs intoqdescrs- the quoted description strings to render- Returns:
- the same string buffer that was given for call chaining
-
renderQDescrs
static StringBuilder renderQDescrs(StringBuilder buf, List<String> qdescrs)
Renders qdescrs into a new buffer.
descrs ::= qdescr | '(' WSP qdescrlist WSP ')' qdescrlist ::= [ qdescr ( SP qdescr )* ] qdescr ::= SQUOTE descr SQUOTE- Parameters:
buf- the string buffer to render the quoted description strings intoqdescrs- the quoted description strings to render- Returns:
- the string buffer the qdescrs are rendered into
-
render
public static StringBuilder render(ObjectClass[] ocs)
Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format.- Parameters:
ocs- the objectClasses to list- Returns:
- a buffer which contains the rendered list
-
render
public static StringBuilder render(StringBuilder buf, ObjectClass[] ocs)
Renders a list of object classes for things like a list of superior objectClasses using the ( oid $ oid ) format into an existing buffer.- Parameters:
buf- the string buffer to render the list of objectClasses intoocs- the objectClasses to list- Returns:
- a buffer which contains the rendered list
-
render
public static StringBuilder render(AttributeType[] ats)
Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format.- Parameters:
ats- the attributeTypes to list- Returns:
- a buffer which contains the rendered list
-
render
public static StringBuilder render(StringBuilder buf, AttributeType[] ats)
Renders a list of attributeTypes for things like the must or may list of objectClasses using the ( oid $ oid ) format into an existing buffer.- Parameters:
buf- the string buffer to render the list of attributeTypes intoats- the attributeTypes to list- Returns:
- a buffer which contains the rendered list
-
render
public static StringBuilder render(Map<String,List<String>> extensions)
Renders the schema extensions into a new StringBuffer.- Parameters:
extensions- the schema extensions map with key and values- Returns:
- a StringBuffer with the extensions component of a syntax description
-
render
public static String render(LoadableSchemaObject description)
Returns a String description of a schema. The resulting String format is :
(OID [DESC '<description>'] FQCN <fcqn> [BYTECODE <bytecode>] X-SCHEMA '<schema>')- Parameters:
description- The description to transform to a String- Returns:
- The rendered schema object
-
stripOptions
public static String stripOptions(String attributeId)
Remove the options from the attributeType, and returns the ID.
RFC 4512 :attributedescription = attributetype options attributetype = oid options = *( SEMI option ) option = 1*keychar
- Parameters:
attributeId- The AttributeType to parse- Returns:
- The AttributeType without its options
-
getOptions
public static Set<String> getOptions(String attributeId)
Get the options from the attributeType.
For instance, given : jpegphoto;binary;lang=jp
your get back a set containing { "binary", "lang=jp" }- Parameters:
attributeId- The AttributeType to parse- Returns:
- a Set of options found for this AttributeType, or null
-
uuidToBytes
public static byte[] uuidToBytes(UUID uuid)
Transform an UUID in a byte array- Parameters:
uuid- The UUID to transform- Returns:
- The byte[] representing the UUID
-
isAttributeNameValid
public static boolean isAttributeNameValid(String attributeName)
Tells if an AttributeType name is valid or not. An Attribute name is valid if it's a descr / numericoid, as described in rfc4512 :name = descr / numericOid descr = keystring keystring = leadkeychar *keychar leadkeychar = ALPHA keychar = ALPHA / DIGIT / HYPHEN / USCORE numericoid = number 1*( DOT number ) number = DIGIT / ( LDIGIT 1*DIGIT ) ALPHA = %x41-5A / %x61-7A ; "A"-"Z" / "a"-"z" DIGIT = %x30 / LDIGIT ; "0"-"9" HYPHEN = %x2D ; hyphen ("-") LDIGIT = %x31-39 ; "1"-"9" DOT = %x2E ; period (".") USCORE = %x5F ; underscore ("_")Note that we have extended this grammar to accept the '_' char, which is widely used in teh LDAP world.- Parameters:
attributeName- The AttributeType name to check- Returns:
- true if it's valid
-
-