Class GenericEntry

java.lang.Object
com.isode.dsapi.GenericEntry
All Implemented Interfaces:
Comparable<GenericEntry>, Iterable<Attribute>
Direct Known Subclasses:
ChangeEntry, Entry

public abstract class GenericEntry extends Object implements Comparable<GenericEntry>, Iterable<Attribute>
An abstract class which is used to provide the framework for different types of entries that may be encountered when interacting with directories and processing LDIF files. There are two subclasses of GenericEntry:
  • non-change entries, represented with Entry objects. Entry objects contain the data returned by an operation which reads the directory, or loads "non-change" records from LDIF files, and provide no methods to modify the attributes they contain.
  • change entries (which are all subclasses of ChangeEntry) represent the different types of change entries that may be read from an LDIF file: Operations which update a directory use change entries: these may be loaded from an LDIF file or built using the class constructors and methods for the relevant subclass.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected List<Attribute>
    List of attributes that belong to this Entry
    protected long
    Pointer to the underlying DS_Entry for native code.
    protected static final com.isode.util.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor used by native code to create an empty object.
    protected
    GenericEntry(int type, DN dn)
    Constructor used by sub-classes to create a blank object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compare to another GenericEntry, ordering the entries by DN.
    protected void
    Releases any native structures associated with this object.
    Returns an Iterator over the normal (non-change) attributes associated with this entry, or null if this entry-type doesn't support normal attributes.
    Returns an Iterator over the change-attributes associated with this entry, or null if this entry-type doesn't support change-attributes.
    Returns the distinguished name of this Entry
    boolean
    Determine whether this entry contains any change-attributes (as would be returned by a call to getChangeIterator()).
    Returns an Iterator over whatever type of attributes that this entry stores.
    void
    setDN(DN dn)
    Set the distinguished name for the entry
    static void
    In-place sort of an array of GenericEntry instances into DN order.
    Returns a representation of this entry as an LDIF dump.
    Returns a String representation of this entry.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • logger

      protected static final com.isode.util.Logger logger
    • DS_Entry

      protected long DS_Entry
      Pointer to the underlying DS_Entry for native code. This pointer will be set by the JNI layer when it creates a new Entry object out of a DS_Entry that has been returned e.g. from a search operation. If a user ever creates a new Entry, then the method jni_create_pointer() must be called; this will create a new, empty DS_Entry structure and associate it with this object.
    • attributeList

      protected List<Attribute> attributeList
      List of attributes that belong to this Entry
  • Constructor Details

    • GenericEntry

      protected GenericEntry()
      Constructor used by native code to create an empty object.
    • GenericEntry

      protected GenericEntry(int type, DN dn) throws NativeLibraryException
      Constructor used by sub-classes to create a blank object.
      Parameters:
      type - 'N' normal, 'A' add, 'M' modify, 'D' delete, 'R' rename (ModDN)
      dn - Base DN
      Throws:
      NativeLibraryException - in case of unrecoverable native library error (including invalid 'type' argument)
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Releases any native structures associated with this object.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • setDN

      public void setDN(DN dn) throws NativeLibraryException, NullPointerException
      Set the distinguished name for the entry
      Parameters:
      dn - the distinguished name (must not be null).
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      NullPointerException - if dn is null.
    • getAttributeIterator

      public Iterator<Attribute> getAttributeIterator()
      Returns an Iterator over the normal (non-change) attributes associated with this entry, or null if this entry-type doesn't support normal attributes. This means that an Iterator is only returned for Entry instances.

      Use getChangeIterator() to fetch the changes associated with ModifyEntry and AddEntry instances.

      Returns:
      Iterator or null
    • getChangeIterator

      public Iterator<Attribute> getChangeIterator()
      Returns an Iterator over the change-attributes associated with this entry, or null if this entry-type doesn't support change-attributes. This means that an Iterator is only returned for AddEntry and ModifyEntry instances. For AddEntry the Iterator will contain AddAttribute instances. For ModifyEntry the Iterator will contain AddAttribute, DeleteAttribute and ReplaceAttribute instances.

      Use getAttributeIterator() to fetch the attributes for a normal Entry.

      Returns:
      Iterator or null
    • iterator

      public Iterator<Attribute> iterator()
      Returns an Iterator over whatever type of attributes that this entry stores.
      Specified by:
      iterator in interface Iterable<Attribute>
      Returns:
      Iterator
      See Also:
    • hasChanges

      public boolean hasChanges()
      Determine whether this entry contains any change-attributes (as would be returned by a call to getChangeIterator()). Since only AddEntry and ModifyEntry can contain changes, for other types this returns false.
      Returns:
      true if this is a ModifyEntry or AddEntry with some modifications associated with it, false otherwise.
    • getDN

      public DN getDN() throws NativeLibraryException
      Returns the distinguished name of this Entry
      Returns:
      the Entry's distinguished name
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • compareTo

      public int compareTo(GenericEntry o)
      Compare to another GenericEntry, ordering the entries by DN.
      Specified by:
      compareTo in interface Comparable<GenericEntry>
    • sortArrayByDN

      public static void sortArrayByDN(GenericEntry[] array)
      In-place sort of an array of GenericEntry instances into DN order.
      Parameters:
      array - GenericEntry[] which will be sorted in place.
      Since:
      14.4
    • toString

      public String toString()
      Returns a String representation of this entry.
      Overrides:
      toString in class Object
      Returns:
      a String representation of the entry.
    • toLDIF

      Returns a representation of this entry as an LDIF dump.
      Returns:
      LDIF dump of the entry
      Throws:
      BadEntryException - The entry could not be converted to LDIF format
      BadDNException - The DN could not be converted to LDIF format
      NativeLibraryException - Internal unrecoverable error
      Since:
      15.0