Class OpenLdapSchemaParser
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.parsers.OpenLdapSchemaParser
-
public class OpenLdapSchemaParser extends Object
A reusable wrapper for hand parser OpenLDAP schema.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description OpenLdapSchemaParser()
Creates a reusable instance of an OpenLdapSchemaParser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Reset the parserList<MutableAttributeType>
getAttributeTypes()
Gets the attribute types.List<ObjectClass>
getObjectClasses()
Gets the object class types.Map<String,OpenLdapObjectIdentifierMacro>
getObjectIdentifierMacros()
Gets the object identifier macros.boolean
isQuirksMode()
Checks if quirks mode is enabled.boolean
isResolveObjectIdentifierMacros()
Checks if object identifier macros should be resolved.void
parse(File schemaFile)
Parses a file of OpenLDAP schemaObject elements/objects.void
parse(InputStream schemaIn)
Parses a stream of OpenLDAP schemaObject elements/objects.void
parse(Reader reader)
Reads an entry in a ldif buffer, and returns the resulting lines, without comments, and unfolded.SchemaObject
parse(String schemaObject)
Parses an OpenLDAP schemaObject element/object.AttributeType
parseAttributeType(String attributeTypeDescription)
Production for matching attribute type descriptions.DitContentRule
parseDitContentRule(String ditContentRuleDescription)
Production for matching DitContentRule descriptions.DitStructureRule
parseDitStructureRule(String ditStructureRuleDescription)
Production for matching DitStructureRule descriptions.LdapComparatorDescription
parseLdapComparator(String ldapComparatorDescription)
Production for LdapComparator descriptions.LdapSyntax
parseLdapSyntax(String ldapSyntaxDescription)
Production for matching ldap syntax descriptions.MatchingRule
parseMatchingRule(String matchingRuleDescription)
Production for matching MatchingRule descriptions.MatchingRuleUse
parseMatchingRuleUse(String matchingRuleUseDescription)
Production for matching MatchingRuleUse descriptions.NameForm
parseNameForm(String nameFormDescription)
Production for NameForm descriptions.NormalizerDescription
parseNormalizer(String normalizerDescription)
Production for Normalizer descriptions.ObjectClass
parseObjectClass(String objectClassDescription)
Production for matching ObjectClass descriptions.SyntaxCheckerDescription
parseSyntaxChecker(String syntaxCheckerDescription)
Production for SyntaxChecker descriptions.void
setQuirksMode(boolean enabled)
Sets the quirks mode.void
setResolveObjectIdentifierMacros(boolean resolveObjectIdentifierMacros)
Sets if object identifier macros should be resolved.
-
-
-
Constructor Detail
-
OpenLdapSchemaParser
public OpenLdapSchemaParser()
Creates a reusable instance of an OpenLdapSchemaParser.
-
-
Method Detail
-
clear
public void clear()
Reset the parser
-
getAttributeTypes
public List<MutableAttributeType> getAttributeTypes()
Gets the attribute types.- Returns:
- the attribute types
-
getObjectClasses
public List<ObjectClass> getObjectClasses()
Gets the object class types.- Returns:
- the object class types
-
getObjectIdentifierMacros
public Map<String,OpenLdapObjectIdentifierMacro> getObjectIdentifierMacros()
Gets the object identifier macros.- Returns:
- the object identifier macros
-
parse
public SchemaObject parse(String schemaObject) throws ParseException
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
public void parse(InputStream schemaIn) throws ParseException, LdapSchemaException, IOException
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
public AttributeType parseAttributeType(String attributeTypeDescription) throws ParseException
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
public DitContentRule parseDitContentRule(String ditContentRuleDescription) throws ParseException
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
public LdapSyntax parseLdapSyntax(String ldapSyntaxDescription) throws ParseException
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
public MatchingRule parseMatchingRule(String matchingRuleDescription) throws ParseException
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
public NameForm parseNameForm(String nameFormDescription) throws ParseException
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
public NormalizerDescription parseNormalizer(String normalizerDescription) throws ParseException
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
public ObjectClass parseObjectClass(String objectClassDescription) throws ParseException
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
public void parse(Reader reader) throws LdapSchemaException, IOException
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
public void parse(File schemaFile) throws ParseException
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
-
-