Package org.ldaptive.io
Class LdifReader
- java.lang.Object
-
- org.ldaptive.io.LdifReader
-
- All Implemented Interfaces:
SearchResultReader
public class LdifReader extends Object implements SearchResultReader
Reads an LDIF from aReader
and returns aSearchResponse
. This implementation only supports entry records. It does not support change records or include statements.
-
-
Field Summary
Fields Modifier and Type Field Description private Reader
ldifReader
Reader to read from.protected Logger
logger
Logger for this class.private static int
READ_AHEAD_LIMIT
Mark read back buffer size.
-
Constructor Summary
Constructors Constructor Description LdifReader(Reader reader)
Creates a new ldif reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private LdapAttribute
parseAttribute(String line)
Parses the supplied line and returns an attribute with a single value found in the line.private LdapEntry
parseEntry(List<String> section)
Parses the supplied array of LDIF lines and returns an LDAP entry.private SearchResultReference
parseReference(List<String> section)
Parses the supplied array of LDIF lines and returns a search reference.SearchResponse
read()
Reads LDIF data from the reader and returns a search result.private List<String>
readSection(BufferedReader reader)
Reads the supplied reader line-by-line until the reader is empty or a empty line is encountered.
-
-
-
Field Detail
-
READ_AHEAD_LIMIT
private static final int READ_AHEAD_LIMIT
Mark read back buffer size.- See Also:
- Constant Field Values
-
logger
protected final Logger logger
Logger for this class.
-
ldifReader
private final Reader ldifReader
Reader to read from.
-
-
Constructor Detail
-
LdifReader
public LdifReader(Reader reader)
Creates a new ldif reader.- Parameters:
reader
- to read LDIF from
-
-
Method Detail
-
read
public SearchResponse read() throws IOException
Reads LDIF data from the reader and returns a search result.- Specified by:
read
in interfaceSearchResultReader
- Returns:
- search result derived from the LDIF
- Throws:
IOException
- if an error occurs using the reader
-
readSection
private List<String> readSection(BufferedReader reader) throws IOException
Reads the supplied reader line-by-line until the reader is empty or a empty line is encountered. Lines containing comments are ignored.- Parameters:
reader
- to read- Returns:
- list of a lines in the section
- Throws:
IOException
- if an error occurs reading
-
parseEntry
private LdapEntry parseEntry(List<String> section) throws IOException
Parses the supplied array of LDIF lines and returns an LDAP entry.- Parameters:
section
- of LDIF lines- Returns:
- ldap entry
- Throws:
IOException
- if an errors occurs reading a URI in the LDIF
-
parseAttribute
private LdapAttribute parseAttribute(String line) throws IOException
Parses the supplied line and returns an attribute with a single value found in the line.- Parameters:
line
- to parse- Returns:
- ldap attribute
- Throws:
IOException
- if an errors occurs reading a URI in the LDIF
-
parseReference
private SearchResultReference parseReference(List<String> section)
Parses the supplied array of LDIF lines and returns a search reference.- Parameters:
section
- of LDIF lines- Returns:
- search reference
-
-