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 anEntryobject, 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 theEntryclass.- 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 booleanequals(java.lang.Object o)Indicates whether the provided object is equal to this entry.AttributegetAttribute(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.StringgetAttributeValue(java.lang.String attributeName)Retrieves the value for the specified attribute, if available.java.lang.BooleangetAttributeValueAsBoolean(java.lang.String attributeName)Retrieves the value for the specified attribute as a Boolean, if available.java.util.DategetAttributeValueAsDate(java.lang.String attributeName)Retrieves the value for the specified attribute as a Date, formatted using the generalized time syntax, if available.DNgetAttributeValueAsDN(java.lang.String attributeName)Retrieves the value for the specified attribute as a DN, if available.java.lang.IntegergetAttributeValueAsInteger(java.lang.String attributeName)Retrieves the value for the specified attribute as an Integer, if available.java.lang.LonggetAttributeValueAsLong(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.StringgetDN()Retrieves the DN for this entry.AttributegetObjectClassAttribute()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.DNgetParentDN()Retrieves the parent DN for this entry.java.lang.StringgetParentDNString()Retrieves the parent DN for this entry as a string.DNgetParsedDN()Retrieves the parsed DN for this entry.RDNgetRDN()Retrieves the RDN for this entry.booleanhasAttribute(Attribute attribute)Indicates whether this entry contains the specified attribute.booleanhasAttribute(java.lang.String attributeName)Indicates whether this entry contains the specified attribute.booleanhasAttributeValue(java.lang.String attributeName, byte[] attributeValue)Indicates whether this entry contains an attribute with the given name and value.booleanhasAttributeValue(java.lang.String attributeName, java.lang.String attributeValue)Indicates whether this entry contains an attribute with the given name and value.inthashCode()Generates a hash code for this entry.booleanhasObjectClass(java.lang.String objectClassName)Indicates whether this entry contains the specified object class.EntrytoEntry()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.voidtoLDIF(ByteStringBuffer buffer)Appends an LDIF representation of this entry to the provided buffer.voidtoLDIF(ByteStringBuffer buffer, int wrapColumn)Appends an LDIF representation of this entry to the provided buffer.java.lang.StringtoLDIFString()Retrieves an LDIF-formatted string representation of this entry.java.lang.StringtoLDIFString(int wrapColumn)Retrieves an LDIF-formatted string representation of this entry.voidtoLDIFString(java.lang.StringBuilder buffer)Appends an LDIF-formatted string representation of this entry to the provided buffer.voidtoLDIFString(java.lang.StringBuilder buffer, int wrapColumn)Appends an LDIF-formatted string representation of this entry to the provided buffer.java.lang.StringtoString()Retrieves a string representation of this entry.voidtoString(java.lang.StringBuilder buffer)Appends a string representation of this entry to the provided buffer.
-
-
-
Constructor Detail
-
CompactEntry
public CompactEntry(@NotNull 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
@NotNull public java.lang.String getDN()
Retrieves the DN for this entry.- Returns:
- The DN for this entry.
-
getParsedDN
@NotNull 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
@Nullable public RDN getRDN() throws LDAPException
Retrieves the RDN for this entry.- Returns:
- The RDN for this entry, or
nullif the DN is the null DN. - Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
getParentDN
@Nullable public DN getParentDN() throws LDAPException
Retrieves the parent DN for this entry.- Returns:
- The parent DN for this entry, or
nullif there is no parent. - Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
getParentDNString
@Nullable 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
nullif there is no parent. - Throws:
LDAPException- If the DN string cannot be parsed as a valid DN.
-
hasAttribute
public boolean hasAttribute(@NotNull 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:
trueif this entry contains the specified attribute, orfalseif not.
-
hasAttribute
public boolean hasAttribute(@NotNull Attribute attribute)
Indicates whether this entry contains the specified attribute. It will only returntrueif 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:
trueif this entry contains the specified attribute, orfalse.
-
hasAttributeValue
public boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull 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:
trueif this entry contains an attribute with the specified name and value, orfalseif not.
-
hasAttributeValue
public boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull 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:
trueif this entry contains an attribute with the specified name and value, orfalseif not.
-
hasObjectClass
public boolean hasObjectClass(@NotNull 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:
trueif this entry contains the specified object class, orfalseif not.
-
getAttributes
@NotNull 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
@Nullable public Attribute getAttribute(@NotNull 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
nullif the specified attribute is not present in this entry.
-
getAttributesWithOptions
@NotNull public java.util.List<Attribute> getAttributesWithOptions(@NotNull java.lang.String baseName, @NotNull 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 ornullif 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
@Nullable public java.lang.String getAttributeValue(@NotNull 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
nullif that attribute is not available.
-
getAttributeValueBytes
@Nullable public byte[] getAttributeValueBytes(@NotNull 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
nullif that attribute is not available.
-
getAttributeValueAsBoolean
@Nullable public java.lang.Boolean getAttributeValueAsBoolean(@NotNull 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
nullif that attribute is not available or the value cannot be parsed as a Boolean.
-
getAttributeValueAsDate
@Nullable public java.util.Date getAttributeValueAsDate(@NotNull 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
nullif that attribute is not available or the value cannot be parsed as a Date.
-
getAttributeValueAsDN
@Nullable public DN getAttributeValueAsDN(@NotNull 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
nullif that attribute is not available or the value cannot be parsed as a DN.
-
getAttributeValueAsInteger
@Nullable public java.lang.Integer getAttributeValueAsInteger(@NotNull 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
nullif that attribute is not available or the value cannot be parsed as an Integer.
-
getAttributeValueAsLong
@Nullable public java.lang.Long getAttributeValueAsLong(@NotNull 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
nullif that attribute is not available or the value cannot be parsed as a Long.
-
getAttributeValues
@Nullable public java.lang.String[] getAttributeValues(@NotNull 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
nullif that attribute is not available.
-
getAttributeValueByteArrays
@Nullable public byte[][] getAttributeValueByteArrays(@NotNull 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
nullif that attribute is not available.
-
getObjectClassAttribute
@Nullable public Attribute getObjectClassAttribute()
Retrieves the "objectClass" attribute from the entry, if available.- Returns:
- The "objectClass" attribute from the entry, or
nullif that attribute not available.
-
getObjectClassValues
@Nullable 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
nullif that attribute is not available.
-
toEntry
@NotNull 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:
hashCodein classjava.lang.Object- Returns:
- The generated hash code for this entry.
-
equals
public boolean equals(@Nullable 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:
equalsin classjava.lang.Object- Parameters:
o- The object for which to make the determination.- Returns:
trueif the provided object is considered equal to this entry, orfalseif not.
-
toLDIF
@NotNull 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
@NotNull 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(@NotNull 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(@NotNull 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
@NotNull 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
@NotNull 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(@NotNull 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(@NotNull 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
@NotNull public java.lang.String toString()
Retrieves a string representation of this entry.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of this entry.
-
-