Class LdifAttributesReader
- java.lang.Object
-
- org.apache.directory.api.ldap.model.ldif.LdifReader
-
- org.apache.directory.api.ldap.model.ldif.LdifAttributesReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<LdifEntry>
public class LdifAttributesReader extends LdifReader
<ldif-file> ::= "version:" <fill> <number> <seps> <dn-spec> <sep> <ldif-content-change> <ldif-content-change> ::= <number> <oid> <options-e> <value-spec> <sep> <attrval-specs-e> <ldif-attrval-record-e> | <alpha> <chars-e> <options-e> <value-spec> <sep> <attrval-specs-e> <ldif-attrval-record-e> | "control:" <fill> <number> <oid> <spaces-e> <criticality> <value-spec-e> <sep> <controls-e> "changetype:" <fill> <changerecord-type> <ldif-change-record-e> | "changetype:" <fill> <changerecord-type> <ldif-change-record-e> <ldif-attrval-record-e> ::= <seps> <dn-spec> <sep> <attributeType> <options-e> <value-spec> <sep> <attrval-specs-e> <ldif-attrval-record-e> | e <ldif-change-record-e> ::= <seps> <dn-spec> <sep> <controls-e> "changetype:" <fill> <changerecord-type> <ldif-change-record-e> | e <dn-spec> ::= "dn:" <fill> <safe-string> | "dn::" <fill> <base64-string> <controls-e> ::= "control:" <fill> <number> <oid> <spaces-e> <criticality> <value-spec-e> <sep> <controls-e> | e <criticality> ::= "true" | "false" | e <oid> ::= '.' <number> <oid> | e <attrval-specs-e> ::= <number> <oid> <options-e> <value-spec> <sep> <attrval-specs-e> | <alpha> <chars-e> <options-e> <value-spec> <sep> <attrval-specs-e> | e <value-spec-e> ::= <value-spec> | e <value-spec> ::= ':' <fill> <safe-string-e> | "::" <fill> <base64-chars> | ":<" <fill> <url> <attributeType> ::= <number> <oid> | <alpha> <chars-e> <options-e> ::= ';' <char> <chars-e> <options-e> |e <chars-e> ::= <char> <chars-e> | e <changerecord-type> ::= "add" <sep> <attributeType> <options-e> <value-spec> <sep> <attrval-specs-e> | "delete" <sep> | "modify" <sep> <mod-type> <fill> <attributeType> <options-e> <sep> <attrval-specs-e> <sep> '-' <sep> <mod-specs-e> | "moddn" <sep> <newrdn> <sep> "deleteoldrdn:" <fill> <0-1> <sep> <newsuperior-e> <sep> | "modrdn" <sep> <newrdn> <sep> "deleteoldrdn:" <fill> <0-1> <sep> <newsuperior-e> <sep> <newrdn> ::= ':' <fill> <safe-string> | "::" <fill> <base64-chars> <newsuperior-e> ::= "newsuperior" <newrdn> | e <mod-specs-e> ::= <mod-type> <fill> <attributeType> <options-e> <sep> <attrval-specs-e> <sep> '-' <sep> <mod-specs-e> | e <mod-type> ::= "add:" | "delete:" | "replace:" <url> ::= <a Uniform Resource Locator, as defined in [6]> LEXICAL ------- <fill> ::= ' ' <fill> | e <char> ::= <alpha> | <digit> | '-' <number> ::= <digit> <digits> <0-1> ::= '0' | '1' <digits> ::= <digit> <digits> | e <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' <seps> ::= <sep> <seps-e> <seps-e> ::= <sep> <seps-e> | e <sep> ::= 0x0D 0x0A | 0x0A <spaces> ::= ' ' <spaces-e> <spaces-e> ::= ' ' <spaces-e> | e <safe-string-e> ::= <safe-string> | e <safe-string> ::= <safe-init-char> <safe-chars> <safe-init-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39] | 0x3B | [0x3D-0x7F] <safe-chars> ::= <safe-char> <safe-chars> | e <safe-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F] <base64-string> ::= <base64-char> <base64-chars> <base64-chars> ::= <base64-char> <base64-chars> | e <base64-char> ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-9x5A] | [0x61-0x7A] <alpha> ::= [0x41-0x5A] | [0x61-0x7A] COMMENTS -------- - The ldap-oid VN is not correct in the RFC-2849. It has been changed from 1*DIGIT 0*1("." 1*DIGIT) to DIGIT+ ("." DIGIT+)* - The mod-spec lacks a sep between *attrval-spec and "-". - The BASE64-UTF8-STRING should be BASE64-CHAR BASE64-STRING - The ValueSpec rule must accept multilines values. In this case, we have a LF followed by a single space before the continued value.- Author:
- Apache Directory Project
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGA logger-
Fields inherited from class org.apache.directory.api.ldap.model.ldif.LdifReader
ATTRVAL_SPEC, ATTRVAL_SPEC_OR_SEP, CHANGE, containsChanges, containsEntries, DEFAULT_VERSION, entryLen, entryOffset, error, LDIF_ENTRY, lineNumber, lines, MOD_SPEC, offset, position, prefetched, reader, schemaManager, SIZE_LIMIT_DEFAULT, sizeLimit, UNKNOWN, validateDn, version
-
-
Constructor Summary
Constructors Constructor Description LdifAttributesReader()Constructors
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidparseAttribute(Attributes attributes, String line, String lowerLine)Parse an AttributeType/AttributeValueprivate AttributesparseAttributes()Parse a ldif file.AttributesparseAttributes(String ldif)A method which parses a ldif string and returns a list of Attributes.EntryparseEntry(String ldif)A method which parses a ldif string and returns an Entry.private EntryparseEntry(SchemaManager schemaManager)Parse a ldif file.EntryparseEntry(SchemaManager schemaManager, String ldif)A method which parses a ldif string and returns an Entry.private voidparseEntryAttribute(SchemaManager schemaManager, Entry entry, String line, String lowerLine)Parse an AttributeType/AttributeValue-
Methods inherited from class org.apache.directory.api.ldap.model.ldif.LdifReader
close, containsEntries, createLdifEntry, fetch, getError, getLine, getLineNumber, getSizeLimit, getVersion, hasError, hasNext, init, isValidateDn, iterator, next, parseAttributeValue, parseAttributeValue, parseChangeType, parseDn, parseEntry, parseLdif, parseLdif, parseLdifFile, parseLdifFile, parseSimpleValue, parseValue, parseVersion, readLines, remove, setSchemaManager, setSizeLimit, setValidateDn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
parseAttribute
private void parseAttribute(Attributes attributes, String line, String lowerLine) throws LdapLdifException
Parse an AttributeType/AttributeValue- Parameters:
attributes- The entry where to store the valueline- The line to parselowerLine- The same line, lowercased- Throws:
LdapLdifException- If anything goes wrong
-
parseEntryAttribute
private void parseEntryAttribute(SchemaManager schemaManager, Entry entry, String line, String lowerLine) throws LdapLdifException
Parse an AttributeType/AttributeValue- Parameters:
schemaManager- The SchemaManagerentry- The entry where to store the valueline- The line to parselowerLine- The same line, lowercased- Throws:
LdapLdifException- If anything goes wrong
-
parseEntry
private Entry parseEntry(SchemaManager schemaManager) throws LdapLdifException
Parse a ldif file. The following rules are processed : <ldif-file> ::= <ldif-attrval-record> <ldif-attrval-records> | <ldif-change-record> <ldif-change-records> <ldif-attrval-record> ::= <dn-spec> <sep> <attrval-spec> <attrval-specs> <ldif-change-record> ::= <dn-spec> <sep> <controls-e> <changerecord> <dn-spec> ::= "dn:" <fill> <distinguishedName> | "dn::" <fill> <base64-distinguishedName> <changerecord> ::= "changetype:" <fill> <change-op>- Parameters:
schemaManager- The SchemaManager- Returns:
- The read entry
- Throws:
LdapLdifException- If the entry can't be read or is invalid
-
parseAttributes
private Attributes parseAttributes() throws LdapLdifException
Parse a ldif file. The following rules are processed :<ldif-file> ::= <ldif-attrval-record> <ldif-attrval-records> | <ldif-change-record> <ldif-change-records> <ldif-attrval-record> ::= <dn-spec> <sep> <attrval-spec> <attrval-specs> <ldif-change-record> ::= <dn-spec> <sep> <controls-e> <changerecord> <dn-spec> ::= "dn:" <fill> <distinguishedName> | "dn::" <fill> <base64-distinguishedName> <changerecord> ::= "changetype:" <fill> <change-op>
- Returns:
- The read entry
- Throws:
LdapLdifException- If the entry can't be read or is invalid
-
parseAttributes
public Attributes parseAttributes(String ldif) throws LdapLdifException
A method which parses a ldif string and returns a list of Attributes.- Parameters:
ldif- The ldif string- Returns:
- A list of Attributes, or an empty List
- Throws:
LdapLdifException- If something went wrong
-
parseEntry
public Entry parseEntry(String ldif) throws LdapLdifException
A method which parses a ldif string and returns an Entry.- Parameters:
ldif- The ldif string- Returns:
- An entry
- Throws:
LdapLdifException- If something went wrong
-
parseEntry
public Entry parseEntry(SchemaManager schemaManager, String ldif) throws LdapLdifException
A method which parses a ldif string and returns an Entry.- Parameters:
schemaManager- The SchemaManagerldif- The ldif string- Returns:
- An entry
- Throws:
LdapLdifException- If something went wrong
-
-