Package com.isode.dsapi
Class ChangeEntry
- java.lang.Object
-
- com.isode.dsapi.GenericEntry
-
- com.isode.dsapi.ChangeEntry
-
- All Implemented Interfaces:
java.lang.Comparable<GenericEntry>
,java.lang.Iterable<Attribute>
- Direct Known Subclasses:
AddEntry
,DeleteEntry
,ModifyEntry
,RenameEntry
public abstract class ChangeEntry extends GenericEntry
An abstract class which acts to group the four different types of change-entries found on an LDIF file: ModifyEntry, AddEntry, DeleteEntry and RenameEntry. Each of these represents an operation that can be performed on a directory.- Author:
- jp
-
-
Field Summary
-
Fields inherited from class com.isode.dsapi.GenericEntry
attributeList, DS_Entry, logger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ChangeEntry()
Constructor used by the native library to create a blank object.protected
ChangeEntry(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 void
addAttribute(Attribute attr)
Add an 'add attribute-values' change to an AddEntry or ModifyEntry.void
append(Attribute attr)
Appends an existing change-attribute to the ChangeEntry.void
deleteAttribute(Attribute attr)
Add a 'delete attribute-values' change to a ModifyEntry.static ChangeEntry
diff(Entry entry1, Entry entry2)
Calculate the difference between two possibly-null Entry references, giving as a result an AddEntry, ModifyEntry or DeleteEntry instance.protected void
jni_diff(int type, Entry entry1, Entry entry2)
Calculate differences and save in the current ModifyEntry or AddEntry.void
replaceAttribute(Attribute attr)
Add a 'replace attribute-values' change to a ModifyEntry.java.lang.String
toString()
Returns a String representation of this entry.-
Methods inherited from class com.isode.dsapi.GenericEntry
compareTo, finalize, getAttributeIterator, getChangeIterator, getDN, hasChanges, iterator, setDN, sortArrayByDN, toLDIF
-
-
-
-
Constructor Detail
-
ChangeEntry
protected ChangeEntry()
Constructor used by the native library to create a blank object.
-
ChangeEntry
protected ChangeEntry(int type, DN dn)
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, or null
-
-
Method Detail
-
diff
public static ChangeEntry diff(Entry entry1, Entry entry2)
Calculate the difference between two possibly-null Entry references, giving as a result an AddEntry, ModifyEntry or DeleteEntry instance. If 'entry1' is null, an AddEntry results; if 'entry2' is null, a DeleteEntry results; otherwise a ModifyEntry results.Note that any Attributes inside entry1 or entry2 which contain no values are treated as if they were not present at all.
- Parameters:
entry1
- initial entry, or null for 'absent'entry2
- target entry, or null for 'absent'- Returns:
- Either an AddEntry, DeleteEntry or ModifyEntry
-
addAttribute
public void addAttribute(Attribute attr) throws BadValueException, java.lang.NullPointerException, NativeLibraryException
Add an 'add attribute-values' change to an AddEntry or ModifyEntry.- Parameters:
attr
- Attribute containing values to be added.- Throws:
BadValueException
- if attr contains no values.java.lang.NullPointerException
- if attr is null.NativeLibraryException
- if an unrecoverable error was detected by the native library
-
replaceAttribute
public void replaceAttribute(Attribute attr) throws NativeLibraryException
Add a 'replace attribute-values' change to a ModifyEntry.- Parameters:
attr
- Attribute containing values to replace current values when change is applied.- Throws:
java.lang.NullPointerException
- if attr is null.NativeLibraryException
- if an unrecoverable error was detected by the native library
-
deleteAttribute
public void deleteAttribute(Attribute attr) throws NativeLibraryException
Add a 'delete attribute-values' change to a ModifyEntry.- Parameters:
attr
- Attribute containing values to delete when change is applied, or containing no values to delete all.- Throws:
java.lang.NullPointerException
- if attr is null.NativeLibraryException
- if an unrecoverable error was detected by the native library
-
append
public void append(Attribute attr) throws NativeLibraryException, BadValueException
Appends an existing change-attribute to the ChangeEntry. The attribute must be an instance of AddAttribute, ReplaceAttribute or DeleteAttribute -- for example, as returned from the ChangeEntry iterator. This is intended to allow a ChangeEntry to be built up from selected changes from another ChangeEntry.- Parameters:
attr
- AddAttribute, ReplaceAttribute or DeleteAttribute- Throws:
BadValueException
- if attr is an AddAttribute which contains no values.java.lang.NullPointerException
- if attr is null.NativeLibraryException
- if an unrecoverable error was detected by the native library- Since:
- R15.0
-
jni_diff
protected void jni_diff(int type, Entry entry1, Entry entry2)
Calculate differences and save in the current ModifyEntry or AddEntry. 'entry1' or 'entry2' may be null to compare to/from an empty Entry. 'type' is 'M' to generate a modify-entry, or 'A' to generate an add-entry.
-
toString
public java.lang.String toString()
Returns a String representation of this entry.- Overrides:
toString
in classGenericEntry
- Returns:
- a String representation of the entry.
-
-