public class LDIFRecord
extends java.lang.Object
implements java.io.Serializable
You can get an LDIFRecord
object from LDIF data
by calling the nextRecord
method of the
LDIF
object holding the data.
If you are constructing a new LDIFRecord
object,
you can specify the content of the record in one of the
following ways:
LDIFAttributeContent
class.
LDIFAddContent
to add a new entry.
LDIFModifyContent
to modify an entry.
LDIFDeleteContent
to delete an entry.
LDIF
,
LDIFAddContent
,
LDIFModifyContent
,
LDIFDeleteContent
,
LDIFAttributeContent
,
Serialized FormConstructor and Description |
---|
LDIFRecord(java.lang.String dn,
LDIFContent content)
Constructs a new
LDIFRecord object with the
specified content. |
Modifier and Type | Method and Description |
---|---|
LDIFContent |
getContent()
Retrieves the content of the LDIF record.
|
LDAPControl[] |
getControls()
Retrieves the list of controls specified in the content
of the LDIF record, if any.
|
java.lang.String |
getDN()
Retrieves the distinguished name of the LDIF record.
|
java.lang.String |
toString()
Gets the string representation of the
LDIFRecord
object. |
public LDIFRecord(java.lang.String dn, LDIFContent content)
LDIFRecord
object with the
specified content.dn
- distinguished name of the entry associated with
the recordcontent
- content of the LDIF record. You can specify
an object of the LDIFAttributeContent
,
LDIFAddContent
, LDIFModifyContent
,
or LDIFDeleteContent
classes.LDIFAddContent
,
LDIFModifyContent
,
LDIFDeleteContent
,
LDIFAttributeContent
public java.lang.String getDN()
public LDIFContent getContent()
LDIFAttributeContent
,
LDIFAddContent
, LDIFModifyContent
,
or LDIFDeleteContent
classes.
To determine the class of the object, use the getType
method of that object. getType
returns one of
the following values:
LDIFContent.ATTRIBUTE_CONTENT
(the object is an
LDIFAttributeContent
object)
LDIFContent.ADD_CONTENT
(the object is an
LDIFAddContent
object)
LDIFContent.MODIFICATION_CONTENT
(the object is an
LDIFModifyContent
object)
LDIFContent.DELETE_CONTENT
(the object is an
LDIFDeleteContent
object)
For example:
... import netscape.ldap.*; import netscape.ldap.util.*; import java.io.*; import java.util.*; ... try { // Parse the LDIF file test.ldif. LDIF parser = new LDIF( "test.ldif" ); // Iterate through each LDIF record in the file. LDIFRecord nextRec = parser.nextRecord(); while ( nextRec != null ) { // Based on the type of content in the record, // get the content and cast it as the appropriate // type. switch( nextRec.getContent().getType() ) { case LDIFContent.ATTRIBUTE_CONTENT: LDIFAttributeContent attrContent = (LDIFAttributeContent)nextRec.getContent(); break; case LDIFContent.ADD_CONTENT: LDIFAddContent addContent = (LDIFAddContent)nextRec.getContent(); break; case LDIFContent.MODIFICATION_CONTENT: LDIFModifyContent modifyContent = (LDIFModifyContent)nextRec.getContent(); break; case LDIFContent.DELETE_CONTENT: LDIFDeleteContent deleteContent = (LDIFDeleteContent)nextRec.getContent(); break; } ... // Iterate through each record. nextRec = parser.nextRecord(); } } catch ( IOException e ) { System.out.println( "Error: " + e.toString() ); System.exit(1); } ...
LDIFAddContent
,
LDIFModifyContent
,
LDIFDeleteContent
,
LDIFAttributeContent
public LDAPControl[] getControls()
LDAPControl
objects that
represent any controls specified in the LDIF record,
or null
if none were specified.public java.lang.String toString()
LDIFRecord
object.toString
in class java.lang.Object