Package org.forgerock.opendj.ldif
Class LDIFEntryReader
java.lang.Object
org.forgerock.opendj.ldif.LDIFEntryReader
- All Implemented Interfaces:
Closeable,AutoCloseable,EntryReader
An LDIF entry reader reads attribute value records (entries) using the LDAP
Data Interchange Format (LDIF) from a user defined source.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new LDIF entry reader whose source is the provided input stream.LDIFEntryReader(Reader reader) Creates a new LDIF entry reader whose source is the provided character stream reader.LDIFEntryReader(String... ldifLines) Creates a new LDIF entry reader which will read lines of LDIF from the provided array of LDIF lines.LDIFEntryReader(List<String> ldifLines) Creates a new LDIF entry reader which will read lines of LDIF from the provided list of LDIF lines. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this entry reader if it is not already closed.booleanhasNext()Returnstrueif this reader contains another entry, blocking if necessary until either the next entry is available or the end of the stream is reached.Reads the next entry, blocking if necessary until an entry is available.setExcludeAllOperationalAttributes(boolean excludeOperationalAttributes) Specifies whether all operational attributes should be excluded from any entries that are read from LDIF.setExcludeAllUserAttributes(boolean excludeUserAttributes) Specifies whether all user attributes should be excluded from any entries that are read from LDIF.setExcludeAttribute(AttributeDescription attributeDescription) Excludes the named attribute from any entries that are read from LDIF.setExcludeBranch(DN excludeBranch) Excludes all entries beneath the named entry (inclusive) from being read from LDIF.setExcludeFilter(Matcher excludeFilter) Excludes all entries which match the provided filter matcher from being read from LDIF.setIncludeAttribute(AttributeDescription attributeDescription) Ensures that the named attribute is not excluded from any entries that are read from LDIF.setIncludeBranch(DN includeBranch) Ensures that all entries beneath the named entry (inclusive) are read from LDIF.setIncludeFilter(Matcher includeFilter) Ensures that all entries which match the provided filter matcher are read from LDIF.setRejectedLDIFListener(RejectedLDIFListener listener) Sets the rejected record listener which should be notified whenever an LDIF record is skipped, malformed, or fails schema validation.Sets the schema which should be used for decoding entries that are read from LDIF.Specifies the schema validation which should be used when reading LDIF entry records.static EntryvalueOfLDIFEntry(String... ldifLines) Parses the provided array of LDIF lines as a single LDIF entry.
-
Constructor Details
-
LDIFEntryReader
Creates a new LDIF entry reader whose source is the provided input stream.- Parameters:
in- The input stream to use.- Throws:
NullPointerException- Ifinwasnull.
-
LDIFEntryReader
Creates a new LDIF entry reader which will read lines of LDIF from the provided list of LDIF lines.- Parameters:
ldifLines- The lines of LDIF to be read.- Throws:
NullPointerException- IfldifLineswasnull.
-
LDIFEntryReader
Creates a new LDIF entry reader whose source is the provided character stream reader.- Parameters:
reader- The character stream reader to use.- Throws:
NullPointerException- Ifreaderwasnull.
-
LDIFEntryReader
Creates a new LDIF entry reader which will read lines of LDIF from the provided array of LDIF lines.- Parameters:
ldifLines- The lines of LDIF to be read.- Throws:
NullPointerException- IfldifLineswasnull.
-
-
Method Details
-
valueOfLDIFEntry
Parses the provided array of LDIF lines as a single LDIF entry.- Parameters:
ldifLines- The lines of LDIF to be parsed.- Returns:
- The parsed LDIF entry.
- Throws:
org.forgerock.i18n.LocalizedIllegalArgumentException- IfldifLinesdid not contain an LDIF entry, if it contained multiple entries, if contained malformed LDIF, or if the entry could not be decoded using the default schema.NullPointerException- IfldifLineswasnull.
-
close
Description copied from interface:EntryReaderCloses this entry reader if it is not already closed. Note that this method does not need to be called if a previous call ofEntryReader.readEntry()has returnednull.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntryReader- Throws:
IOException- If an unexpected IO error occurred while closing.
-
hasNext
Returnstrueif this reader contains another entry, blocking if necessary until either the next entry is available or the end of the stream is reached.- Specified by:
hasNextin interfaceEntryReader- Returns:
trueif this reader contains another entry.- Throws:
DecodeException- If the entry could not be decoded because it was malformed.IOException- If an unexpected IO error occurred.
-
readEntry
Reads the next entry, blocking if necessary until an entry is available.- Specified by:
readEntryin interfaceEntryReader- Returns:
- The next entry.
- Throws:
DecodeException- If the entry could not be decoded because it was malformed.IOException- If an unexpected IO error occurred while reading the entry.
-
setExcludeAllOperationalAttributes
Specifies whether all operational attributes should be excluded from any entries that are read from LDIF. The default isfalse.- Parameters:
excludeOperationalAttributes-trueif all operational attributes should be excluded, orfalseotherwise.- Returns:
- A reference to this
LDIFEntryReader.
-
setExcludeAllUserAttributes
Specifies whether all user attributes should be excluded from any entries that are read from LDIF. The default isfalse.- Parameters:
excludeUserAttributes-trueif all user attributes should be excluded, orfalseotherwise.- Returns:
- A reference to this
LDIFEntryReader.
-
setExcludeAttribute
Excludes the named attribute from any entries that are read from LDIF. By default all attributes are included unless explicitly excluded.- Parameters:
attributeDescription- The name of the attribute to be excluded.- Returns:
- A reference to this
LDIFEntryReader.
-
setExcludeBranch
Excludes all entries beneath the named entry (inclusive) from being read from LDIF. By default all entries are written unless explicitly excluded or included by branches or filters.- Parameters:
excludeBranch- The distinguished name of the branch to be excluded.- Returns:
- A reference to this
LDIFEntryReader.
-
setExcludeFilter
Excludes all entries which match the provided filter matcher from being read from LDIF. By default all entries are read unless explicitly excluded or included by branches or filters.- Parameters:
excludeFilter- The filter matcher.- Returns:
- A reference to this
LDIFEntryReader.
-
setIncludeAttribute
Ensures that the named attribute is not excluded from any entries that are read from LDIF. By default all attributes are included unless explicitly excluded.- Parameters:
attributeDescription- The name of the attribute to be included.- Returns:
- A reference to this
LDIFEntryReader.
-
setIncludeBranch
Ensures that all entries beneath the named entry (inclusive) are read from LDIF. By default all entries are written unless explicitly excluded or included by branches or filters.- Parameters:
includeBranch- The distinguished name of the branch to be included.- Returns:
- A reference to this
LDIFEntryReader.
-
setIncludeFilter
Ensures that all entries which match the provided filter matcher are read from LDIF. By default all entries are read unless explicitly excluded or included by branches or filters.- Parameters:
includeFilter- The filter matcher.- Returns:
- A reference to this
LDIFEntryReader.
-
setRejectedLDIFListener
Sets the rejected record listener which should be notified whenever an LDIF record is skipped, malformed, or fails schema validation.By default the
RejectedLDIFListener.FAIL_FASTlistener is used.- Parameters:
listener- The rejected record listener.- Returns:
- A reference to this
LDIFEntryReader.
-
setSchema
Sets the schema which should be used for decoding entries that are read from LDIF. The default schema is used if no other is specified.- Parameters:
schema- The schema which should be used for decoding entries that are read from LDIF.- Returns:
- A reference to this
LDIFEntryReader.
-
setSchemaValidationPolicy
Specifies the schema validation which should be used when reading LDIF entry records. If attribute value validation is enabled then all checks will be performed.Schema validation is disabled by default.
NOTE: this method copies the provided policy so changes made to it after this method has been called will have no effect.
- Parameters:
policy- The schema validation which should be used when reading LDIF entry records.- Returns:
- A reference to this
LDIFEntryReader.
-