All LDAP Classes
Internal LDAP Classes

com.novell.ldap.util
Class LDIFReader

java.lang.Object
  extended by com.novell.ldap.util.LDIFReader
All Implemented Interfaces:
LDAPReader

public class LDIFReader
extends java.lang.Object
implements LDAPReader

The class to process the inputStream object to read an LDIF file.

This calss reads LDAP entries and LDAP Requests form an LDIF file

The constructors uses a default size value of 8,192 to create the buffering character-input stream and assume that the size is big enough to hold the dn field and the first line of the next field of the first record in the LDIF file currently being read.

The constructors uses '1' as default LDIF file version


Field Summary
private  java.io.BufferedReader bufReader
           
private  byte[] bytes
           
private  java.util.ArrayList cList
           
private  boolean control
           
private  LDAPControl[] controls
           
private  LDAPEntry currentEntry
           
private  LDAPMessage currentRequest
           
private  int dnlNumber
           
private  java.lang.String entryDN
           
private  int fNumber
           
private  int lNumber
           
private  java.lang.String[] modInfo
           
private  LDAPModification[] mods
           
private  int reqType
           
private  boolean requestFile
           
private  java.util.ArrayList rFields
           
private  java.lang.String version
           
 
Constructor Summary
LDIFReader(java.io.InputStream in)
          Constructs an LDIFReader object by initializing LDIF_VERSION, isRequest, InputStreamReader, and BufferedReader.
LDIFReader(java.io.InputStream in, int version)
          Constructs an LDIFReader object by initializing LDIF_VERSION, isRequest, InputStreamReader, and BufferedReader.
LDIFReader(java.io.InputStream in, int version, int bufSize)
          Constructs an LDIFReader object by initializing LDIF_VERSION, isRequest, InputStreamReader, and BufferedReader.
 
Method Summary
 java.lang.String getVersion()
          Gets the version of the LDIF data associated with the input stream
private  int IndexOf(java.lang.StringBuffer bl, int ch)
          Returns the index within this StringBuffer object of the first occurence of the specified char.
 boolean isRequest()
          Returns true if request data ist associated with the input stream, or false if content data.
 LDAPMessage readMessage()
          Read LDAP Requests from the LDIF request (change) file or content file.
private  void readRecordFields()
          Read all lines in the current record, convert record lines to the record fields, and trim off extra spaces in record fields.
private  void setRequest(boolean type)
          Sets the request type of the file being read, true if request data or false if content data.
private  void setVersion(int value)
          Gets the version of the LDIF data associated with the input stream
private  void toLDAPEntry()
          Process LDIF record fields to generate an LDAPEntry.
private  void toLDAPModifications()
          Build LDAPModification array based on the content of LDIF modify record.
private  void toModInfo()
          Build String array object that contains moddn information.
private  void toRecordProperties()
          Set record properties.
private  java.lang.StringBuffer trimField(java.lang.StringBuffer line)
          trimField trims off extra spaces in a field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestFile

private boolean requestFile

version

private java.lang.String version

reqType

private int reqType

lNumber

private int lNumber

dnlNumber

private int dnlNumber

fNumber

private int fNumber

bytes

private byte[] bytes

control

private boolean control

entryDN

private java.lang.String entryDN

modInfo

private java.lang.String[] modInfo

rFields

private java.util.ArrayList rFields

cList

private java.util.ArrayList cList

bufReader

private java.io.BufferedReader bufReader

controls

private LDAPControl[] controls

currentEntry

private LDAPEntry currentEntry

mods

private LDAPModification[] mods

currentRequest

private LDAPMessage currentRequest
Constructor Detail

LDIFReader

public LDIFReader(java.io.InputStream in)
           throws java.io.IOException,
                  LDAPLocalException
Constructs an LDIFReader object by initializing LDIF_VERSION, isRequest, InputStreamReader, and BufferedReader.

Parameters:
in - The InputStream object to be processed by LDIFReader
Throws:
java.io.IOException
LDAPLocalException

LDIFReader

public LDIFReader(java.io.InputStream in,
                  int version)
           throws java.io.IOException,
                  LDAPLocalException
Constructs an LDIFReader object by initializing LDIF_VERSION, isRequest, InputStreamReader, and BufferedReader.

Parameters:
in - The Inputstream object to be processed by LDIFReader
version - The version currently used in the LDIF file
Throws:
java.io.IOException
LDAPLocalException

LDIFReader

public LDIFReader(java.io.InputStream in,
                  int version,
                  int bufSize)
           throws java.io.IOException,
                  LDAPLocalException
Constructs an LDIFReader object by initializing LDIF_VERSION, isRequest, InputStreamReader, and BufferedReader.

Parameters:
in - The Inputstream object to be processed by LDIFReader
version - The version currently used in the LDIF file
bufSize - The size used to create a buffering character-input stream. The defaule value is 8,192.
Throws:
java.io.IOException
LDAPLocalException
Method Detail

getVersion

public java.lang.String getVersion()
Gets the version of the LDIF data associated with the input stream

Specified by:
getVersion in interface LDAPReader
Returns:
the version number

setVersion

private void setVersion(int value)
Gets the version of the LDIF data associated with the input stream

Parameters:
value - the version number

isRequest

public boolean isRequest()
Returns true if request data ist associated with the input stream, or false if content data.

Specified by:
isRequest in interface LDAPReader
Returns:
true if input stream contains request data.

setRequest

private void setRequest(boolean type)
Sets the request type of the file being read, true if request data or false if content data.

Parameters:
type - sets the type of file to content or request data.

readMessage

public LDAPMessage readMessage()
                        throws java.io.IOException,
                               LDAPException
Read LDAP Requests from the LDIF request (change) file or content file.

Specified by:
readMessage in interface LDAPReader
Returns:
LDAPMessage specified by the record
Throws:
java.io.IOException
LDAPException

readRecordFields

private void readRecordFields()
                       throws java.io.IOException,
                              LDAPException
Read all lines in the current record, convert record lines to the record fields, and trim off extra spaces in record fields.

Throws:
java.io.IOException
LDAPException

toRecordProperties

private void toRecordProperties()
                         throws java.io.IOException,
                                LDAPException
Set record properties.

For LDIF content record, LDAPEntry specidfied by this record is created

For LDIF change record, depending on the request type, either LDAPEntry, modInfo, or LDAPModifiction array along with the controls associated with the request are created

Throws:
java.io.IOException
LDAPException

toLDAPEntry

private void toLDAPEntry()
                  throws LDAPLocalException
Process LDIF record fields to generate an LDAPEntry.

Throws:
LDAPLocalException

toModInfo

private void toModInfo()
                throws LDAPLocalException
Build String array object that contains moddn information.

Throws:
LDAPLocalException

toLDAPModifications

private void toLDAPModifications()
                          throws LDAPLocalException
Build LDAPModification array based on the content of LDIF modify record.

Throws:
LDAPLocalException

IndexOf

private int IndexOf(java.lang.StringBuffer bl,
                    int ch)
Returns the index within this StringBuffer object of the first occurence of the specified char.

Parameters:
bl - The StringBuffer object
ch - The character to look for in the StringBuffer object
Returns:
The index of the first occurence of the character in the StringBuffer object, or -1 if the character does not occur.

trimField

private java.lang.StringBuffer trimField(java.lang.StringBuffer line)
                                  throws LDAPLocalException
trimField trims off extra spaces in a field. It also trims confield and constructs control onjects.

Throws:
LDAPLocalException

All LDAP Classes
Internal LDAP Classes

Copyright ? 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000