Package netscape.ldap.util
Class LDIFRecord
- java.lang.Object
-
- netscape.ldap.util.LDIFRecord
-
- All Implemented Interfaces:
java.io.Serializable
public class LDIFRecord extends java.lang.Object implements java.io.SerializableAn object of this class represents an LDIF record in an LDIF file (or in LDIF data). A record can contain a list of attributes (which describes an entry) or a list of modifications (which decribes the changes that need to be made to an entry). Each record also has a distinguished name.You can get an
LDIFRecordobject from LDIF data by calling thenextRecordmethod of theLDIFobject holding the data.If you are constructing a new
LDIFRecordobject, you can specify the content of the record in one of the following ways:- To create a record that specifies an entry, use an object of
the
LDIFAttributeContentclass. - To create a record that specifies a modification to be made,
use an object of one of the following classes:
- Use
LDIFAddContentto add a new entry. - Use
LDIFModifyContentto modify an entry. - Use
LDIFDeleteContentto delete an entry.
- Use
- Version:
- 1.0
- See Also:
LDIF,LDIFAddContent,LDIFModifyContent,LDIFDeleteContent,LDIFAttributeContent, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LDIFRecord(java.lang.String dn, LDIFContent content)Constructs a newLDIFRecordobject with the specified content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LDIFContentgetContent()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.StringgetDN()Retrieves the distinguished name of the LDIF record.java.lang.StringtoString()Gets the string representation of theLDIFRecordobject.
-
-
-
Constructor Detail
-
LDIFRecord
public LDIFRecord(java.lang.String dn, LDIFContent content)Constructs a newLDIFRecordobject with the specified content.- Parameters:
dn- distinguished name of the entry associated with the recordcontent- content of the LDIF record. You can specify an object of theLDIFAttributeContent,LDIFAddContent,LDIFModifyContent, orLDIFDeleteContentclasses.- See Also:
LDIFAddContent,LDIFModifyContent,LDIFDeleteContent,LDIFAttributeContent
-
-
Method Detail
-
getDN
public java.lang.String getDN()
Retrieves the distinguished name of the LDIF record.- Returns:
- the distinguished name of the LDIF record.
-
getContent
public LDIFContent getContent()
Retrieves the content of the LDIF record. The content is an object of theLDIFAttributeContent,LDIFAddContent,LDIFModifyContent, orLDIFDeleteContentclasses.To determine the class of the object, use the
getTypemethod of that object.getTypereturns one of the following values:LDIFContent.ATTRIBUTE_CONTENT(the object is anLDIFAttributeContentobject)LDIFContent.ADD_CONTENT(the object is anLDIFAddContentobject)LDIFContent.MODIFICATION_CONTENT(the object is anLDIFModifyContentobject)LDIFContent.DELETE_CONTENT(the object is anLDIFDeleteContentobject)
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); } ...- Returns:
- the content of the LDIF record.
- See Also:
LDIFAddContent,LDIFModifyContent,LDIFDeleteContent,LDIFAttributeContent
-
getControls
public LDAPControl[] getControls()
Retrieves the list of controls specified in the content of the LDIF record, if any.- Returns:
- an array of
LDAPControlobjects that represent any controls specified in the LDIF record, ornullif none were specified.
-
toString
public java.lang.String toString()
Gets the string representation of theLDIFRecordobject.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation of the LDIF record.
-
-