Class GenericEntry

  • All Implemented Interfaces:
    java.lang.Comparable<GenericEntry>, java.lang.Iterable<Attribute>
    Direct Known Subclasses:
    ChangeEntry, Entry

    public abstract class GenericEntry
    extends java.lang.Object
    implements java.lang.Comparable<GenericEntry>, java.lang.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 java.util.List<Attribute> attributeList
      List of attributes that belong to this Entry
      protected long DS_Entry
      Pointer to the underlying DS_Entry for native code.
      protected static com.isode.util.Logger logger  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected GenericEntry()
      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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(GenericEntry o)
      Compare to another GenericEntry, ordering the entries by DN.
      protected void finalize()
      Releases any native structures associated with this object.
      java.util.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.
      java.util.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.
      DN getDN()
      Returns the distinguished name of this Entry
      boolean hasChanges()
      Determine whether this entry contains any change-attributes (as would be returned by a call to getChangeIterator()).
      java.util.Iterator<Attribute> iterator()
      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 sortArrayByDN​(GenericEntry[] array)
      In-place sort of an array of GenericEntry instances into DN order.
      java.lang.String toLDIF()
      Returns a representation of this entry as an LDIF dump.
      java.lang.String toString()
      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 Detail

      • 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 java.util.List<Attribute> attributeList
        List of attributes that belong to this Entry
    • Constructor Detail

      • 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 Detail

      • finalize

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

        public void setDN​(DN dn)
                   throws NativeLibraryException,
                          java.lang.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
        java.lang.NullPointerException - if dn is null.
      • getAttributeIterator

        public java.util.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 java.util.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
      • 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 java.lang.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 java.lang.String toString()
        Returns a String representation of this entry.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the entry.