org.apache.directory.api.ldap.model.ldif
Class LdifEntry

java.lang.Object
  extended by org.apache.directory.api.ldap.model.ldif.LdifEntry
All Implemented Interfaces:
Externalizable, Serializable, Cloneable

public class LdifEntry
extends Object
implements Cloneable, Externalizable

A entry to be populated by an ldif parser. We will have different kind of entries :

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
static Modification[] EMPTY_MODS
          Used in toArray()
 
Constructor Summary
LdifEntry()
          Creates a new LdifEntry object.
LdifEntry(Dn dn, Object... avas)
          Creates a LdifEntry using a list of strings representing the Ldif element
LdifEntry(Entry entry)
          Creates a new LdifEntry object, storing an Entry
LdifEntry(String dn, Object... strings)
          Creates a LdifEntry using a list of strings representing the Ldif element
 
Method Summary
 void addAttribute(Attribute attr)
          Add an attribute to the entry
 void addAttribute(String id, Object... values)
          Add an attribute to the entry
 void addControl(Control... controls)
          Add a control to the entry
 void addModification(Modification modification)
          Add a modification item (used by modify operations)
 void addModification(ModificationOperation modOp, Attribute attr)
          Add a modification item (used by modify operations)
 void addModification(ModificationOperation modOp, String id, Object value)
          Add a modification
 LdifEntry clone()
          Clone method
 boolean equals(Object o)
          
 Attribute get(String attributeId)
          Returns a attribute given it's id
 ChangeType getChangeType()
          Get the change type
 LdifControl getControl(String oid)
           
 Map<String,LdifControl> getControls()
           
 Dn getDn()
           
 Entry getEntry()
          Get the entry's entry
 Modification[] getModificationArray()
          Gets the modification items as an array.
 List<Modification> getModifications()
           
 String getNewRdn()
           
 String getNewSuperior()
           
 boolean hasControls()
           
 int hashCode()
           
 boolean isChangeAdd()
           
 boolean isChangeDelete()
           
 boolean isChangeModDn()
           
 boolean isChangeModify()
           
 boolean isChangeModRdn()
           
 boolean isDeleteOldRdn()
           
 boolean isEntry()
          Tells if the current entry is a added one
 boolean isLdifChange()
           
 boolean isLdifContent()
           
 void putAttribute(String id, Object value)
          Add an attribute value to an existing attribute
 void readExternal(ObjectInput in)
           
 void removeAttribute(String... ids)
          Remove a list of Attributes from the LdifEntry
 void setChangeType(ChangeType changeType)
          Set the modification type
 void setChangeType(String changeType)
          Set the change type
 void setDeleteOldRdn(boolean deleteOldRdn)
          Set the flage deleteOldRdn
 void setDn(Dn dn)
          Set the Distinguished Name
 void setDn(String dn)
          Set the Distinguished Name
 void setNewRdn(String newRdn)
          Set the new Rdn
 void setNewSuperior(String newSuperior)
          Set the new superior
 int size()
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_MODS

public static final Modification[] EMPTY_MODS
Used in toArray()

Constructor Detail

LdifEntry

public LdifEntry()
Creates a new LdifEntry object.


LdifEntry

public LdifEntry(Entry entry)
Creates a new LdifEntry object, storing an Entry


LdifEntry

public LdifEntry(Dn dn,
                 Object... avas)
          throws LdapInvalidAttributeValueException,
                 LdapLdifException
Creates a LdifEntry using a list of strings representing the Ldif element

Parameters:
dn - The LdifEntry DN
avas - The Ldif to convert to an LdifEntry
Throws:
LdapInvalidAttributeValueException - If either the AttributeType or the associated value is incorrect
LdapLdifException - If we get any other exception

LdifEntry

public LdifEntry(String dn,
                 Object... strings)
          throws LdapInvalidAttributeValueException,
                 LdapLdifException,
                 LdapInvalidDnException
Creates a LdifEntry using a list of strings representing the Ldif element

Parameters:
dn - The LdifEntry DN
avas - The Ldif attributes and values to convert to an LdifEntry
Throws:
LdapInvalidDnException - If the Dn is invalid
LdapInvalidAttributeValueException - If either the AttributeType or the associated value is incorrect
LdapLdifException - If we get any other exception
Method Detail

setDn

public void setDn(Dn dn)
Set the Distinguished Name

Parameters:
dn - The Distinguished Name

setDn

public void setDn(String dn)
           throws LdapInvalidDnException
Set the Distinguished Name

Parameters:
dn - The Distinguished Name
Throws:
LdapInvalidDnException - If the Dn is invalid

setChangeType

public void setChangeType(ChangeType changeType)
Set the modification type

Parameters:
changeType - The change type

setChangeType

public void setChangeType(String changeType)
Set the change type

Parameters:
changeType - The change type

addModification

public void addModification(Modification modification)
Add a modification item (used by modify operations)

Parameters:
modification - The modification to be added

addModification

public void addModification(ModificationOperation modOp,
                            Attribute attr)
