Package com.isode.dsapi
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
Entryobjects. 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
FieldsModifier and TypeFieldDescriptionList of attributes that belong to this Entryprotected longPointer to the underlying DS_Entry for native code.protected static final com.isode.util.Logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor used by native code to create an empty object.protectedGenericEntry(int type, DN dn) Constructor used by sub-classes to create a blank object. -
Method Summary
Modifier and TypeMethodDescriptionintCompare to another GenericEntry, ordering the entries by DN.protected voidfinalize()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.getDN()Returns the distinguished name of this EntrybooleanDetermine whether this entry contains any change-attributes (as would be returned by a call to getChangeIterator()).iterator()Returns an Iterator over whatever type of attributes that this entry stores.voidSet the distinguished name for the entrystatic voidsortArrayByDN(GenericEntry[] array) In-place sort of an array of GenericEntry instances into DN order.toLDIF()Returns a representation of this entry as an LDIF dump.toString()Returns a String representation of this entry.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
logger
protected static final com.isode.util.Logger logger -
DS_Entry
protected long DS_EntryPointer 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
List of attributes that belong to this Entry
-
-
Constructor Details
-
GenericEntry
protected GenericEntry()Constructor used by native code to create an empty object. -
GenericEntry
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
Releases any native structures associated with this object. -
setDN
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 libraryNullPointerException- if dn is null.
-
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
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
Returns an Iterator over whatever type of attributes that this entry stores. -
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
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
Compare to another GenericEntry, ordering the entries by DN.- Specified by:
compareToin interfaceComparable<GenericEntry>
-
sortArrayByDN
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
Returns a String representation of this 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 formatBadDNException- The DN could not be converted to LDIF formatNativeLibraryException- Internal unrecoverable error- Since:
- 15.0
-