Class LdifEntry
java.lang.Object
org.apache.directory.api.ldap.model.ldif.LdifEntry
- All Implemented Interfaces:
Externalizable, Serializable, Cloneable, 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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new LdifEntry object.Creates a LdifEntry using a list of strings representing the Ldif elementCreates a new LdifEntry object, storing an EntryCreates a LdifEntry using a list of strings representing the Ldif elementLdifEntry(SchemaManager schemaManager) Creates a new schema aware LdifEntry object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(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)clone()Clone methodbooleanReturns a attribute given it's idGet the change typegetControl(String oid) getDn()getEntry()Get the entry's entryintReturns the lengthBeforeParsing of the entry at the time of parsing.Gets the modification items as an array.longbooleaninthashCode()booleanbooleanbooleanbooleanbooleanbooleanbooleanisEntry()Tells if the current entry is a added onebooleanbooleaniterator()Returns an enumeration containing the zero or more attributes in the collection.voidputAttribute(String id, Object value) Add an attribute value to an existing attributevoidvoidremoveAttribute(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 flagvoidSet the Distinguished NamevoidSet the Distinguished NamevoidSet the new RdnvoidsetNewSuperior(String newSuperior) Set the new superiorintsize()toString()voidMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
EMPTY_MODS
Used in toArray()
-
-
Constructor Details
-
LdifEntry
public LdifEntry()Creates a new LdifEntry object. -
LdifEntry
Creates a new schema aware LdifEntry object.- Parameters:
schemaManager- The SchemaManager
-
LdifEntry
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 Details
-
setDn
-
setDn
Set the Distinguished Name- Parameters:
dn- The Distinguished Name- Throws:
LdapInvalidDnException- If the Dn is invalid
-
setChangeType
Set the modification type- Parameters:
changeType- The change type
-
setChangeType
Set the change type- Parameters:
changeType- The change type
-
addModification
Add a modification item (used by modify operations)- Parameters:
modification- The modification to be added
-
addModification
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
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
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
Add an attribute to the entry- Parameters:
attr- The attribute to be added- Throws:
LdapException- if something went wrong
-
addAttribute
Add an attribute to the entry- Parameters:
id- The attribute IDvalues- The attribute values- Throws:
LdapException- if something went wrong
-
removeAttribute
Remove a list of Attributes from the LdifEntry- Parameters:
ids- The Attributes to remove
-
putAttribute
Add an attribute value to an existing attribute- Parameters:
id- The attribute IDvalue- The attribute value- Throws:
LdapException- if something went wrong
-
getChangeType
Get the change type- Returns:
- The change type. One of :
- ADD
- MODIFY
- MODDN
- MODRDN
- DELETE
- NONE
-
getModifications
- Returns:
- The list of modification items
-
getModificationArray
Gets the modification items as an array.- Returns:
- modification items as an array.
-
getDn
- Returns:
- The entry Distinguished name
-
size
public int size()- Returns:
- The number of entry modifications
-
get
-
getEntry
-
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
- Returns:
- The new Rdn
-
setNewRdn
-
getNewSuperior
- Returns:
- The new superior
-
setNewSuperior
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
- Returns:
- The set of controls for this entry
-
getControl
- Parameters:
oid- The control's OID- Returns:
- The associated control, if any
-
addControl
Add a control to the entry- Parameters:
controls- The added controls
-
clone
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
-
getOffset
public long getOffset()- Returns:
- the offset
-
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
-
hashCode
-
equals
-
readExternal
- 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:
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Parameters:
out- The stream in which the ChangeLogEvent will be serialized.- Throws:
IOException- If the serialization fail- See Also:
-