Class OpenLdapSchemaParser
java.lang.Object
org.apache.directory.api.ldap.model.schema.parsers.OpenLdapSchemaParser
A reusable wrapper for hand parser OpenLDAP schema.
- Author:
- Apache Directory Project
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intthe number of the current line being parsed by the readerprotected static final org.slf4j.LoggerThe LoggerFactory used by this class -
Constructor Summary
ConstructorsConstructorDescriptionCreates a reusable instance of an OpenLdapSchemaParser. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Reset the parserGets the attribute types.Gets the object class types.Gets the object identifier macros.booleanChecks if quirks mode is enabled.booleanChecks if object identifier macros should be resolved.voidParses a file of OpenLDAP schemaObject elements/objects.voidparse(InputStream schemaIn) Parses a stream of OpenLDAP schemaObject elements/objects.voidReads an entry in a ldif buffer, and returns the resulting lines, without comments, and unfolded.Parses an OpenLDAP schemaObject element/object.parseAttributeType(String attributeTypeDescription) Production for matching attribute type descriptions.parseDitContentRule(String ditContentRuleDescription) Production for matching DitContentRule descriptions.parseDitStructureRule(String ditStructureRuleDescription) Production for matching DitStructureRule descriptions.parseLdapComparator(String ldapComparatorDescription) Production for LdapComparator descriptions.parseLdapSyntax(String ldapSyntaxDescription) Production for matching ldap syntax descriptions.parseMatchingRule(String matchingRuleDescription) Production for matching MatchingRule descriptions.parseMatchingRuleUse(String matchingRuleUseDescription) Production for matching MatchingRuleUse descriptions.parseNameForm(String nameFormDescription) Production for NameForm descriptions.parseNormalizer(String normalizerDescription) Production for Normalizer descriptions.parseObjectClass(String objectClassDescription) Production for matching ObjectClass descriptions.parseSyntaxChecker(String syntaxCheckerDescription) Production for SyntaxChecker descriptions.voidsetQuirksMode(boolean enabled) Sets the quirks mode.voidsetResolveObjectIdentifierMacros(boolean resolveObjectIdentifierMacros) Sets if object identifier macros should be resolved.
-
Field Details
-
LOG
protected static final org.slf4j.Logger LOGThe LoggerFactory used by this class -
lineNumber
protected int lineNumberthe number of the current line being parsed by the reader
-
-
Constructor Details
-
OpenLdapSchemaParser
public OpenLdapSchemaParser()Creates a reusable instance of an OpenLdapSchemaParser.
-
-
Method Details
-
clear
public void clear()Reset the parser -
getAttributeTypes
Gets the attribute types.- Returns:
- the attribute types
-
getObjectClasses
Gets the object class types.- Returns:
- the object class types
-
getObjectIdentifierMacros
Gets the object identifier macros.- Returns:
- the object identifier macros
-
parse
Parses an OpenLDAP schemaObject element/object.- Parameters:
schemaObject- the String image of a complete schema object- Returns:
- the schema object
- Throws:
ParseException- If the schemaObject can't be parsed
-
parse
Parses a stream of OpenLDAP schemaObject elements/objects. Default charset is used.- Parameters:
schemaIn- a stream of schema objects- Throws:
ParseException- If the schema can't be parsedLdapSchemaException- If there is an error in the schemaIOException- If the stream can't be read
-
parseAttributeType
Production for matching attribute type descriptions. It is fault-tolerant against element ordering.AttributeTypeDescription = LPAREN WSP numericoid ; object identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active [ SP "SUP" SP oid ] ; supertype [ SP "EQUALITY" SP oid ] ; equality matching rule [ SP "ORDERING" SP oid ] ; ordering matching rule [ SP "SUBSTR" SP oid ] ; substrings matching rule [ SP "SYNTAX" SP noidlen ] ; value syntax [ SP "SINGLE-VALUE" ] ; single-value [ SP "COLLECTIVE" ] ; collective [ SP "NO-USER-MODIFICATION" ] ; not user modifiable [ SP "USAGE" SP usage ] ; usage extensions WSP RPAREN ; extensions usage = "userApplications" / ; user "directoryOperation" / ; directory operational "distributedOperation" / ; DSA-shared operational "dSAOperation" ; DSA-specific operational extensions = *( SP xstring SP qdstrings ) xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE )- Parameters:
attributeTypeDescription- The String containing the AttributeTypeDescription- Returns:
- An instance of AttributeType
- Throws:
ParseException- If the element was invalid
-
parseDitContentRule
Production for matching DitContentRule descriptions. It is fault-tolerant against element ordering.DITContentRuleDescription = LPAREN WSP numericoid ; object identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active [ SP "AUX" SP oids ] ; auxiliary object classes [ SP "MUST" SP oids ] ; attribute types [ SP "MAY" SP oids ] ; attribute types [ SP "NOT" SP oids ] ; attribute types extensions WSP RPAREN ; extensions
- Parameters:
ditContentRuleDescription- The String containing the DitContentRuleDescription- Returns:
- An instance of ditContentRule
- Throws:
ParseException- If the element was invalid
-
parseDitStructureRule
public DitStructureRule parseDitStructureRule(String ditStructureRuleDescription) throws ParseException Production for matching DitStructureRule descriptions. It is fault-tolerant against element ordering.DITStructureRuleDescription = LPAREN WSP ruleid ; rule identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active SP "FORM" SP oid ; NameForm [ SP "SUP" ruleids ] ; superior rules extensions WSP RPAREN ; extensions ruleids = ruleid / ( LPAREN WSP ruleidlist WSP RPAREN ) ruleidlist = ruleid *( SP ruleid ) ruleid = number
- Parameters:
ditStructureRuleDescription- The String containing the DitStructureRuleDescription- Returns:
- An instance of DitStructureRule
- Throws:
ParseException- If the element was invalid
-
parseLdapComparator
public LdapComparatorDescription parseLdapComparator(String ldapComparatorDescription) throws ParseException Production for LdapComparator descriptions. It is fault-tolerant against element ordering.LdapComparatorDescription = LPAREN WSP numericoid ; object identifier [ SP "DESC" SP qdstring ] ; description SP "FQCN" SP fqcn ; fully qualified class name [ SP "BYTECODE" SP base64 ] ; optional base64 encoded bytecode extensions WSP RPAREN ; extensions base64 = *(4base64-char) base64-char = ALPHA / DIGIT / "+" / "/" fqcn = fqcnComponent 1*( DOT fqcnComponent ) fqcnComponent = ???- Parameters:
ldapComparatorDescription- The String containing the LdapComparatorDescription- Returns:
- An instance of LdapComparatorDescription
- Throws:
ParseException- If the element was invalid
-
parseLdapSyntax
Production for matching ldap syntax descriptions. It is fault-tolerant against element ordering.SyntaxDescription = LPAREN WSP numericoid ; object identifier [ SP "DESC" SP qdstring ] ; description extensions WSP RPAREN ; extensions
- Parameters:
ldapSyntaxDescription- The String containing the Ldap Syntax description- Returns:
- An instance of LdapSyntax
- Throws:
ParseException- If the element was invalid
-
parseMatchingRule
Production for matching MatchingRule descriptions. It is fault-tolerant against element ordering.MatchingRuleDescription = LPAREN WSP numericoid ; object identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active SP "SYNTAX" SP numericoid ; assertion syntax extensions WSP RPAREN ; extensions
- Parameters:
matchingRuleDescription- The String containing the MatchingRuledescription- Returns:
- An instance of MatchingRule
- Throws:
ParseException- If the element was invalid
-
parseMatchingRuleUse
public MatchingRuleUse parseMatchingRuleUse(String matchingRuleUseDescription) throws ParseException Production for matching MatchingRuleUse descriptions. It is fault-tolerant against element ordering.MatchingRuleUseDescription = LPAREN WSP numericoid ; object identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active SP "APPLIES" SP oids ; attribute types extensions WSP RPAREN ; extensions
- Parameters:
matchingRuleUseDescription- The String containing the MatchingRuleUsedescription- Returns:
- An instance of MatchingRuleUse
- Throws:
ParseException- If the element was invalid
-
parseNameForm
Production for NameForm descriptions. It is fault-tolerant against element ordering.NameFormDescription = LPAREN WSP numericoid ; object identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active SP "OC" SP oid ; structural object class SP "MUST" SP oids ; attribute types [ SP "MAY" SP oids ] ; attribute types extensions WSP RPAREN ; extensions
- Parameters:
nameFormDescription- The String containing the NameFormdescription- Returns:
- An instance of NameForm
- Throws:
ParseException- If the element was invalid
-
parseNormalizer
Production for Normalizer descriptions. It is fault-tolerant against element ordering.NormalizerDescription = LPAREN WSP numericoid ; object identifier [ SP "DESC" SP qdstring ] ; description SP "FQCN" SP fqcn ; fully qualified class name [ SP "BYTECODE" SP base64 ] ; optional base64 encoded bytecode extensions WSP RPAREN ; extensions base64 = *(4base64-char) base64-char = ALPHA / DIGIT / "+" / "/" fqcn = fqcnComponent 1*( DOT fqcnComponent ) fqcnComponent = ???- Parameters:
normalizerDescription- The String containing the NormalizerDescription- Returns:
- An instance of NormalizerDescription
- Throws:
ParseException- If the element was invalid
-
parseObjectClass
Production for matching ObjectClass descriptions. It is fault-tolerant against element ordering.ObjectClassDescription = LPAREN WSP numericoid ; object identifier [ SP "NAME" SP qdescrs ] ; short names (descriptors) [ SP "DESC" SP qdstring ] ; description [ SP "OBSOLETE" ] ; not active [ SP "SUP" SP oids ] ; superior object classes [ SP kind ] ; kind of class [ SP "MUST" SP oids ] ; attribute types [ SP "MAY" SP oids ] ; attribute types extensions WSP RPAREN kind = "ABSTRACT" / "STRUCTURAL" / "AUXILIARY"
- Parameters:
objectClassDescription- The String containing the ObjectClassDescription- Returns:
- An instance of objectClass
- Throws:
ParseException- If the element was invalid
-
parseSyntaxChecker
public SyntaxCheckerDescription parseSyntaxChecker(String syntaxCheckerDescription) throws ParseException Production for SyntaxChecker descriptions. It is fault-tolerant against element ordering.SyntaxCheckerDescription = LPAREN WSP numericoid ; object identifier [ SP "DESC" SP qdstring ] ; description SP "FQCN" SP fqcn ; fully qualified class name [ SP "BYTECODE" SP base64 ] ; optional base64 encoded bytecode extensions WSP RPAREN ; extensions base64 = *(4base64-char) base64-char = ALPHA / DIGIT / "+" / "/" fqcn = fqcnComponent 1*( DOT fqcnComponent ) fqcnComponent = ???- Parameters:
syntaxCheckerDescription- The String containing the SyntaxCheckerDescription- Returns:
- An instance of SyntaxCheckerDescription
- Throws:
ParseException- If the element was invalid
-
parse
Reads an entry in a ldif buffer, and returns the resulting lines, without comments, and unfolded. The lines represent *one* entry.- Parameters:
reader- The stream reader- Throws:
LdapSchemaException- If something went wrong in the schemaIOException- If the stream can't be read
-
parse
Parses a file of OpenLDAP schemaObject elements/objects. Default charset is used.- Parameters:
schemaFile- a file of schema objects- Throws:
ParseException- If the schemaObject can't be parsed
-
isResolveObjectIdentifierMacros
public boolean isResolveObjectIdentifierMacros()Checks if object identifier macros should be resolved.- Returns:
- true, object identifier macros should be resolved.
-
setResolveObjectIdentifierMacros
public void setResolveObjectIdentifierMacros(boolean resolveObjectIdentifierMacros) Sets if object identifier macros should be resolved.- Parameters:
resolveObjectIdentifierMacros- true if object identifier macros should be resolved
-
isQuirksMode
public boolean isQuirksMode()Checks if quirks mode is enabled.- Returns:
- true, if is quirks mode is enabled
-
setQuirksMode
public void setQuirksMode(boolean enabled) Sets the quirks mode. If enabled the parser accepts non-numeric OIDs and some special characters in descriptions.- Parameters:
enabled- the new quirks mode
-