Class LinkedAttribute
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<ByteString>
-
- org.forgerock.opendj.ldap.AbstractAttribute
-
- org.forgerock.opendj.ldap.LinkedAttribute
-
- All Implemented Interfaces:
Iterable<ByteString>,Collection<ByteString>,Set<ByteString>,Attribute
public final class LinkedAttribute extends AbstractAttribute
An implementation of theAttributeinterface with predictable iteration order.Internally, attribute values are stored in a linked list and it's this list which defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). This ordering is particularly useful in LDAP where clients generally appreciate having things returned in the same order they were presented.
All operations are supported by this implementation.
-
-
Constructor Summary
Constructors Constructor Description LinkedAttribute(String attributeDescription)Creates a new attribute having the specified attribute description and no attribute values.LinkedAttribute(String attributeDescription, Object value)Creates a new attribute having the specified attribute description and single attribute value.LinkedAttribute(String attributeDescription, Object... values)Creates a new attribute having the specified attribute description and attribute values.LinkedAttribute(String attributeDescription, Collection<?> values)Creates a new attribute having the specified attribute description and attribute values.LinkedAttribute(Attribute attribute)Creates a new attribute having the same attribute description and attribute values asattribute.LinkedAttribute(AttributeDescription attributeDescription)Creates a new attribute having the specified attribute description and no attribute values.LinkedAttribute(AttributeDescription attributeDescription, Object value)Creates a new attribute having the specified attribute description and single attribute value.LinkedAttribute(AttributeDescription attributeDescription, Object... values)Creates a new attribute having the specified attribute description and attribute values.LinkedAttribute(AttributeDescription attributeDescription, Collection<?> values)Creates a new attribute having the specified attribute description and attribute values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(ByteString value)Addsvalueto this attribute if it is not already present (optional operation).voidclear()Removes all of the attribute values from this attribute (optional operation).booleancontains(Object value)Returnstrueif this attribute containsvalue.booleancontainsAll(Collection<?> values)Returnstrueif this attribute contains all of the attribute values contained invalues.ByteStringfirstValue()Returns the first attribute value in this attribute.AttributeDescriptiongetAttributeDescription()Returns the attribute description of this attribute, which includes its attribute type and any options.booleanisEmpty()Returnstrueif this attribute contains no attribute values.booleanisVirtual()Indicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).Iterator<ByteString>iterator()Returns an iterator over the attribute values in this attribute.ConditionResultmatchesEqualityAssertion(Assertion assertion, ByteSequence rawAssertion)NOTE: it is only possible to optimize for the equality matching rule because the other matching rules may not be compatible with the equality matching rule's normalized representation.booleanremove(Object value)Removesvaluefrom this attribute if it is present (optional operation).<T> booleanretainAll(Collection<T> values, Collection<? super T> missingValues)Retains only the attribute values in this attribute which are contained invalues(optional operation).intsize()Returns the number of attribute values in this attribute.-
Methods inherited from class org.forgerock.opendj.ldap.AbstractAttribute
add, addAll, addAll, equals, hashCode, matchesApproximateAssertion, matchesGreaterOrEqualAssertion, matchesLessOrEqualAssertion, matchesSubstringAssertion, parse, removeAll, removeAll, retainAll, toArray, toString
-
Methods inherited from class java.util.AbstractCollection
toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.forgerock.opendj.ldap.Attribute
firstValueAsString, getAttributeDescriptionAsString, isReal, put, put, toArray
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator, toArray
-
-
-
-
Constructor Detail
-
LinkedAttribute
public LinkedAttribute(Attribute attribute)
Creates a new attribute having the same attribute description and attribute values asattribute.- Parameters:
attribute- The attribute to be copied.- Throws:
NullPointerException- Ifattributewasnull.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription)
Creates a new attribute having the specified attribute description and no attribute values.- Parameters:
attributeDescription- The attribute description.- Throws:
NullPointerException- IfattributeDescriptionwasnull.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription, Object value)
Creates a new attribute having the specified attribute description and single attribute value.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.value- The single attribute value.- Throws:
NullPointerException- IfattributeDescriptionorvaluewasnull.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription, Object... values)
Creates a new attribute having the specified attribute description and attribute values.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
NullPointerException- IfattributeDescriptionorvalueswasnull.
-
LinkedAttribute
public LinkedAttribute(AttributeDescription attributeDescription, Collection<?> values)
Creates a new attribute having the specified attribute description and attribute values.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
NullPointerException- IfattributeDescriptionorvalueswasnull.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription)
Creates a new attribute having the specified attribute description and no attribute values. The attribute description will be decoded using the default schema.- Parameters:
attributeDescription- The attribute description.- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionwasnull.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription, Collection<?> values)
Creates a new attribute having the specified attribute description and attribute values. The attribute description will be decoded using the default schema.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvalueswasnull.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription, Object value)
Creates a new attribute having the specified attribute description and single attribute value. The attribute description will be decoded using the default schema.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.value- The single attribute value.- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvaluewasnull.
-
LinkedAttribute
public LinkedAttribute(String attributeDescription, Object... values)
Creates a new attribute having the specified attribute description and attribute values. The attribute description will be decoded using the default schema.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Parameters:
attributeDescription- The attribute description.values- The attribute values.- Throws:
LocalizedIllegalArgumentException- IfattributeDescriptioncould not be decoded using the default schema.NullPointerException- IfattributeDescriptionorvalueswasnull.
-
-
Method Detail
-
add
public boolean add(ByteString value)
Description copied from interface:AttributeAddsvalueto this attribute if it is not already present (optional operation). If this attribute already containsvalue, the call leaves the attribute unchanged and returnsfalse.- Specified by:
addin interfaceAttribute- Specified by:
addin interfaceCollection<ByteString>- Specified by:
addin interfaceSet<ByteString>- Overrides:
addin classAbstractCollection<ByteString>- Parameters:
value- The attribute value to be added to this attribute.- Returns:
trueif this attribute changed as a result of this call.
-
clear
public void clear()
Description copied from interface:AttributeRemoves all of the attribute values from this attribute (optional operation). This attribute will be empty after this call returns.- Specified by:
clearin interfaceAttribute- Specified by:
clearin interfaceCollection<ByteString>- Specified by:
clearin interfaceSet<ByteString>- Overrides:
clearin classAbstractCollection<ByteString>
-
contains
public boolean contains(Object value)
Description copied from interface:AttributeReturnstrueif this attribute containsvalue.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Specified by:
containsin interfaceAttribute- Specified by:
containsin interfaceCollection<ByteString>- Specified by:
containsin interfaceSet<ByteString>- Overrides:
containsin classAbstractAttribute- Parameters:
value- The attribute value whose presence in this attribute is to be tested.- Returns:
trueif this attribute containsvalue, orfalseif not.
-
containsAll
public boolean containsAll(Collection<?> values)
Description copied from interface:AttributeReturnstrueif this attribute contains all of the attribute values contained invalues.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Specified by:
containsAllin interfaceAttribute- Specified by:
containsAllin interfaceCollection<ByteString>- Specified by:
containsAllin interfaceSet<ByteString>- Overrides:
containsAllin classAbstractAttribute- Parameters:
values- The attribute values whose presence in this attribute is to be tested.- Returns:
trueif this attribute contains all of the attribute values contained invalues, orfalseif not.
-
firstValue
public ByteString firstValue()
Description copied from interface:AttributeReturns the first attribute value in this attribute.- Specified by:
firstValuein interfaceAttribute- Overrides:
firstValuein classAbstractAttribute- Returns:
- The first attribute value in this attribute.
-
getAttributeDescription
public AttributeDescription getAttributeDescription()
Description copied from interface:AttributeReturns the attribute description of this attribute, which includes its attribute type and any options.- Returns:
- The attribute description.
-
isVirtual
public boolean isVirtual()
Description copied from interface:AttributeIndicates whether this is a virtual attribute (dynamically computed) rather than a real attribute (persisted).- Returns:
trueif this is a virtual attribute.
-
isEmpty
public boolean isEmpty()
Description copied from interface:AttributeReturnstrueif this attribute contains no attribute values.- Specified by:
isEmptyin interfaceAttribute- Specified by:
isEmptyin interfaceCollection<ByteString>- Specified by:
isEmptyin interfaceSet<ByteString>- Overrides:
isEmptyin classAbstractAttribute- Returns:
trueif this attribute contains no attribute values.
-
iterator
public Iterator<ByteString> iterator()
Description copied from interface:AttributeReturns an iterator over the attribute values in this attribute. The attribute values are returned in no particular order, unless the implementation of this attribute provides such a guarantee.- Specified by:
iteratorin interfaceAttribute- Specified by:
iteratorin interfaceCollection<ByteString>- Specified by:
iteratorin interfaceIterable<ByteString>- Specified by:
iteratorin interfaceSet<ByteString>- Specified by:
iteratorin classAbstractAttribute- Returns:
- An iterator over the attribute values in this attribute.
-
matchesEqualityAssertion
public ConditionResult matchesEqualityAssertion(Assertion assertion, ByteSequence rawAssertion)
NOTE: it is only possible to optimize for the equality matching rule because the other matching rules may not be compatible with the equality matching rule's normalized representation. For example, DN syntax uses DN matching for equality and case ignore string matching for substring matching.- Specified by:
matchesEqualityAssertionin interfaceAttribute- Overrides:
matchesEqualityAssertionin classAbstractAttribute- Parameters:
assertion- The attribute value assertion compiled using the attribute's default equality matching rule.rawAssertion- The raw assertion value whose syntax is compatible with the attribute's default equality matching rule.- Returns:
ConditionResult.FALSEif the assertion does not match any values in this attribute,ConditionResult.TRUEif the assertion matches at least one value in this attribute, orConditionResult.UNDEFINEDif the assertion does not match any values in this attribute, but one or more values could not be compared because they are incompatible with the matching rule.
-
remove
public boolean remove(Object value)
Description copied from interface:AttributeRemovesvaluefrom this attribute if it is present (optional operation). If this attribute does not containvalue, the call leaves the attribute unchanged and returnsfalse.If
valueis not an instance ofByteStringthen it will be converted using theByteString.valueOfObject(Object)method.- Specified by:
removein interfaceAttribute- Specified by:
removein interfaceCollection<ByteString>- Specified by:
removein interfaceSet<ByteString>- Overrides:
removein classAbstractCollection<ByteString>- Parameters:
value- The attribute value to be removed from this attribute.- Returns:
trueif this attribute changed as a result of this call.
-
retainAll
public <T> boolean retainAll(Collection<T> values, Collection<? super T> missingValues)
Description copied from interface:AttributeRetains only the attribute values in this attribute which are contained invalues(optional operation). Any attribute values which are not already present will be added tomissingValuesif specified.Any attribute values which are not instances of
ByteStringwill be converted using theByteString.valueOfObject(Object)method.- Specified by:
retainAllin interfaceAttribute- Overrides:
retainAllin classAbstractAttribute- Type Parameters:
T- The type of the attribute value objects being retained.- Parameters:
values- The attribute values to be retained in this attribute.missingValues- A collection into which missing values will be added, ornullif missing values should not be saved.- Returns:
trueif this attribute changed as a result of this call.
-
size
public int size()
Description copied from interface:AttributeReturns the number of attribute values in this attribute.- Specified by:
sizein interfaceAttribute- Specified by:
sizein interfaceCollection<ByteString>- Specified by:
sizein interfaceSet<ByteString>- Overrides:
sizein classAbstractAttribute- Returns:
- The number of attribute values in this attribute.
-
-