Package javax.jcr

Interface Value

  • All Known Subinterfaces:
    JackrabbitValue
    All Known Implementing Classes:
    BaseValue, BinaryValue, BooleanValue, DateValue, DecimalValue, DoubleValue, ErrorValue, LongValue, NameValue, PathValue, QValueValue, ReferenceValue, StringValue, URIValue, WeakReferenceValue

    public interface Value
    A generic holder for the value of a property. A Value object can be used without knowing the actual property type (STRING, DOUBLE, BINARY etc.).

    The Binary interface and its related methods in Property, Value and ValueFactory replace the deprecated Value.getStream and Property.getStream methods from JCR 1.0. However, though getStream has been deprecated, for reasons of backward compatibility its behavior must still conform to the following rules:

    • A Value object can be read using type-specific get methods. These methods are divided into two groups:
      • The non-stream get methods getString(), getBinary(), getDate(), getDecimal(), getLong(), getDouble() and getBoolean().
      • getStream().
    • Once a Value object has been read once using getStream(), all subsequent calls to getStream() will return the same Stream object. This may mean, for example, that the stream returned is fully or partially consumed. In order to get a fresh stream the Value object must be reacquired via Property.getValue() or Property.getValues().
    • Once a Value object has been read once using getStream(), any subsequent call to any of the non-stream get methods will throw an IllegalStateException. In order to successfully invoke a non-stream get method, the Value must be reacquired via Property.getValue() or Property.getValues().
    • Once a Value object has been read once using a non-stream get method, any subsequent call to getStream() will throw an IllegalStateException. In order to successfully invoke getStream(), the Value must be reacquired via Property.getValue() or Property.getValues().

    Two Value instances, v1 and v2, are considered equal if and only if:

    • v1.getType() == v2.getType(), and,
    • v1.getString().equals(v2.getString())
    Actually comparing two Value instances by converting them to string form may not be practical in some cases (for example, if the values are very large binaries). Consequently, the above is intended as a normative definition of Value equality but not as a procedural test of equality. It is assumed that implementations will have efficient means of determining equality that conform with the above definition.

    An implementation is only required to support equality comparisons on Value instances that were acquired from the same Session and whose contents have not been read. The equality comparison must not change the state of the Value instances even though the getString() method in the above definition implies a state change.