public class LDIF
extends java.lang.Object
implements java.io.Serializable
This class implements an LDIF file parser. You can construct
an object of this class to parse data in LDIF format and
manipulate the data as individual LDIFRecord
objects.
LDIFRecord
,
Serialized FormConstructor and Description |
---|
LDIF()
Constructs an
LDIF object to parse the
LDAP data read from stdin. |
LDIF(java.io.DataInputStream ds)
Constructs an
LDIF object to parse the
LDIF data read from an input stream. |
LDIF(java.lang.String file)
Constructs an
LDIF object to parse the
LDIF data read from a specified file. |
Modifier and Type | Method and Description |
---|---|
static void |
breakString(java.io.PrintWriter pw,
java.lang.String value,
int max)
Outputs the String in LDIF line-continuation format.
|
int |
getVersion()
Gets the version of LDIF used in the data.
|
static boolean |
isPrintable(byte[] b)
Returns true if all the bytes in the given array are valid for output as a
String according to the LDIF specification.
|
static void |
main(java.lang.String[] args)
Test driver - just reads and parses an LDIF file, printing
each record as interpreted
|
LDIFRecord |
nextRecord()
Returns the next record in the LDIF data.
|
protected LDAPControl |
parse_control_spec(java.lang.String line)
Parses the specification of a control
A control looks line one of the following: control: 1.2.3.4.10.210 control: 1.2.3.4.10.210 true control: 1.2.3.4.10.210 true: someASCIIvalue control: 1.2.3.4.10.210: someASCIIvalue control: 1.2.3.4.10.210 true:: 44GK44GM44GV44KP44KJ control: 1.2.3.4.10.210:: 44GK44GM44GV44KP44KJ control: 1.2.3.4.10.210 true:< file:///usr/local/directory/cont.dta control: 1.2.3.4.10.210:< file:///usr/local/directory/cont.dta |
protected void |
throwLDIFException(java.lang.String msg)
Throws a LDIF file exception including the current line number.
|
static java.lang.String |
toPrintableString(byte[] b)
Converts a byte array to a printable string following
the LDIF rules (encode in base64 if necessary)
|
java.lang.String |
toString()
Gets the string representation of the
entire LDIF file.
|
public LDIF() throws java.io.IOException
LDIF
object to parse the
LDAP data read from stdin.java.io.IOException
- An I/O error has occurred.public LDIF(java.lang.String file) throws java.io.IOException
LDIF
object to parse the
LDIF data read from a specified file.file
- the name of the LDIF file to parsejava.io.IOException
- An I/O error has occurred.public LDIF(java.io.DataInputStream ds) throws java.io.IOException
LDIF
object to parse the
LDIF data read from an input stream.ds
- The input stream providing the LDIF datajava.io.IOException
- An I/O error has occurred.public LDIFRecord nextRecord() throws java.io.IOException
LDIFRecord
object or null if there are no more records.java.io.IOException
- An I/O error has occurred.LDIFRecord
protected LDAPControl parse_control_spec(java.lang.String line) throws java.io.IOException
line
- a line containing a control specjava.io.IOException
- if the line could not be parsedpublic static boolean isPrintable(byte[] b)
true
if all the bytes in the given array are valid for
output as a String according to the LDIF specification; otherwise,
false
.public static void breakString(java.io.PrintWriter pw, java.lang.String value, int max)
pw
- the printer writervalue
- the given string being printed outmax
- the maximum characters allowed in the linepublic int getVersion()
public java.lang.String toString()
toString
in class java.lang.Object
protected void throwLDIFException(java.lang.String msg) throws java.io.IOException
msg
- Error messagejava.io.IOException
public static java.lang.String toPrintableString(byte[] b)
b
- the byte array to convertpublic static void main(java.lang.String[] args)
args
- name of the LDIF file to parse