Class LdifEntry
- java.lang.Object
-
- org.apache.directory.api.ldap.model.ldif.LdifEntry
-
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,Iterable<Attribute>
public class LdifEntry extends Object implements Cloneable, Externalizable, Iterable<Attribute>
A entry to be populated by an ldif parser. We will have different kind of entries :- added entries
- deleted entries
- modified entries
- Rdn modified entries
- Dn modified entries
- Author:
- Apache Directory Project
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Modification[]EMPTY_MODSUsed in toArray()
-
Constructor Summary
Constructors Constructor Description LdifEntry()Creates a new LdifEntry object.LdifEntry(String dn, Object... strings)Creates a LdifEntry using a list of strings representing the Ldif elementLdifEntry(Entry entry)Creates a new LdifEntry object, storing an EntryLdifEntry(Dn dn, Object... avas)Creates a LdifEntry using a list of strings representing the Ldif elementLdifEntry(SchemaManager schemaManager)Creates a new schema aware LdifEntry object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String id, Object... values)Add an attribute to the entryvoidaddAttribute(Attribute attr)Add an attribute to the entryvoidaddControl(Control... controls)Add a control to the entryvoidaddModification(Modification modification)Add a modification item (used by modify operations)voidaddModification(ModificationOperation modOp, String id)Add a modification with no valuevoidaddModification(ModificationOperation modOp, String id, Object value)Add a modificationvoidaddModification(ModificationOperation modOp, Attribute attr)Add a modification item (used by modify operations)LdifEntryclone()Clone methodbooleanequals(Object o)Attributeget(String attributeId)Returns a attribute given it's idChangeTypegetChangeType()Get the change typeLdifControlgetControl(String oid)Map<String,LdifControl>getControls()DngetDn()EntrygetEntry()Get the entry's entryintgetLengthBeforeParsing()Returns the lengthBeforeParsing of the entry at the time of parsing.Modification[]getModificationArray()Gets the modification items as an array.List<Modification>getModifications()StringgetNewRdn()StringgetNewSuperior()longgetOffset()booleanhasControls()inthashCode()booleanisChangeAdd()booleanisChangeDelete()booleanisChangeModDn()booleanisChangeModify()booleanisChangeModRdn()booleanisDeleteOldRdn()booleanisEntry()Tells if the current entry is a added onebooleanisLdifChange()booleanisLdifContent()Iterator<Attribute>iterator()Returns an enumeration containing the zero or more attributes in the collection.voidputAttribute(String id, Object value)Add an attribute value to an existing attributevoidreadExternal(ObjectInput in)voidremoveAttribute(String... ids)Remove a list of Attributes from the LdifEntryvoidsetChangeType(String changeType)Set the change typevoidsetChangeType(ChangeType changeType)Set the modification typevoidsetDeleteOldRdn(boolean deleteOldRdn)Set the deleteOldRdn flagvoidsetDn(String dn)Set the Distinguished NamevoidsetDn(Dn dn)Set the Distinguished Name(package private) voidsetLengthBeforeParsing(int length)voidsetNewRdn(String newRdn)Set the new RdnvoidsetNewSuperior(String newSuperior)Set the new superior(package private) voidsetOffset(long offset)intsize()StringtoString()voidwriteExternal(ObjectOutput out)-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
EMPTY_MODS
public static final Modification[] EMPTY_MODS
Used in toArray()
-
-
Constructor Detail
-
LdifEntry
public LdifEntry()
Creates a new LdifEntry object.
-
LdifEntry
public LdifEntry(SchemaManager schemaManager)
Creates a new schema aware LdifEntry object.- Parameters:
schemaManager- The SchemaManager
-
LdifEntry
public LdifEntry(Entry entry)
Creates a new LdifEntry object, storing an Entry- Parameters:
entry- The entry to encapsulate
-
LdifEntry
public LdifEntry(Dn dn, Object... avas) throws LdapInvalidAttributeValueException, LdapLdifException
Creates a LdifEntry using a list of strings representing the Ldif element- Parameters:
dn- The LdifEntry DNavas- The Ldif to convert to an LdifEntry- Throws:
LdapInvalidAttributeValueException- If either the AttributeType or the associated value is incorrectLdapLdifException- If we get any other exception
-
LdifEntry
public LdifEntry(String dn, Object... strings) throws LdapInvalidAttributeValueException, LdapLdifException, LdapInvalidDnException
Creates a LdifEntry using a list of strings representing the Ldif element- Parameters:
dn- The LdifEntry DNstrings- The Ldif attributes and values to convert to an LdifEntry- Throws:
LdapInvalidDnException- If the Dn is invalidLdapInvalidAttributeValueException- If either the AttributeType or the associated value is incorrectLdapLdifException- If we get any other exception
-
-
Method Detail
-
setDn
public void setDn(Dn dn)
Set the Distinguished Name- Parameters:
dn- The Distinguished Name
-
setDn
public void setDn(String dn) throws LdapInvalidDnException
Set the Distinguished Name- Parameters:
dn- The Distinguished Name- Throws:
LdapInvalidDnException- If the Dn is invalid
-
setChangeType
public void setChangeType(ChangeType changeType)
Set the modification type- Parameters:
changeType- The change type
-
setChangeType
public void setChangeType(String changeType)
Set the change type- Parameters:
changeType- The change type
-
addModification
public void addModification(Modification modification)
Add a modification item (used by modify operations)- Parameters:
modification- The modification to be added
-
addModification
public void addModification(ModificationOperation modOp, Attribute attr)
Add a modification item (used by modify operations)- Parameters:
modOp- The operation. One of :- ModificationOperation.ADD_ATTRIBUTE
- ModificationOperation.REMOVE_ATTRIBUTE
- ModificationOperation.REPLACE_ATTRIBUTE
- ModificationOperation.INCREMENT_ATTRIBUTE
attr- The attribute to be added
-
addModification
public void addModification(ModificationOperation modOp, String id)
Add a modification with no value- Parameters:
modOp- The modification operation value. One of :- ModificationOperation.ADD_ATTRIBUTE
- ModificationOperation.REMOVE_ATTRIBUTE
- ModificationOperation.REPLACE_ATTRIBUTE
- ModificationOperation.INCREMENT_ATTRIBUTE
id- The attribute's ID
-
addModification
public void addModification(ModificationOperation modOp, String id, Object value)
Add a modification- Parameters:
modOp- The modification operation value. One of :- ModificationOperation.ADD_ATTRIBUTE
- ModificationOperation.REMOVE_ATTRIBUTE
- ModificationOperation.REPLACE_ATTRIBUTE
- ModificationOperation.INCREMENT_ATTRIBUTE
id- The attribute's IDvalue- The attribute's value
-
addAttribute
public void addAttribute(Attribute attr) throws LdapException
Add an attribute to the entry- Parameters:
attr- The attribute to be added- Throws:
LdapException- if something went wrong
-
addAttribute
public void addAttribute(String id, Object... values) throws LdapException
Add an attribute to the entry- Parameters:
id- The attribute IDvalues- The attribute values- Throws:
LdapException- if something went wrong
-
removeAttribute
public void removeAttribute(String... ids)
Remove a list of Attributes from the LdifEntry- Parameters:
ids- The Attributes to remove
-
putAttribute
public void putAttribute(String id, Object value) throws LdapException
Add an attribute value to an existing attribute- Parameters:
id- The attribute IDvalue- The attribute value- Throws:
LdapException- if something went wrong
-
getChangeType
public ChangeType getChangeType()
Get the change type- Returns:
- The change type. One of :
- ADD
- MODIFY
- MODDN
- MODRDN
- DELETE
- NONE
-
getModifications
public List<Modification> getModifications()
- Returns:
- The list of modification items
-
getModificationArray
public Modification[] getModificationArray()
Gets the modification items as an array.- Returns:
- modification items as an array.
-
getDn
public Dn getDn()
- Returns:
- The entry Distinguished name
-
size
public int size()
- Returns:
- The number of entry modifications
-
get
public Attribute get(String attributeId)
Returns a attribute given it's id- Parameters:
attributeId- The attribute Id- Returns:
- The attribute if it exists
-
getEntry
public Entry getEntry()
Get the entry's entry- Returns:
- the stored Entry
-
isDeleteOldRdn
public boolean isDeleteOldRdn()
- Returns:
- True, if the old Rdn should be deleted.
-
setDeleteOldRdn
public void setDeleteOldRdn(boolean deleteOldRdn)
Set the deleteOldRdn flag- Parameters:
deleteOldRdn- True if the old Rdn should be deleted
-
getNewRdn
public String getNewRdn()
- Returns:
- The new Rdn
-
setNewRdn
public void setNewRdn(String newRdn)
Set the new Rdn- Parameters:
newRdn- The new Rdn
-
getNewSuperior
public String getNewSuperior()
- Returns:
- The new superior
-
setNewSuperior
public void setNewSuperior(String newSuperior)
Set the new superior- Parameters:
newSuperior- The new Superior
-
isLdifContent
public boolean isLdifContent()
- Returns:
- True if this is a content ldif
-
isLdifChange
public boolean isLdifChange()
- Returns:
- True if there is this is a change ldif
-
isChangeAdd
public boolean isChangeAdd()
- Returns:
- True if the entry is an ADD entry
-
isChangeDelete
public boolean isChangeDelete()
- Returns:
- True if the entry is a DELETE entry
-
isChangeModDn
public boolean isChangeModDn()
- Returns:
- True if the entry is a MODDN entry
-
isChangeModRdn
public boolean isChangeModRdn()
- Returns:
- True if the entry is a MODRDN entry
-
isChangeModify
public boolean isChangeModify()
- Returns:
- True if the entry is a MODIFY entry
-
isEntry
public boolean isEntry()
Tells if the current entry is a added one- Returns:
trueif the entry is added
-
hasControls
public boolean hasControls()
- Returns:
- true if the entry has some controls
-
getControls
public Map<String,LdifControl> getControls()
- Returns:
- The set of controls for this entry
-
getControl
public LdifControl getControl(String oid)
- Parameters:
oid- The control's OID- Returns:
- The associated control, if any
-
addControl
public void addControl(Control... controls)
Add a control to the entry- Parameters:
controls- The added controls
-
clone
public LdifEntry clone() throws CloneNotSupportedException
Clone method- Overrides:
clonein classObject- Returns:
- a clone of the current instance
- Throws:
CloneNotSupportedException- If there is some problem while cloning the instance
-
getLengthBeforeParsing
public int getLengthBeforeParsing()
Returns the lengthBeforeParsing of the entry at the time of parsing. This includes the lengthBeforeParsing of the comments present in entry at the time of parsing so this lengthBeforeParsing may not always match with the lengthBeforeParsing of the entry data present in memory.- Returns:
- The entry length, comments included
-
setLengthBeforeParsing
void setLengthBeforeParsing(int length)
- Parameters:
length- the lengthBeforeParsing to set
-
getOffset
public long getOffset()
- Returns:
- the offset
-
setOffset
void setOffset(long offset)
- Parameters:
offset- the offset to set
-
iterator
public Iterator<Attribute> iterator()
Returns an enumeration containing the zero or more attributes in the collection. The behavior of the enumeration is not specified if the attribute collection is changed.
-
toString
public String toString()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classObject- Returns:
- the instance's hash code
- See Also:
Object.hashCode()
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Parameters:
in- The stream from which the LdifEntry is read- Throws:
IOException- If the stream can't be readClassNotFoundException- If the LdifEntry can't be created- See Also:
Externalizable.readExternal(ObjectInput)
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out- The stream in which the ChangeLogEvent will be serialized.- Throws:
IOException- If the serialization fail- See Also:
Externalizable.readExternal(ObjectInput)
-
-