public final class Attributes extends Object
Attribute
s as well as static factory methods for
facilitating common Attribute
construction use-cases.
Of particular interest are the following three factory methods:
empty(String); create(String, String); create(String, String, String...);These are provided in order to facilitate construction of empty, single-valued, and multi-valued attributes respectively, for example, in unit tests. The last factory method is not designed for performance critical functionality and, instead, an
AttributeBuilder
should be used in order to incrementally construct
multi-valued attributes.Modifier and Type | Method and Description |
---|---|
static Attribute |
create(org.forgerock.opendj.ldap.AttributeDescription attributeDescription,
org.forgerock.opendj.ldap.ByteString value)
Creates a new single-valued attribute with the specified attribute description and value.
|
static Attribute |
create(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
org.forgerock.opendj.ldap.ByteString value)
Creates a new single-valued attribute with the specified attribute type and value.
|
static Attribute |
create(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
String valueString)
Creates a new single-valued attribute with the specified name and value.
|
static Attribute |
create(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
String name,
org.forgerock.opendj.ldap.ByteString value)
Creates a new single-valued attribute with the specified attribute type and value.
|
static Attribute |
create(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
String name,
String valueString)
Creates a new single-valued attribute with the attribute type and value.
|
static Attribute |
create(String attributeName,
String... valueStrings)
Creates a new multi-valued attribute with the specified attribute name and attribute values.
|
static Attribute |
create(String attributeName,
String valueString)
Creates a new single-valued attribute with the specified attribute name and attribute value.
|
static List<Attribute> |
createAsList(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
org.forgerock.opendj.ldap.ByteString value)
Creates a new List with a single-valued attribute with the specified attribute type and value.
|
static List<Attribute> |
createAsList(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
String valueString)
Creates a new List with a single-valued attribute with the specified name and value.
|
static Attribute |
empty(Attribute attribute)
Creates a new attribute which has the same attribute type and attribute options as the provided attribute but no
attribute values.
|
static Attribute |
empty(org.forgerock.opendj.ldap.schema.AttributeType attributeType)
Creates a new attribute with the provided attribute type and no values.
|
static Attribute |
empty(org.forgerock.opendj.ldap.schema.AttributeType attributeType,
String name)
Creates a new attribute with the provided attribute type and no values.
|
static Attribute |
empty(String attributeName)
Creates a new attribute with the specified attribute name and no attribute values.
|
static Attribute |
merge(Attribute a1,
Attribute a2)
Creates a new attribute containing all the values from the two provided attributes.
|
static Attribute |
merge(Attribute a1,
Attribute a2,
Collection<org.forgerock.opendj.ldap.ByteString> duplicateValues)
Creates a new attribute containing all the values from the two provided attributes and put any duplicate values
into the provided collection.
|
static Attribute |
subtract(Attribute a1,
Attribute a2)
Creates a new attribute containing the values from the first attribute which are not in the second attribute.
|
static Attribute |
subtract(Attribute a1,
Attribute a2,
Collection<org.forgerock.opendj.ldap.ByteString> missingValues)
Creates a new attribute containing the values from the first attribute which are not in the second attribute.
|
public static Attribute create(org.forgerock.opendj.ldap.AttributeDescription attributeDescription, org.forgerock.opendj.ldap.ByteString value)
attributeDescription
- The attribute description to use.value
- The attribute value.public static Attribute create(org.forgerock.opendj.ldap.schema.AttributeType attributeType, org.forgerock.opendj.ldap.ByteString value)
attributeType
- The attribute type to use.value
- The attribute value.public static List<Attribute> createAsList(org.forgerock.opendj.ldap.schema.AttributeType attributeType, org.forgerock.opendj.ldap.ByteString value)
attributeType
- The attribute type to use.value
- The attribute value.public static Attribute create(org.forgerock.opendj.ldap.schema.AttributeType attributeType, String valueString)
attributeType
- The attribute type to use.valueString
- The String representation of the attribute value.public static List<Attribute> createAsList(org.forgerock.opendj.ldap.schema.AttributeType attributeType, String valueString)
attributeType
- The attribute type to use.valueString
- The String representation of the attribute value.public static Attribute create(org.forgerock.opendj.ldap.schema.AttributeType attributeType, String name, org.forgerock.opendj.ldap.ByteString value)
attributeType
- The attribute type to use.name
- The user-provided name for this attribute.value
- The attribute value.public static Attribute create(org.forgerock.opendj.ldap.schema.AttributeType attributeType, String name, String valueString)
attributeType
- The attribute type to use.name
- The user-provided name for this attribute.valueString
- The String representation of the attribute value.public static Attribute create(String attributeName, String valueString)
If the attribute name cannot be found in the schema, a new attribute type is created using the default attribute syntax.
attributeName
- The name or OID of the attribute type for this attribute (can be mixed case).valueString
- The String representation of the attribute value.public static Attribute create(String attributeName, String... valueStrings)
If the attribute name cannot be found in the schema, a new attribute type is created using the default attribute syntax.
NOTE: this method is provided as a convenience and should typically be reserved for use in unit tests and
places where performance is not an issue. In particular, this method will construct a temporary array containing
the attribute's values. For performance critical purposes, incrementally construct an attribute using an
AttributeBuilder
.
attributeName
- The name or OID of the attribute type for this attribute (can be mixed case).valueStrings
- The string representation of the attribute values.public static Attribute empty(Attribute attribute)
attribute
- The attribute to be copied.public static Attribute empty(org.forgerock.opendj.ldap.schema.AttributeType attributeType)
attributeType
- The attribute type to use.public static Attribute empty(org.forgerock.opendj.ldap.schema.AttributeType attributeType, String name)
attributeType
- The attribute type to use.name
- The user-provided name for this attribute.public static Attribute empty(String attributeName)
If the attribute name cannot be found in the schema, a new attribute type is created using the default attribute syntax.
attributeName
- The name or OID of the attribute type for this attribute (can be mixed case).public static Attribute merge(Attribute a1, Attribute a2)
This method is logically equivalent to:
merge(a1, a2, null);
a1
- The first attribute.a2
- The second attribute.public static Attribute merge(Attribute a1, Attribute a2, Collection<org.forgerock.opendj.ldap.ByteString> duplicateValues)
a1
- The first attribute.a2
- The second attribute.duplicateValues
- A collection which will be used to store any duplicate values, or null
if duplicate
values should not be stored.public static Attribute subtract(Attribute a1, Attribute a2)
This method is logically equivalent to:
subtract(a1, a2, null);
a1
- The first attribute.a2
- The second attribute.public static Attribute subtract(Attribute a1, Attribute a2, Collection<org.forgerock.opendj.ldap.ByteString> missingValues)
a1
- The first attribute.a2
- The second attribute.missingValues
- A collection which will be used to store any missing values, or null
if missing values
should not be stored.Copyright © 2010–2017 ForgeRock AS. All rights reserved.