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_MODS
Used 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 void
addAttribute(String id, Object... values)
Add an attribute to the entryvoid
addAttribute(Attribute attr)
Add an attribute to the entryvoid
addControl(Control... controls)
Add a control to the entryvoid
addModification(Modification modification)
Add a modification item (used by modify operations)void
addModification(ModificationOperation modOp, String id)
Add a modification with no valuevoid
addModification(ModificationOperation modOp, String id, Object value)
Add a modificationvoid
addModification(ModificationOperation modOp, Attribute attr)
Add a modification item (used by modify operations)LdifEntry
clone()
Clone methodboolean
equals(Object o)
Attribute
get(String attributeId)
Returns a attribute given it's idChangeType
getChangeType()
Get the change typeLdifControl
getControl(String oid)
Map<String,LdifControl>
getControls()
Dn
getDn()
Entry
getEntry()
Get the entry's entryint
getLengthBeforeParsing()
Returns the lengthBeforeParsing of the entry at the time of parsing.Modification[]
getModificationArray()
Gets the modification items as an array.List<Modification>
getModifications()
String
getNewRdn()
String
getNewSuperior()
long
getOffset()
boolean
hasControls()
int
hashCode()
boolean
isChangeAdd()
boolean
isChangeDelete()
boolean
isChangeModDn()
boolean
isChangeModify()
boolean
isChangeModRdn()
boolean
isDeleteOldRdn()
boolean
isEntry()
Tells if the current entry is a added oneboolean
isLdifChange()
boolean
isLdifContent()
Iterator<Attribute>
iterator()
Returns an enumeration containing the zero or more attributes in the collection.void
putAttribute(String id, Object value)
Add an attribute value to an existing attributevoid
readExternal(ObjectInput in)
void
removeAttribute(String... ids)
Remove a list of Attributes from the LdifEntryvoid
setChangeType(String changeType)
Set the change typevoid
setChangeType(ChangeType changeType)
Set the modification typevoid
setDeleteOldRdn(boolean deleteOldRdn)
Set the deleteOldRdn flagvoid
setDn(String dn)
Set the Distinguished Namevoid
setDn(Dn dn)
Set the Distinguished Namevoid
setNewRdn(String newRdn)
Set the new Rdnvoid
setNewSuperior(String newSuperior)
Set the new superiorint
size()
String
toString()
void
writeExternal(ObjectOutput out)
-
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(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
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
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
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.
-
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
-
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
-
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:
true
if 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- 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
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.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- Returns:
- the instance's hash code
- See Also:
Object.hashCode()
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in 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:
writeExternal
in interfaceExternalizable
- Parameters:
out
- The stream in which the ChangeLogEvent will be serialized.- Throws:
IOException
- If the serialization fail- See Also:
Externalizable.readExternal(ObjectInput)
-
-