Package org.ldaptive
Class LdapEntry
- java.lang.Object
-
- org.ldaptive.AbstractMessage
-
- org.ldaptive.LdapEntry
-
- All Implemented Interfaces:
Message
public class LdapEntry extends AbstractMessage
LDAP search result entry defined as:SearchResultEntry ::= [APPLICATION 4] SEQUENCE { objectName LDAPDN, attributes PartialAttributeList } PartialAttributeList ::= SEQUENCE OF partialAttribute PartialAttribute PartialAttribute ::= SEQUENCE { type AttributeDescription, vals SET OF value AttributeValue }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
LdapEntry.AttributeParser
Parses a buffer containing an attribute name and its values.protected static class
LdapEntry.AttributesHandler
Parse handler implementation for the attributes.static class
LdapEntry.Builder
protected static class
LdapEntry.LdapDnHandler
Parse handler implementation for the LDAP DN.-
Nested classes/interfaces inherited from class org.ldaptive.AbstractMessage
AbstractMessage.AbstractBuilder<B,T extends AbstractMessage>, AbstractMessage.ControlParser, AbstractMessage.ControlsHandler, AbstractMessage.MessageIDHandler
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,LdapAttribute>
attributes
LDAP attributes on the entry.private static DERPath
ATTRIBUTES_PATH
DER path to attributes.private static int
HASH_CODE_SEED
hash code seed.private static DERPath
LDAP_DN_PATH
DER path to LDAP DN.private String
ldapDn
LDAP DN of the entry.private String
normalizedDn
Normalized LDAP DN.private Dn
parsedDn
Parsed LDAP DN.static int
PROTOCOL_OP
BER protocol number.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributes(Collection<LdapAttribute> attrs)
Adds attributes to the entry.void
addAttributes(LdapAttribute... attrs)
Adds attributes to the entry.static LdapEntry.Builder
builder()
Creates a builder for this class.void
clear()
Removes all the attributes.static AttributeModification[]
computeModifications(LdapEntry source, LdapEntry target)
Returns the list of attribute modifications needed to change the supplied target entry into the supplied source entry.static AttributeModification[]
computeModifications(LdapEntry source, LdapEntry target, boolean useReplace)
Returns the list of attribute modifications needed to change the supplied target entry into the supplied source entry.boolean
equals(Object o)
LdapAttribute
getAttribute()
Returns a single attribute of this entry.LdapAttribute
getAttribute(String name)
Returns the attribute with the supplied name.String[]
getAttributeNames()
Returns the attribute names in this entry.Collection<LdapAttribute>
getAttributes()
Returns the ldap attributes.String
getDn()
Returns the ldap DN.String
getNormalizedDn()
Returns the normalized ldap DN.Dn
getParsedDn()
Returns the parsed ldap DN.int
hashCode()
Returns the hash code for this object.void
removeAttribute(String name)
Removes the attribute with the supplied name.void
removeAttributes(Collection<LdapAttribute> attrs)
Removes the attribute(s) from this ldap attributes.void
removeAttributes(LdapAttribute... attrs)
Removes an attribute from this ldap attributes.void
setDn(String dn)
Sets the ldap DN.int
size()
Returns the number of attributes.static LdapEntry
sort(LdapEntry le)
Returns a new entry whose attributes are sorted naturally by name without options.String
toString()
-
Methods inherited from class org.ldaptive.AbstractMessage
addControls, copyValues, getControls, getMessageID, setMessageID
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ldaptive.Message
getControl
-
-
-
-
Field Detail
-
PROTOCOL_OP
public static final int PROTOCOL_OP
BER protocol number.- See Also:
- Constant Field Values
-
HASH_CODE_SEED
private static final int HASH_CODE_SEED
hash code seed.- See Also:
- Constant Field Values
-
LDAP_DN_PATH
private static final DERPath LDAP_DN_PATH
DER path to LDAP DN.
-
ATTRIBUTES_PATH
private static final DERPath ATTRIBUTES_PATH
DER path to attributes.
-
ldapDn
private String ldapDn
LDAP DN of the entry.
-
parsedDn
private Dn parsedDn
Parsed LDAP DN.
-
normalizedDn
private String normalizedDn
Normalized LDAP DN.
-
attributes
private Map<String,LdapAttribute> attributes
LDAP attributes on the entry.
-
-
Constructor Detail
-
LdapEntry
public LdapEntry()
Default constructor.
-
LdapEntry
public LdapEntry(DERBuffer buffer)
Creates a new search result entry.- Parameters:
buffer
- to decode
-
-
Method Detail
-
getDn
public String getDn()
Returns the ldap DN.- Returns:
- ldap DN
-
getParsedDn
public Dn getParsedDn()
Returns the parsed ldap DN. Parsing is performed usingDefaultDnParser
.- Returns:
- parsed ldap DN or null if
ldapDn
is null or could not be parsed
-
getNormalizedDn
public String getNormalizedDn()
Returns the normalized ldap DN. Normalization is performed usingDefaultRDnNormalizer
.- Returns:
- normalized ldap DN or null if
ldapDn
is null or could not be parsed
-
setDn
public void setDn(String dn)
Sets the ldap DN.- Parameters:
dn
- ldap DN
-
getAttributes
public Collection<LdapAttribute> getAttributes()
Returns the ldap attributes.- Returns:
- ldap attributes
-
getAttribute
public LdapAttribute getAttribute()
Returns a single attribute of this entry. If multiple attributes exist the first attribute returned by the underlying iterator is used. If no attributes exist null is returned.- Returns:
- single attribute
-
getAttribute
public LdapAttribute getAttribute(String name)
Returns the attribute with the supplied name.- Parameters:
name
- of the attribute to return- Returns:
- ldap attribute
-
getAttributeNames
public String[] getAttributeNames()
Returns the attribute names in this entry.- Returns:
- string array of attribute names
-
addAttributes
public void addAttributes(LdapAttribute... attrs)
Adds attributes to the entry.- Parameters:
attrs
- attributes to add
-
addAttributes
public void addAttributes(Collection<LdapAttribute> attrs)
Adds attributes to the entry.- Parameters:
attrs
- attributes to add
-
removeAttribute
public void removeAttribute(String name)
Removes the attribute with the supplied name.- Parameters:
name
- of attribute to remove
-
removeAttributes
public void removeAttributes(LdapAttribute... attrs)
Removes an attribute from this ldap attributes.- Parameters:
attrs
- attribute to remove
-
removeAttributes
public void removeAttributes(Collection<LdapAttribute> attrs)
Removes the attribute(s) from this ldap attributes.- Parameters:
attrs
- collection of ldap attributes to remove
-
size
public int size()
Returns the number of attributes.- Returns:
- number of attributes
-
clear
public void clear()
Removes all the attributes.
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classAbstractMessage
-
hashCode
public int hashCode()
Description copied from class:AbstractMessage
Returns the hash code for this object.- Specified by:
hashCode
in classAbstractMessage
- Returns:
- hash code
-
toString
public String toString()
- Overrides:
toString
in classAbstractMessage
-
sort
public static LdapEntry sort(LdapEntry le)
Returns a new entry whose attributes are sorted naturally by name without options.- Parameters:
le
- entry to sort- Returns:
- sorted entry
-
computeModifications
public static AttributeModification[] computeModifications(LdapEntry source, LdapEntry target)
Returns the list of attribute modifications needed to change the supplied target entry into the supplied source entry. SeecomputeModifications(LdapEntry, LdapEntry, boolean)
.- Parameters:
source
- ldap entry containing new datatarget
- ldap entry containing existing data- Returns:
- attribute modifications needed to change target into source or an empty array
-
computeModifications
public static AttributeModification[] computeModifications(LdapEntry source, LdapEntry target, boolean useReplace)
Returns the list of attribute modifications needed to change the supplied target entry into the supplied source entry. This implementation performs a byte comparison on the attribute values to determine changes.- Parameters:
source
- ldap entry containing new datatarget
- ldap entry containing existing datauseReplace
- whether to use a single REPLACE modification or individual ADD/DELETE for attribute values- Returns:
- attribute modifications needed to change target into source or an empty array
-
builder
public static LdapEntry.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-