Class Attributes

java.lang.Object
org.forgerock.opendj.ldap.Attributes

public final class Attributes extends Object
This class contains methods for creating and manipulating attributes.
  • Method Details

    • emptyAttribute

      public static Attribute emptyAttribute(AttributeDescription attributeDescription)
      Returns a read-only empty attribute having the specified attribute description. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in an UnsupportedOperationException.
      Parameters:
      attributeDescription - The attribute description.
      Returns:
      The empty attribute.
      Throws:
      NullPointerException - If attributeDescription was null.
    • emptyAttribute

      public static Attribute emptyAttribute(String attributeDescription)
      Returns a read-only empty attribute having the specified attribute description. The attribute description will be decoded using the default schema. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in an UnsupportedOperationException.
      Parameters:
      attributeDescription - The attribute description.
      Returns:
      The empty attribute.
      Throws:
      LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
      NullPointerException - If attributeDescription was null.
    • renameAttribute

      public static Attribute renameAttribute(Attribute attribute, AttributeDescription attributeDescription)
      Returns a view of attribute having a different attribute description. All operations on the returned attribute "pass-through" to the underlying attribute.
      Parameters:
      attribute - The attribute to be renamed.
      attributeDescription - The new attribute description for attribute.
      Returns:
      A renamed view of attribute.
      Throws:
      NullPointerException - If attribute or attributeDescription was null.
    • renameAttribute

      public static Attribute renameAttribute(Attribute attribute, String attributeDescription)
      Returns a view of attribute having a different attribute description. All operations on the returned attribute "pass-through" to the underlying attribute. The attribute description will be decoded using the default schema.
      Parameters:
      attribute - The attribute to be renamed.
      attributeDescription - The new attribute description for attribute.
      Returns:
      A renamed view of attribute.
      Throws:
      LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
      NullPointerException - If attribute or attributeDescription was null.
    • singletonAttribute

      public static Attribute singletonAttribute(AttributeDescription attributeDescription, Object value)
      Returns a read-only single-valued attribute having the specified attribute description and value. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in an UnsupportedOperationException.

      If value is not an instance of ByteString then it will be converted using the ByteString.valueOfObject(Object) method.

      Parameters:
      attributeDescription - The attribute description.
      value - The single attribute value.
      Returns:
      The single-valued attribute.
      Throws:
      NullPointerException - If attributeDescription or value was null.
    • singletonAttribute

      public static Attribute singletonAttribute(String attributeDescription, Object value)
      Returns a read-only single-valued attribute having the specified attribute description. The attribute description will be decoded using the default schema. Attempts to modify the returned attribute either directly, or indirectly via an iterator, result in an UnsupportedOperationException.

      If value is not an instance of ByteString then it will be converted using the ByteString.valueOfObject(Object) method.

      Parameters:
      attributeDescription - The attribute description.
      value - The single attribute value.
      Returns:
      The single-valued attribute.
      Throws:
      LocalizedIllegalArgumentException - If attributeDescription could not be decoded using the default schema.
      NullPointerException - If attributeDescription or value was null.
    • unmodifiableAttribute

      public static Attribute unmodifiableAttribute(Attribute attribute)
      Returns a read-only view of attribute. Query operations on the returned attribute "read-through" to the underlying attribute, and attempts to modify the returned attribute either directly or indirectly via an iterator result in an UnsupportedOperationException.
      Parameters:
      attribute - The attribute for which a read-only view is to be returned.
      Returns:
      A read-only view of attribute.
      Throws:
      NullPointerException - If attribute was null.
    • virtualAttribute

      public static Attribute virtualAttribute(Attribute attribute)
      Returns a view of attribute that is virtual, i.e. implementations of Attribute.isVirtual() and Attribute.isReal() match the semantics of virtual attributes.

      Virtual attributes a special kind of attribute whose values do not actually exist in persistent storage but rather are dynamically generated in some manner.

      In particular, this method can be used to implement collective virtual attribute, which is a special kind of attribute whose values do not actually exist in persistent storage but rather are obtained dynamically from applicable collective attribute subentry.

      Parameters:
      attribute - The attribute for which a read-only view is to be returned.
      Returns:
      A read-only view of attribute.
      Throws:
      NullPointerException - If attribute was null.
    • virtualAttribute

      public static Attribute virtualAttribute(AttributeDescription attributeDescription, Supplier<Collection<?>> attributeValuesSupplier)
      Returns a virtual attribute whose values will be supplied by provided Supplier.

      Virtual attributes a special kind of attribute whose values do not actually exist in persistent storage but rather are dynamically generated in some manner.

      In particular, this method can be used to implement collective virtual attribute, which is a special kind of attribute whose values do not actually exist in persistent storage but rather are obtained dynamically from applicable collective attribute subentry.

      Note: this method should be used when computing the attribute value operation is costly. Indeed, this method returns an attribute which lazily computes the attribute value.

      Parameters:
      attributeDescription - the attribute description of the attribute
      attributeValuesSupplier - The supplier that returns the attribute values for which a read-only view is to be returned.
      Returns:
      A read-only view of attribute.
      Throws:
      NullPointerException - If attribute was null.
    • virtualAttribute

      public static Attribute virtualAttribute(AttributeDescription attributeDescription)
      Returns an empty virtual attribute.

      Virtual attributes a special kind of attribute whose values do not actually exist in persistent storage but rather are dynamically generated in some manner.

      In particular, this method can be used to implement collective virtual attribute, which is a special kind of attribute whose values do not actually exist in persistent storage but rather are obtained dynamically from applicable collective attribute subentry.

      Parameters:
      attributeDescription - The attribute for which a read-only view is to be returned.
      Returns:
      A read-only view of an empty attribute.
      Throws:
      NullPointerException - If attribute was null.