|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.ldap.util.LDIFWriter
public class LDIFWriter
LDIFWriter is used to write LDIF content records or LDIF change records to the OutputStream object.
The object of the class is used to generate LDIF content record or LDIF change record lines and write the lines to OUtputStream
Field Summary | |
---|---|
private java.io.BufferedWriter |
bufWriter
|
private java.lang.Boolean |
requestFile
|
private java.lang.String |
version
|
Constructor Summary | |
---|---|
|
LDIFWriter(java.io.OutputStream out)
Constructs an LDIFWriter object. |
|
LDIFWriter(java.io.OutputStream out,
java.lang.String version,
boolean request)
Constructs an LDIFWriter object. |
private |
LDIFWriter(java.io.OutputStream out,
java.lang.String version,
java.lang.Boolean request)
Constructs an LDIFWriter object. |
Method Summary | |
---|---|
void |
finish()
Write all remaining data to the output stream |
java.lang.String |
getVersion()
Gets the version of the LDIF data associated with the input stream |
boolean |
isPrintable(byte[] bytes)
Check if the input byte array object is safe to make a String. |
boolean |
isRequest()
Returns true if request data ist associated with the input stream, or false if content data. |
private void |
writeAddRequest(LDAPEntry entry,
LDAPControl[] ctrls)
Used to generate LDIF content record or LDIF change/add record lines. |
private void |
writeAttribute(java.lang.String attrName,
byte[] attrVal)
Write attribute name and value into outputStream. |
private void |
writeAttribute(java.lang.String attrName,
java.lang.String attrVal)
Write attribute name and value into outputStream. |
void |
writeComments(java.lang.String line)
Write a comment line into the LDIF OutputStream. |
private void |
writeControls(LDAPControl[] ctrls)
Write control line(s). |
private void |
writeDeleteRequest(java.lang.String dn,
LDAPControl[] ctrls)
Used to generate LDIF change/delete record lines. |
private void |
writeDN(java.lang.String dn)
Write the DN to the outputStream. |
void |
writeEntry(LDAPEntry entry)
Write an LDAP record into LDIF file as LDAPContent data. |
void |
writeEntry(LDAPEntry entry,
LDAPControl[] controls)
Write an LDAP record into LDIF file as LDAPContent data. |
void |
writeError(java.lang.Exception e)
Writes an exception as a comment in LDIF. |
private void |
writeLine(java.lang.String line)
Write a line into the OutputStream. |
void |
writeMessage(LDAPMessage request)
Write an LDAP record into LDIF file. |
private void |
writeModifyDNRequest(java.lang.String dn,
java.lang.String newRDN,
boolean deleteOldRDN,
java.lang.String newSuperior,
LDAPControl[] ctrls)
Used to generate LDIF change/moddn record lines. |
private void |
writeModifyRequest(java.lang.String dn,
LDAPModification[] mods,
LDAPControl[] ctrls)
Used to generate LDIF change/modify record lines. |
private void |
writeVersionLine()
Write the version line of LDIF file into the OutputStream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.Boolean requestFile
private java.io.BufferedWriter bufWriter
private java.lang.String version
Constructor Detail |
---|
public LDIFWriter(java.io.OutputStream out) throws java.io.IOException
If the first message is one of LDAPAddRequest, LDAPDeleteRequest, LDAPModifyDNRequest, or LDAPModifyRequest the file will be writen as an LDAP request (change) file.
If the first message written to the file is an LDAPSearchResult object an LDIF content file will be written.
You are not allowed to mix request data and content data
out
- The OutputStream where the LDIF data will be written.
java.io.IOException
- for errors writing to the stream.public LDIFWriter(java.io.OutputStream out, java.lang.String version, boolean request) throws java.io.IOException
out
- The OutputStream where the LDIF data will be written.version
- The version to set in the LDIF file, must be "1".request
- If true sets the out file type to request (change) data,
else the file type will be content.
java.io.IOException
private LDIFWriter(java.io.OutputStream out, java.lang.String version, java.lang.Boolean request) throws java.io.IOException
You are not allowed to mix request data and content data
out
- The OutputStream where the LDIF data will be written.version
- The version to set in the LDIF file, must be "1".request
- If true sets the out file type to request (change) data,
else the file type will be content.
java.io.IOException
Method Detail |
---|
public void writeEntry(LDAPEntry entry) throws java.io.IOException
You are not allowed to mix request data and content data
writeEntry
in interface LDAPWriter
entry
- LDAPEntry object
java.io.IOException
- if an I/O error occurs.LDAPEntry
public void writeEntry(LDAPEntry entry, LDAPControl[] controls) throws java.io.IOException
You are not allowed to mix request data and content data
writeEntry
in interface LDAPWriter
entry
- LDAPEntry objectcontrols
- Controls that were returned with this entry
java.io.IOException
- if an I/O error occurs.LDAPEntry
public void writeMessage(LDAPMessage request) throws java.io.IOException
You are not allowed to mix request data and content data
writeMessage
in interface LDAPWriter
request
- LDAPMessage object
java.io.IOException
- if an I/O error occurs.LDAPSearchResults
,
LDAPAddRequest
,
LDAPDeleteRequest
,
LDAPModifyDNRequest
,
LDAPModifyRequest
public void writeComments(java.lang.String line) throws java.io.IOException
an '#' char is added to the front of each line to indicate that the line is a comment line. If a line contains more than 78 chars, it will be split into multiple lines each of which starts with '#'
writeComments
in interface LDAPWriter
line
- The comment lines to be written to the OutputStream
java.io.IOException
- if an I/O error occurs.public void writeError(java.lang.Exception e) throws java.io.IOException
writeError
in interface LDAPWriter
e
- Exception to be written.
java.io.IOException
public java.lang.String getVersion()
getVersion
in interface LDAPWriter
public boolean isRequest()
isRequest
in interface LDAPWriter
public boolean isPrintable(byte[] bytes)
Check if the input byte array contains any un-printable value
bytes
- The byte array object to be checked.
private void writeVersionLine() throws java.io.IOException
Two extra lines will be written to separate version line with the rest of lines in LDIF file
java.io.IOException
- if an I/O error occurs.private void writeLine(java.lang.String line) throws java.io.IOException
If the line contains more than 80 chars, it will be splited into multiple lines each of which starts with a space ( ASCII ' ') except the first one.
line
- The line to be written to the OutputStream
java.io.IOException
- if an I/O error occurs.private void writeAddRequest(LDAPEntry entry, LDAPControl[] ctrls) throws java.io.IOException
Turn LDAPEntry object and LDAPControl[] object into LDIF record lines
entry
- LDAPREntry objectctrls
- LDAPControl object
java.io.IOException
private void writeModifyRequest(java.lang.String dn, LDAPModification[] mods, LDAPControl[] ctrls) throws java.io.IOException
Turn entry DN, LDAPModification[] object, and LDAPControl[] object into LDIF LDIF record fields and then turn record fields into LDIF change/modify record lines
dn
- String object representing entry DNmods
- LDAPModification array objectctrls
- LDAPControl array object
java.io.IOException
LDAPModification
,
LDAPControl
private void writeModifyDNRequest(java.lang.String dn, java.lang.String newRDN, boolean deleteOldRDN, java.lang.String newSuperior, LDAPControl[] ctrls) throws java.io.IOException
Turn entry DN and moddn information into LDIF change/modify record lines
dn
- String object representing entry DNnewRDN
- The NewRDN for the ModDN requestdeleteOldRDN
- the deleteOldRDN flagnewSuperior
- the new Superior DN for a move, or null if renamectrls
- LDAPControl array object
java.io.IOException
private void writeDeleteRequest(java.lang.String dn, LDAPControl[] ctrls) throws java.io.IOException
Turn entry DN, controls and change type into LDIF change/delete record fields and then turn record fields into LDIF moddn record lines
dn
- String object representing entry DNctrls
- LDAPControl array object
java.io.IOException
LDAPControl
private void writeDN(java.lang.String dn) throws java.io.IOException
dn
- the DN to write
java.io.IOException
private void writeControls(LDAPControl[] ctrls) throws java.io.IOException
ctrls
- LDAPControl array object
java.io.IOException
private void writeAttribute(java.lang.String attrName, java.lang.String attrVal) throws java.io.IOException
Check if attrVal starts with NUL, LF, CR, ' ', ':', or '<' or contains any NUL, LF, or CR, and then write it out
java.io.IOException
private void writeAttribute(java.lang.String attrName, byte[] attrVal) throws java.io.IOException
Check if attribute value contains NON-SAFE-INIT-CHAR or NON-SAFE-CHAR. if it does, it needs to be base64 encoded and then write it out
java.io.IOException
public void finish() throws java.io.IOException
finish
in interface LDAPWriter
java.io.IOException
|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |