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
-
-
Field Summary
Fields Modifier and Type Field Description protected intlineNumberthe number of the current line being parsed by the readerprotected static LoggerLOGThe LoggerFactory used by this class
-
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 voidclear()Reset the parserList<AttributeType>getAttributeTypes()Gets the attribute types.List<ObjectClass>getObjectClasses()Gets the object class types.Map<String,OpenLdapObjectIdentifierMacro>getObjectIdentifierMacros()Gets the object identifier macros.booleanisQuirksMode()Checks if quirks mode is enabled.booleanisResolveObjectIdentifierMacros()Checks if object identifier macros should be resolved.voidparse(File schemaFile)Parses a file of OpenLDAP schemaObject elements/objects.voidparse(InputStream schemaIn)Parses a stream of OpenLDAP schemaObject elements/objects.voidparse(Reader reader)Reads an entry in a ldif buffer, and returns the resulting lines, without comments, and unfolded.SchemaObjectparse(String schemaObject)Parses an OpenLDAP schemaObject element/object.AttributeTypeparseAttributeType(String attributeTypeDescription)Production for matching attribute type descriptions.DitContentRuleparseDitContentRule(String ditContentRuleDescription)Production for matching DitContentRule descriptions.DitStructureRuleparseDitStructureRule(String ditStructureRuleDescription)Production for matching DitStructureRule descriptions.LdapComparatorDescriptionparseLdapComparator(String ldapComparatorDescription)Production for LdapComparator descriptions.LdapSyntaxparseLdapSyntax(String ldapSyntaxDescription)Production for matching ldap syntax descriptions.MatchingRuleparseMatchingRule(String matchingRuleDescription)Production for matching MatchingRule descriptions.MatchingRuleUseparseMatchingRuleUse(String matchingRuleUseDescription)Production for matching MatchingRuleUse descriptions.NameFormparseNameForm(String nameFormDescription)Production for NameForm descriptions.NormalizerDescriptionparseNormalizer(String normalizerDescription)Production for Normalizer descriptions.ObjectClassparseObjectClass(String objectClassDescription)Production for matching ObjectClass descriptions.SyntaxCheckerDescriptionparseSyntaxChecker(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 Detail
-
LOG
protected static final Logger LOG
The LoggerFactory used by this class
-
lineNumber
protected int lineNumber
the number of the current line being parsed by the reader
-
-
Method Detail
-
clear
public void clear()
Reset the parser
-
getAttributeTypes
public List<AttributeType> 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
-
-