Package com.unboundid.ldap.sdk
Class CompactEntry
- java.lang.Object
-
- com.unboundid.ldap.sdk.CompactEntry
-
- All Implemented Interfaces:
java.io.Serializable
@NotMutable @ThreadSafety(level=NOT_THREADSAFE) public final class CompactEntry extends java.lang.Object implements java.io.Serializable
This class provides a data structure that represents a compact version of an entry. This is basically the same as anEntry
object, except that it stores the information in a more compact form that requires less space in memory. This may be useful in applications that need to hold a large number of entries in memory. Note that performance of some methods in this class may be significantly worse than the performance of the corresponding methods in theEntry
class.- See Also:
Entry
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CompactEntry(Entry entry)
Creates a new compact entry from the provided entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
Indicates whether the provided object is equal to this entry.Attribute
getAttribute(java.lang.String attributeName)
Retrieves the attribute with the specified name.java.util.Collection<Attribute>
getAttributes()
Retrieves the set of attributes contained in this entry.java.util.List<Attribute>
getAttributesWithOptions(java.lang.String baseName, java.util.Set<java.lang.String> options)
Retrieves the list of attributes with the given base name and all of the specified options.java.lang.String
getAttributeValue(java.lang.String attributeName)
Retrieves the value for the specified attribute, if available.java.lang.Boolean
getAttributeValueAsBoolean(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Boolean, if available.java.util.Date
getAttributeValueAsDate(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Date, formatted using the generalized time syntax, if available.DN
getAttributeValueAsDN(java.lang.String attributeName)
Retrieves the value for the specified attribute as a DN, if available.java.lang.Integer
getAttributeValueAsInteger(java.lang.String attributeName)
Retrieves the value for the specified attribute as an Integer, if available.java.lang.Long
getAttributeValueAsLong(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Long, if available.byte[][]
getAttributeValueByteArrays(java.lang.String attributeName)
Retrieves the set of values for the specified attribute as byte arrays, if available.byte[]
getAttributeValueBytes(java.lang.String attributeName)
Retrieves the value for the specified attribute as a byte array, if available.java.lang.String[]
getAttributeValues(java.lang.String attributeName)
Retrieves the set of values for the specified attribute, if available.java.lang.String
getDN()
Retrieves the DN for this entry.Attribute
getObjectClassAttribute()
Retrieves the "objectClass" attribute from the entry, if available.java.lang.String[]
getObjectClassValues()
Retrieves the values of the "objectClass" attribute from the entry, if available.DN
getParentDN()
Retrieves the parent DN for this entry.java.lang.String
getParentDNString()
Retrieves the parent DN for this entry as a string.DN
getParsedDN()
Retrieves the parsed DN for this entry.RDN
getRDN()
Retrieves the RDN for this entry.boolean
hasAttribute(Attribute attribute)
Indicates whether this entry contains the specified attribute.boolean
hasAttribute(java.lang.String attributeName)
Indicates whether this entry contains the specified attribute.boolean
hasAttributeValue(java.lang.String attributeName, byte[] attributeValue)
Indicates whether this entry contains an attribute with the given name and value.boolean
hasAttributeValue(java.lang.String attributeName, java.lang.String attributeValue)
Indicates whether this entry contains an attribute with the given name and value.int
hashCode()
Generates a hash code for this entry.boolean
hasObjectClass(java.lang.String objectClassName)
Indicates whether this entry contains the specified object class.Entry
toEntry()
Converts this compact entry to a full entry.java.lang.String[]
toLDIF()
Retrieves an LDIF representation of this entry, with each attribute value on a separate line.java.lang.String[]
toLDIF(int wrapColumn)
Retrieves an LDIF representation of this entry, with each attribute value on a separate line.void
toLDIF(ByteStringBuffer buffer)
Appends an LDIF representation of this entry to the provided buffer.void
toLDIF(ByteStringBuffer buffer, int wrapColumn)
Appends an LDIF representation of this entry to the provided buffer.java.lang.String
toLDIFString()
Retrieves an LDIF-formatted string representation of this entry.java.lang.String
toLDIFString(int wrapColumn)
Retrieves an LDIF-formatted string representation of this entry.void
toLDIFString(java.lang.StringBuilder buffer)
Appends an LDIF-formatted string representation of this entry to the provided buffer.void
toLDIFString(java.lang.StringBuilder buffer, int wrapColumn)
Appends an LDIF-formatted string representation of this entry to the provided buffer.java.lang.String
toString()
Retrieves a string representation of this entry.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this entry to the provided buffer.
-
-
-
Constructor Detail
-
CompactEntry
public CompactEntry(Entry entry)
Creates a new compact entry from the provided entry.- Parameters:
entry
- The entry to use to create this compact entry. It must not benull
.
-
-
Method Detail
-
getDN
public java.lang.String getDN()
Retrieves the DN for this entry.- Returns:
- The DN for this entry.
-
getParsedDN
public DN getParsedDN() throws LDAPException
Retrieves the parsed DN for this entry.- Returns:
- The parsed DN for this entry.
- Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getRDN
public RDN getRDN() throws LDAPException
Retrieves the RDN for this entry.- Returns:
- The RDN for this entry, or
null
if the DN is the null DN. - Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getParentDN
public DN getParentDN() throws LDAPException
Retrieves the parent DN for this entry.- Returns:
- The parent DN for this entry, or
null
if there is no parent. - Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
getParentDNString
public java.lang.String getParentDNString() throws LDAPException
Retrieves the parent DN for this entry as a string.- Returns:
- The parent DN for this entry as a string, or
null
if there is no parent. - Throws:
LDAPException
- If the DN string cannot be parsed as a valid DN.
-
hasAttribute
public boolean hasAttribute(java.lang.String attributeName)
Indicates whether this entry contains the specified attribute.- Parameters:
attributeName
- The name of the attribute for which to make the determination. It must not benull
.- Returns:
true
if this entry contains the specified attribute, orfalse
if not.
-
hasAttribute
public boolean hasAttribute(Attribute attribute)
Indicates whether this entry contains the specified attribute. It will only returntrue
if this entry contains an attribute with the same name and exact set of values.- Parameters:
attribute
- The attribute for which to make the determination. It must not benull
.- Returns:
true
if this entry contains the specified attribute, orfalse
.
-
hasAttributeValue
public boolean hasAttributeValue(java.lang.String attributeName, java.lang.String attributeValue)
Indicates whether this entry contains an attribute with the given name and value.- Parameters:
attributeName
- The name of the attribute for which to make the determination. It must not benull
.attributeValue
- The value for which to make the determination. It must not benull
.- Returns:
true
if this entry contains an attribute with the specified name and value, orfalse
if not.
-
hasAttributeValue
public boolean hasAttributeValue(java.lang.String attributeName, byte[] attributeValue)
Indicates whether this entry contains an attribute with the given name and value.- Parameters:
attributeName
- The name of the attribute for which to make the determination. It must not benull
.attributeValue
- The value for which to make the determination. It must not benull
.- Returns:
true
if this entry contains an attribute with the specified name and value, orfalse
if not.
-
hasObjectClass
public boolean hasObjectClass(java.lang.String objectClassName)
Indicates whether this entry contains the specified object class.- Parameters:
objectClassName
- The name of the object class for which to make the determination. It must not benull
.- Returns:
true
if this entry contains the specified object class, orfalse
if not.
-
getAttributes
public java.util.Collection<Attribute> getAttributes()
Retrieves the set of attributes contained in this entry.- Returns:
- The set of attributes contained in this entry.
-
getAttribute
public Attribute getAttribute(java.lang.String attributeName)
Retrieves the attribute with the specified name.- Parameters:
attributeName
- The name of the attribute to retrieve. It must not benull
.- Returns:
- The requested attribute from this entry, or
null
if the specified attribute is not present in this entry.
-
getAttributesWithOptions
public java.util.List<Attribute> getAttributesWithOptions(java.lang.String baseName, java.util.Set<java.lang.String> options)
Retrieves the list of attributes with the given base name and all of the specified options.- Parameters:
baseName
- The base name (without any options) for the attribute to retrieve. It must not benull
.options
- The set of options that should be included in the attributes that are returned. It may be empty ornull
if all attributes with the specified base name should be returned, regardless of the options that they contain (if any).- Returns:
- The list of attributes with the given base name and all of the specified options. It may be empty if there are no attributes with the specified base name and set of options.
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String attributeName)
Retrieves the value for the specified attribute, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The value for the specified attribute, or
null
if that attribute is not available.
-
getAttributeValueBytes
public byte[] getAttributeValueBytes(java.lang.String attributeName)
Retrieves the value for the specified attribute as a byte array, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The value for the specified attribute as a byte array, or
null
if that attribute is not available.
-
getAttributeValueAsBoolean
public java.lang.Boolean getAttributeValueAsBoolean(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Boolean, if available. If the attribute has more than one value, then the first value will be returned. Values of "true", "t", "yes", "y", "on", and "1" will be interpreted asTRUE
. Values of "false", "f", "no", "n", "off", and "0" will be interpreted asFALSE
.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The Boolean value parsed from the specified attribute, or
null
if that attribute is not available or the value cannot be parsed as a Boolean.
-
getAttributeValueAsDate
public java.util.Date getAttributeValueAsDate(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Date, formatted using the generalized time syntax, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The Date value parsed from the specified attribute, or
null
if that attribute is not available or the value cannot be parsed as a Date.
-
getAttributeValueAsDN
public DN getAttributeValueAsDN(java.lang.String attributeName)
Retrieves the value for the specified attribute as a DN, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The Date value parsed from the specified attribute, or
null
if that attribute is not available or the value cannot be parsed as a DN.
-
getAttributeValueAsInteger
public java.lang.Integer getAttributeValueAsInteger(java.lang.String attributeName)
Retrieves the value for the specified attribute as an Integer, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The Integer value parsed from the specified attribute, or
null
if that attribute is not available or the value cannot be parsed as an Integer.
-
getAttributeValueAsLong
public java.lang.Long getAttributeValueAsLong(java.lang.String attributeName)
Retrieves the value for the specified attribute as a Long, if available. If the attribute has more than one value, then the first value will be returned.- Parameters:
attributeName
- The name of the attribute for which to retrieve the value. It must not benull
.- Returns:
- The Long value parsed from the specified attribute, or
null
if that attribute is not available or the value cannot be parsed as a Long.
-
getAttributeValues
public java.lang.String[] getAttributeValues(java.lang.String attributeName)
Retrieves the set of values for the specified attribute, if available.- Parameters:
attributeName
- The name of the attribute for which to retrieve the values. It must not benull
.- Returns:
- The set of values for the specified attribute, or
null
if that attribute is not available.
-
getAttributeValueByteArrays
public byte[][] getAttributeValueByteArrays(java.lang.String attributeName)
Retrieves the set of values for the specified attribute as byte arrays, if available.- Parameters:
attributeName
- The name of the attribute for which to retrieve the values. It must not benull
.- Returns:
- The set of values for the specified attribute as byte arrays, or
null
if that attribute is not available.
-
getObjectClassAttribute
public Attribute getObjectClassAttribute()
Retrieves the "objectClass" attribute from the entry, if available.- Returns:
- The "objectClass" attribute from the entry, or
null
if that attribute not available.
-
getObjectClassValues
public java.lang.String[] getObjectClassValues()
Retrieves the values of the "objectClass" attribute from the entry, if available.- Returns:
- The values of the "objectClass" attribute from the entry, or
null
if that attribute is not available.
-
toEntry
public Entry toEntry()
Converts this compact entry to a full entry.- Returns:
- The entry created from this compact entry.
-
hashCode
public int hashCode()
Generates a hash code for this entry.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The generated hash code for this entry.
-
equals
public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this entry. The provided object will only be considered equal to this entry if it is an entry with the same DN and set of attributes.- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The object for which to make the determination.- Returns:
true
if the provided object is considered equal to this entry, orfalse
if not.
-
toLDIF
public java.lang.String[] toLDIF()
Retrieves an LDIF representation of this entry, with each attribute value on a separate line. Long lines will not be wrapped.- Returns:
- An LDIF representation of this entry.
-
toLDIF
public java.lang.String[] toLDIF(int wrapColumn)
Retrieves an LDIF representation of this entry, with each attribute value on a separate line. Long lines will be wrapped at the specified column.- Parameters:
wrapColumn
- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.- Returns:
- An LDIF representation of this entry.
-
toLDIF
public void toLDIF(ByteStringBuffer buffer)
Appends an LDIF representation of this entry to the provided buffer. Long lines will not be wrapped.- Parameters:
buffer
- The buffer to which the LDIF representation of this entry should be written.
-
toLDIF
public void toLDIF(ByteStringBuffer buffer, int wrapColumn)
Appends an LDIF representation of this entry to the provided buffer.- Parameters:
buffer
- The buffer to which the LDIF representation of this entry should be written.wrapColumn
- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.
-
toLDIFString
public java.lang.String toLDIFString()
Retrieves an LDIF-formatted string representation of this entry. No wrapping will be performed, and no extra blank lines will be added.- Returns:
- An LDIF-formatted string representation of this entry.
-
toLDIFString
public java.lang.String toLDIFString(int wrapColumn)
Retrieves an LDIF-formatted string representation of this entry. No extra blank lines will be added.- Parameters:
wrapColumn
- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.- Returns:
- An LDIF-formatted string representation of this entry.
-
toLDIFString
public void toLDIFString(java.lang.StringBuilder buffer)
Appends an LDIF-formatted string representation of this entry to the provided buffer. No wrapping will be performed, and no extra blank lines will be added.- Parameters:
buffer
- The buffer to which to append the LDIF representation of this entry.
-
toLDIFString
public void toLDIFString(java.lang.StringBuilder buffer, int wrapColumn)
Appends an LDIF-formatted string representation of this entry to the provided buffer. No extra blank lines will be added.- Parameters:
buffer
- The buffer to which to append the LDIF representation of this entry.wrapColumn
- The column at which long lines should be wrapped. A value less than or equal to two indicates that no wrapping should be performed.
-
toString
public java.lang.String toString()
Retrieves a string representation of this entry.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this entry.
-
toString
public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this entry to the provided buffer.- Parameters:
buffer
- The buffer to which to append the string representation of this entry.
-
-