public class Value extends Object implements Cloneable, Externalizable, Comparable<Value>
+---------+ | boolean | isHR flag +---------+ | boolean | TRUE if the value is not null, FALSE otherwise +---------+ [| int |] If the previous flag is TRUE, the length of the value [+---------+] [| byte[] |] The value itself [+---------+] | boolean | TRUE if we have a prepared String +---------+ [| String |] The prepared String if we have it [+---------+]
| Modifier and Type | Field and Description |
|---|---|
private AttributeType |
attributeType
reference to the attributeType associated with the value
|
private byte[] |
bytes
The UTF-8 bytes for this value (we use the UP value)
|
private int |
h
The computed hashcode.
|
private boolean |
isHR
Two flags used to tell if the value is HR or not in serialization
|
private static org.slf4j.Logger |
LOG
logger for reporting errors that might not be handled properly upstream
|
private String |
normValue
the prepared representation of the user provided value if it's a String
|
private static long |
serialVersionUID
Used for serialization
|
private static StringComparator |
stringComparator
A default comparator if we don't have an EQUALITY MR
|
private String |
upValue
the User Provided value if it's a String
|
| Constructor and Description |
|---|
Value(AttributeType attributeType)
Creates a schema aware binary Value with an initial value.
|
Value(AttributeType attributeType,
byte[] upValue)
Creates a schema aware binary Value with an initial value.
|
Value(AttributeType attributeType,
String upValue)
Creates a schema aware StringValue with an initial user provided String value.
|
Value(AttributeType attributeType,
String upValue,
String normValue)
Creates a schema aware StringValue with an initial user provided String value and
its normalized Value
|
Value(AttributeType attributeType,
Value value)
Creates a Value from an existing Value with an AttributeType
|
Value(byte[] value)
Creates a Value with an initial user provided binary value.
|
Value(String upValue)
Creates a Value with an initial user provided String value.
|
| Modifier and Type | Method and Description |
|---|---|
Value |
clone()
Clone a Value
|
int |
compareTo(byte[] other)
Compare two values.
|
int |
compareTo(String other)
Compare the current value with a String.
|
int |
compareTo(Value other)
Compare two values.
|
private void |
computeNormValue()
Compute the normalized value
|
static Value |
createValue(AttributeType attributeType)
Create a Value with an AttributeType.
|
static Value |
deserialize(AttributeType attributeType,
ObjectInput in)
Deserialize a Value.
|
int |
deserialize(byte[] buffer,
int pos)
Deserialize a StringValue from a byte[], starting at a given position
|
static Value |
deserialize(ObjectInput in)
Deserialize a Value.
|
boolean |
equals(Object obj)
We compare two values using their Comparator, if any.
|
AttributeType |
getAttributeType()
Get the associated AttributeType
|
byte[] |
getBytes()
Get the wrapped value as a byte[], if and only if the Value is binary,
otherwise returns null.
|
private LdapComparator<?> |
getLdapComparator()
Gets a comparator using getMatchingRule() to resolve the matching
that the comparator is extracted from.
|
String |
getNormalized() |
String |
getString()
Get the User Provided value.
|
int |
hashCode() |
private void |
init(AttributeType attributeType) |
boolean |
isHumanReadable()
Tells if the current value is Human Readable
|
boolean |
isInstanceOf(AttributeType attributeType)
Check if the value is stored into an instance of the given
AttributeType, or one of its ascendant.
|
boolean |
isNull()
Check if the contained value is null or not
|
boolean |
isSchemaAware()
Tells if the value is schema aware or not.
|
boolean |
isValid(SyntaxChecker syntaxChecker)
Uses the syntaxChecker associated with the attributeType to check if the
value is valid.
|
int |
length() |
void |
readExternal(ObjectInput in) |
int |
serialize(byte[] buffer,
int pos)
Serialize the Value into a buffer at the given position.
|
String |
toString() |
void |
writeExternal(ObjectOutput out) |
private static final long serialVersionUID
private static final org.slf4j.Logger LOG
private transient AttributeType attributeType
private String upValue
private String normValue
private volatile int h
private byte[] bytes
private boolean isHR
private static StringComparator stringComparator
public Value(String upValue)
upValue - the value to wrap. It can be nullpublic Value(byte[] value)
value - the binary value to wrap which may be null, or a zero length byte arraypublic Value(AttributeType attributeType, byte[] upValue) throws LdapInvalidAttributeValueException
attributeType - the schema type associated with this ValueupValue - the value to wrapLdapInvalidAttributeValueException - If the added value is invalid accordingly
to the schemaValue(AttributeType attributeType)
attributeType - the schema type associated with this Valuepublic Value(AttributeType attributeType, String upValue) throws LdapInvalidAttributeValueException
attributeType - the schema type associated with this StringValueupValue - the value to wrapLdapInvalidAttributeValueException - If the added value is invalid accordingly
to the schemapublic Value(AttributeType attributeType, String upValue, String normValue) throws LdapInvalidAttributeValueException
attributeType - the schema type associated with this StringValueupValue - the value to wrapnormValue - the normalized value to wrapLdapInvalidAttributeValueException - If the added value is invalid accordingly
to the schemapublic Value(AttributeType attributeType, Value value) throws LdapInvalidAttributeValueException
attributeType - the schema attribute type associated with this StringValuevalue - the original ValueLdapInvalidAttributeValueException - If the value is invalidprivate void init(AttributeType attributeType)
public static Value createValue(AttributeType attributeType)
attributeType - The ATttributeType to usepublic boolean isNull()
true if the inner value is null.public AttributeType getAttributeType()
public boolean isInstanceOf(AttributeType attributeType)
attributeType - The AttributeType we are looking attrue if the value is associated with the given
attributeType or one of its ascendantpublic String getString()
private void computeNormValue()
throws LdapException
LdapException - If we were'nt able to normalize the valuepublic String getNormalized()
public byte[] getBytes()
public boolean isSchemaAware()
true if the value is sxhema awarepublic final boolean isValid(SyntaxChecker syntaxChecker) throws LdapInvalidAttributeValueException
syntaxChecker - the SyntaxChecker to use to validate the valuetrue if the value is validLdapInvalidAttributeValueException - if the value cannot be validatedpublic boolean isHumanReadable()
true if the value is a String, false otherwisepublic int length()
private LdapComparator<?> getLdapComparator()
public int serialize(byte[] buffer,
int pos)
buffer - The buffer which will contain the serialized StringValuepos - The position in the buffer for the serialized valuepublic static Value deserialize(ObjectInput in) throws IOException, ClassNotFoundException
in - The input streamIOException - If the stream can't be readClassNotFoundException - If we can't instanciate a Valuepublic static Value deserialize(AttributeType attributeType, ObjectInput in) throws IOException, ClassNotFoundException
attributeType - The AttributeType associated with the Value. Can be nullin - The input streamIOException - If the stream can't be readClassNotFoundException - If we can't instanciate a Valuepublic int deserialize(byte[] buffer,
int pos)
throws IOException,
LdapInvalidAttributeValueException
buffer - The buffer containing the StringValuepos - The position in the bufferIOException - If the serialized value is not a StringValueLdapInvalidAttributeValueException - If the value is invalidpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic int compareTo(String other)
other - the String we want to compare the current value withIllegalStateException - on failures to extract the comparator, or the
normalizers needed to perform the required comparisons based on the schemapublic int compareTo(byte[] other)
other - the byte[] we want to compare the current value withIllegalStateException - on failures to extract the comparator, or the
normalizers needed to perform the required comparisons based on the schemapublic int compareTo(Value other)
compareTo in interface Comparable<Value>other - The other Value we want to compare the current value withIllegalStateException - on failures to extract the comparator, or the
normalizers needed to perform the required comparisons based on the schemapublic boolean equals(Object obj)
equals in class ObjectObject.equals(Object)public int hashCode()
hashCode in class ObjectObject.hashCode()public String toString()
toString in class ObjectObject.toString()Copyright © 2003–2019 The Apache Software Foundation. All rights reserved.