Copyright© 2008-2022 Sitevision AB, all rights reserved.
public interface Value
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:
Value
object can be read using type-specific
get
methods. These methods are divided into two groups: get
methods getString()
,
getBinary()
, getDate()
, getDecimal()
,
getLong()
, getDouble()
and
getBoolean()
. getStream()
. 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()
. 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()
.
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())
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.
Modifier and Type | Method and Description |
---|---|
Binary |
getBinary()
Returns a
Binary representation of this value. |
boolean |
getBoolean()
Returns a
Boolean representation of this value. |
Calendar |
getDate()
Returns a
Calendar representation of this value. |
BigDecimal |
getDecimal()
Returns a
BigDecimal representation of this value. |
double |
getDouble()
Returns a
double representation of this value. |
long |
getLong()
Returns a
long representation of this value. |
InputStream |
getStream()
Deprecated.
As of JCR 2.0,
getBinary() should be used instead. |
String |
getString()
Returns a
String representation of this value. |
int |
getType()
Returns the
type of this Value . |
String getString() throws ValueFormatException, IllegalStateException, RepositoryException
String
representation of this value.String
representation of the value of this
property.ValueFormatException
- if conversion to a String
is
not possible.IllegalStateException
- if getStream
has previously
been called on this Value
instance. In this case a new
Value
instance must be acquired in order to successfully
call this method.RepositoryException
- if another error occurs.@Deprecated InputStream getStream() throws RepositoryException
getBinary()
should be used instead.InputStream
representation of this value. Uses
the standard conversion to binary (see JCR specification).
It is the responsibility of the caller to close the returned
InputStream
.
Sitevision note: Unsupported operation
InputStream
representation of this value.RepositoryException
- if an error occurs.Binary getBinary() throws RepositoryException
Binary
representation of this value. The Binary
object in turn provides methods to access the binary data itself.
Uses the standard conversion to binary (see JCR specification).
Sitevision note: Limited to the URL
and URI
properties of nodes with primary
NodeType
sv:file
and sv:image
and to any PropertyType.WEAKREFERENCE
pointing to a Node
of type sv:file
or sv:image
Binary
representation of this value.RepositoryException
- if an error occurs.long getLong() throws ValueFormatException, RepositoryException
long
representation of this value.long
representation of this value.ValueFormatException
- if conversion to an long
is not
possible.RepositoryException
- if another error occurs.double getDouble() throws ValueFormatException, RepositoryException
double
representation of this value.double
representation of this value.ValueFormatException
- if conversion to a double
is
not possible.RepositoryException
- if another error occurs.BigDecimal getDecimal() throws ValueFormatException, RepositoryException
BigDecimal
representation of this value.BigDecimal
representation of this value.ValueFormatException
- if conversion to a BigDecimal
is not possible.RepositoryException
- if another error occurs.Calendar getDate() throws ValueFormatException, RepositoryException
Calendar
representation of this value.
The object returned is a copy of the stored value, so changes to it are not reflected in internal storage.
Calendar
representation of this value.ValueFormatException
- if conversion to a Calendar
is
not possible.RepositoryException
- if another error occurs.boolean getBoolean() throws ValueFormatException, RepositoryException
Boolean
representation of this value.Boolean
representation of this value.ValueFormatException
- if conversion to a Boolean
is
not possible.RepositoryException
- if another error occurs.int getType()
type
of this Value
. One of: PropertyType.STRING
PropertyType.DATE
PropertyType.BINARY
PropertyType.DOUBLE
PropertyType.DECIMAL
PropertyType.LONG
PropertyType.BOOLEAN
PropertyType.NAME
PropertyType.PATH
PropertyType.REFERENCE
PropertyType.WEAKREFERENCE
PropertyType.URI
PropertyType
.
The type returned is that which was set at property creation.
Sitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.