Class Entry

  • All Implemented Interfaces:
    java.lang.Comparable<GenericEntry>, java.lang.Iterable<Attribute>

    public class Entry
    extends GenericEntry
    A class which encapsulates a normal non-change entry. This is regarded as a read-only type -- no more attributes can be added once the entry has been constructed.

    Entry objects are returned via an Indication when data is read from a directory, or when reading non-change entries from an LDIF file.

    See Also:
    Indication.getEntry(int), LDIF.getEntry(), LDIF.get()
    • Constructor Detail

      • Entry

        public Entry​(DN dn)
        Create a new blank Entry using a specified DN
        Parameters:
        dn - the distinguished name (must not be null)
        Throws:
        java.lang.NullPointerException - if dn is null
        NativeLibraryException - if an unrecoverable error was detected by the native library
      • Entry

        public Entry​(ModifyEntry change)
              throws DeleteAttributeException
        Create an Entry from a ModifyEntry, by applying the change to an empty Entry.

        If one or more delete-attribute modifications from the ModifyEntry fail (due to not matching a value), then the DeleteAttributeException is thrown. This exception contains the resulting Entry without the failed deletions, which is otherwise complete and correct and which can be used if deletions failing is acceptable.

        Parameters:
        change - ModifyEntry to apply to an empty entry
        Throws:
        DeleteAttributeException - In the case that there are failed deletions
      • Entry

        public Entry​(AddEntry add)
        Create an Entry from an AddEntry.
        Parameters:
        add - AddEntry to convert
      • Entry

        public Entry​(Entry entry)
        Create an Entry by copying an existing Entry.
        Parameters:
        entry - Entry to copy
        Since:
        14.6
      • Entry

        public Entry​(Entry entry,
                     ModifyEntry change)
              throws DeleteAttributeException
        Create an Entry containing the result of applying a ModifyEntry to the given Entry.

        If one or more delete-attribute modifications from the ModifyEntry fail (due to not matching a value), then the DeleteAttributeException is thrown. This exception contains the resulting Entry without the failed deletions, which is otherwise complete and correct and which can be used if deletions failing is acceptable.

        Parameters:
        entry - Base entry to apply changes to
        change - Changes to apply
        Throws:
        DeleteAttributeException - In the case that there are failed deletions
    • Method Detail

      • getAttributeIterator

        public java.util.Iterator<Attribute> getAttributeIterator()
        Returns an Iterator over all the Attribute instances associated with this Entry.
        Overrides:
        getAttributeIterator in class GenericEntry
        Returns:
        Iterator
      • getAttributeCount

        public int getAttributeCount()
        Returns a count of the number of attributes attached to this entry. The value returned by this method may be used to determine the limit for a subsequent call to getAttribute().
        Returns:
        attribute count
        See Also:
        getAttribute(int)
      • getAttribute

        public Attribute getAttribute​(int index)
        Returns a specific Attribute for this Entry. The value specified by index is zero based and must not be equal to or greater than the value returned by getAttributeCount().
        Parameters:
        index - a value which must be between 0 and one less than whatever getAttributeCount() returns
        Returns:
        an Attribute
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if index is out of range.
        See Also:
        getAttributeCount()
      • getAttribute

        public Attribute getAttribute​(AttributeType attrType)
                               throws NoSuchAttributeException
        Return a specific attribute from this Entry's list of attributes. If the Entry has multiple Attributes of the same type (for example, if it's been created ready for a modify operation), then there is no guarantee as to which of the Attributes will be returned by this method.
        Parameters:
        attrType - the AttributeType required
        Returns:
        the specified Attribute
        Throws:
        NoSuchAttributeException - if the Entry doesn't contain an Attribute of type attrType.
      • rename

        public AddEntry rename​(DN new_dn)
        Do a rename operation on the entry, and return the result as a new AddEntry. A rename operation involves deleting the attribute value(s) corresponding to the current RDN and adding new attribute value(s) corresponding to the new RDN. The entry's DN is also changed.
        Parameters:
        new_dn - DN required for the returned AddEntry
        Returns:
        AddEntry result of rename operation
        Since:
        14.4
      • toString

        public java.lang.String toString()
        Returns a String representation of this Entry. The String contains the Entry's DN and a count of the number of attributes that the Entry contains.
        Overrides:
        toString in class GenericEntry
        Returns:
        a String representation of the Entry.