Add a modification item (used by modify operations)

Parameters:
modOp - The operation. One of :
  • ModificationOperation.ADD_ATTRIBUTE
  • ModificationOperation.REMOVE_ATTRIBUTE
  • ModificationOperation.REPLACE_ATTRIBUTE
attr - The attribute to be added

addModification

public void addModification(ModificationOperation modOp,
                            String id,
                            Object value)
Add a modification

Parameters:
modOp - The modification operation value. One of :
  • ModificationOperation.ADD_ATTRIBUTE
  • ModificationOperation.REMOVE_ATTRIBUTE
  • ModificationOperation.REPLACE_ATTRIBUTE
id - The attribute's ID
value - The attribute's value

addAttribute

public void addAttribute(Attribute attr)
                  throws LdapException
Add an attribute to the entry

Parameters:
attr - The attribute to be added
Throws:
LdapException - if something went wrong

addAttribute

public void addAttribute(String id,
                         Object... values)
                  throws LdapException
Add an attribute to the entry

Parameters:
id - The attribute ID
values - The attribute values
Throws:
LdapException - if something went wrong

removeAttribute

public void removeAttribute(String... ids)
Remove a list of Attributes from the LdifEntry

Parameters:
ids - The Attributes to remove

putAttribute

public void putAttribute(String id,
                         Object value)
                  throws LdapException
Add an attribute value to an existing attribute

Parameters:
id - The attribute ID
value - The attribute value
Throws:
LdapException - if something went wrong

getChangeType

public ChangeType getChangeType()
Get the change type

Returns:
The change type. One of :
  • ADD
  • MODIFY
  • MODDN
  • MODRDN
  • DELETE
  • NONE

getModifications

public List<Modification> getModifications()
Returns:
The list of modification items

getModificationArray

public Modification[] getModificationArray()
Gets the modification items as an array.

Returns:
modification items as an array.

getDn

public Dn getDn()
Returns:
The entry Distinguished name

size

public int size()
Returns:
The number of entry modifications

get

public Attribute get(String attributeId)
Returns a attribute given it's id

Parameters:
attributeId - The attribute Id
Returns:
The attribute if it exists

getEntry

public Entry getEntry()
Get the entry's entry

Returns:
the stored Entry

isDeleteOldRdn

public boolean isDeleteOldRdn()
Returns:
True, if the old Rdn should be deleted.

setDeleteOldRdn

public void setDeleteOldRdn(boolean deleteOldRdn)
Set the flage deleteOldRdn

Parameters:
deleteOldRdn - True if the old Rdn should be deleted

getNewRdn

public String getNewRdn()
Returns:
The new Rdn

setNewRdn

public void setNewRdn(String newRdn)
Set the new Rdn

Parameters:
newRdn - The new Rdn

getNewSuperior

public String getNewSuperior()
Returns:
The new superior

setNewSuperior

public void setNewSuperior(String newSuperior)
Set the new superior

Parameters:
newSuperior - The new Superior

isLdifContent

public boolean isLdifContent()
Returns:
True if this is a content ldif

isLdifChange

public boolean isLdifChange()
Returns:
True if there is this is a change ldif

isChangeAdd

public boolean isChangeAdd()
Returns:
True if the entry is an ADD entry

isChangeDelete

public boolean isChangeDelete()
Returns:
True if the entry is a DELETE entry

isChangeModDn

public boolean isChangeModDn()
Returns:
True if the entry is a MODDN entry

isChangeModRdn

public boolean isChangeModRdn()
Returns:
True if the entry is a MODRDN entry

isChangeModify

public boolean isChangeModify()
Returns:
True if the entry is a MODIFY entry

isEntry

public boolean isEntry()
Tells if the current entry is a added one

Returns:
true if the entry is added

hasControls

public boolean hasControls()
Returns:
true if the entry has some controls

getControls

public Map<String,LdifControl> getControls()
Returns:
The set of controls for this entry

getControl

public LdifControl getControl(String oid)
Parameters:
oid - The control's OID
Returns:
The associated control, if any

addControl

public void addControl(Control... controls)
Add a control to the entry

Parameters:
controls - The added controls

clone

public LdifEntry clone()
                throws CloneNotSupportedException
Clone method

Overrides:
clone in class Object
Returns:
a clone of the current instance
Throws:
CloneNotSupportedException - If there is some problem while cloning the instance

toString

public String toString()
Overrides:
toString in class Object
Returns:
a String representing the Entry, as a LDIF

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Returns:
the instance's hash code
See Also:
Object.hashCode()

equals

public boolean equals(Object o)

Overrides:
equals in class Object

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Parameters:
in - The stream from which the LdifEntry is read
Throws:
IOException - If the stream can't be read
ClassNotFoundException - If the LdifEntry can't be created
See Also:
Externalizable.readExternal(ObjectInput)

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Parameters:
out - The stream in which the ChangeLogEvent will be serialized.
Throws:
IOException - If the serialization fail
See Also:
Externalizable.readExternal(ObjectInput)


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.