Package org.ldaptive.io
Class LdifWriter
- java.lang.Object
-
- org.ldaptive.io.LdifWriter
-
- All Implemented Interfaces:
SearchResultWriter
public class LdifWriter extends Object implements SearchResultWriter
Writes aSearchResult
as LDIF to aWriter
.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
COLON_CHAR
ASCII decimal value of colon.private static int
CR_CHAR
ASCII decimal value of carriage return.private static int
LA_CHAR
ASCII decimal value of left arrow.private Writer
ldifWriter
Writer to write to.private static int
LF_CHAR
ASCII decimal value of line feed.private static String
LINE_SEPARATOR
Line separator.private static int
MAX_ASCII_CHAR
ASCII decimal value of highest character.private static int
NUL_CHAR
ASCII decimal value of nul.private static int
SP_CHAR
ASCII decimal value of space.
-
Constructor Summary
Constructors Constructor Description LdifWriter(Writer writer)
Creates a new ldif writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
createLdif(SearchResult result)
Creates an LDIF using the supplied search result.protected String
createLdifEntry(LdapEntry entry)
Creates an LDIF using the supplied ldap entry.protected String
createSearchReference(SearchReference ref)
Creates an LDIF using the supplied search reference.private boolean
encodeData(String data)
Determines whether the supplied data should be base64 encoded.void
write(SearchResult result)
Writes the supplied search result to the writer.
-
-
-
Field Detail
-
NUL_CHAR
private static final int NUL_CHAR
ASCII decimal value of nul.- See Also:
- Constant Field Values
-
LF_CHAR
private static final int LF_CHAR
ASCII decimal value of line feed.- See Also:
- Constant Field Values
-
CR_CHAR
private static final int CR_CHAR
ASCII decimal value of carriage return.- See Also:
- Constant Field Values
-
SP_CHAR
private static final int SP_CHAR
ASCII decimal value of space.- See Also:
- Constant Field Values
-
COLON_CHAR
private static final int COLON_CHAR
ASCII decimal value of colon.- See Also:
- Constant Field Values
-
LA_CHAR
private static final int LA_CHAR
ASCII decimal value of left arrow.- See Also:
- Constant Field Values
-
MAX_ASCII_CHAR
private static final int MAX_ASCII_CHAR
ASCII decimal value of highest character.- See Also:
- Constant Field Values
-
LINE_SEPARATOR
private static final String LINE_SEPARATOR
Line separator.
-
ldifWriter
private final Writer ldifWriter
Writer to write to.
-
-
Constructor Detail
-
LdifWriter
public LdifWriter(Writer writer)
Creates a new ldif writer.- Parameters:
writer
- to write LDIF to
-
-
Method Detail
-
write
public void write(SearchResult result) throws IOException
Writes the supplied search result to the writer.- Specified by:
write
in interfaceSearchResultWriter
- Parameters:
result
- search result to write- Throws:
IOException
- if an error occurs using the writer
-
createLdif
protected String createLdif(SearchResult result)
Creates an LDIF using the supplied search result.- Parameters:
result
- search result- Returns:
- LDIF
-
createLdifEntry
protected String createLdifEntry(LdapEntry entry)
Creates an LDIF using the supplied ldap entry.- Parameters:
entry
- ldap entry- Returns:
- LDIF
-
createSearchReference
protected String createSearchReference(SearchReference ref)
Creates an LDIF using the supplied search reference.- Parameters:
ref
- search reference- Returns:
- LDIF
-
encodeData
private boolean encodeData(String data)
Determines whether the supplied data should be base64 encoded. See http://www.faqs.org/rfcs/rfc2849.html for more details.- Parameters:
data
- to inspect- Returns:
- whether the data should be base64 encoded
-
-