netscape.ldap.util
Class LDIF
- Serializable
public class LDIF
extends java.lang.Object
implements Serializable
LDAP Data Interchange Format (LDIF) is a file format used to
import and export directory data from an LDAP server and to
describe a set of changes to be applied to data in a directory.
This format is described in the Internet draft
The LDAP Data Interchange Format (LDIF) -
Technical Specification.
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.
LDIF() - Constructs an
LDIF object to parse the
LDAP data read from stdin.
|
LDIF(DataInputStream ds) - Constructs an
LDIF object to parse the
LDIF data read from an input stream.
|
LDIF(String file) - Constructs an
LDIF object to parse the
LDIF data read from a specified file.
|
static void | breakString(PrintWriter pw, 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(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(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:<32file:///usr/local/directory/cont.dta
control: 1.2.3.4.10.210:<32file:///usr/local/directory/cont.dta
|
protected void | throwLDIFException(String msg) - Throws a LDIF file exception including the current line number.
|
static String | toPrintableString(byte[] b) - Converts a byte array to a printable string following
the LDIF rules (encode in base64 if necessary)
|
String | toString() - Gets the string representation of the
entire LDIF file.
|
LDIF
public LDIF()
throws IOException
Constructs an LDIF
object to parse the
LDAP data read from stdin.
LDIF
public LDIF(DataInputStream ds)
throws IOException
Constructs an LDIF
object to parse the
LDIF data read from an input stream.
ds
- The input stream providing the LDIF data
LDIF
public LDIF(String file)
throws IOException
Constructs an LDIF
object to parse the
LDIF data read from a specified file.
file
- the name of the LDIF file to parse
breakString
public static void breakString(PrintWriter pw,
String value,
int max)
Outputs the String in LDIF line-continuation format. No line will be longer
than the given max. A continuation line starts with a single blank space.
pw
- the printer writervalue
- the given string being printed outmax
- the maximum characters allowed in the line
getVersion
public int getVersion()
Gets the version of LDIF used in the data.
- version of LDIF used in the data.
isPrintable
public 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. If not, the array should
output base64-encoded.
true
if all the bytes in the given array are valid for
output as a String according to the LDIF specification; otherwise,
false
.
main
public static void main(String[] args)
Test driver - just reads and parses an LDIF file, printing
each record as interpreted
args
- name of the LDIF file to parse
nextRecord
public LDIFRecord nextRecord()
throws IOException
Returns the next record in the LDIF data. You can call this
method repeatedly to iterate through all records in the LDIF data.
- the next record as an
LDIFRecord
object or null if there are no more records.
parse_control_spec
protected LDAPControl parse_control_spec(String line)
throws IOException
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:<32file:///usr/local/directory/cont.dta
control: 1.2.3.4.10.210:<32file:///usr/local/directory/cont.dta
line
- a line containing a control spec
throwLDIFException
protected void throwLDIFException(String msg)
throws IOException
Throws a LDIF file exception including the current line number.
toPrintableString
public static String toPrintableString(byte[] b)
Converts a byte array to a printable string following
the LDIF rules (encode in base64 if necessary)
b
- the byte array to convert
- a converted string which is printable.
toString
public String toString()
Gets the string representation of the
entire LDIF file.
- the string representation of the entire LDIF data file.