Class LdifEntry

java.lang.Object
org.apache.directory.api.ldap.model.ldif.LdifEntry
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Iterable<Attribute>

public class LdifEntry extends Object implements Cloneable, Externalizable, Iterable<Attribute>
A entry to be populated by an ldif parser. We will have different kind of entries :
  • added entries
  • deleted entries
  • modified entries
  • Rdn modified entries
  • Dn modified entries
Author:
Apache Directory Project
See Also:
  • Field Details

    • EMPTY_MODS

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

  • Method Details

    • 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
      • ModificationOperation.INCREMENT_ATTRIBUTE
      attr - The attribute to be added
    • addModification

      public void addModification(ModificationOperation modOp, String id)
      Add a modification with no value
      Parameters:
      modOp - The modification operation value. One of :
      • ModificationOperation.ADD_ATTRIBUTE
      • ModificationOperation.REMOVE_ATTRIBUTE
      • ModificationOperation.REPLACE_ATTRIBUTE
      • ModificationOperation.INCREMENT_ATTRIBUTE
      id - The attribute's ID
    • 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
      • ModificationOperation.INCREMENT_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 deleteOldRdn flag
      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
    • getLengthBeforeParsing

      public int getLengthBeforeParsing()
      Returns the lengthBeforeParsing of the entry at the time of parsing. This includes the lengthBeforeParsing of the comments present in entry at the time of parsing so this lengthBeforeParsing may not always match with the lengthBeforeParsing of the entry data present in memory.
      Returns:
      The entry length, comments included
    • getOffset

      public long getOffset()
      Returns:
      the offset
    • iterator

      public Iterator<Attribute> iterator()
      Returns an enumeration containing the zero or more attributes in the collection. The behavior of the enumeration is not specified if the attribute collection is changed.
      Specified by:
      iterator in interface Iterable<Attribute>
      Returns:
      an enumeration of all contained attributes
    • 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:
    • 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:
    • 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: