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 ValueA generic holder for the value of a property. AValueobject can be used without knowing the actual property type (STRING,DOUBLE,BINARYetc.).The
Binaryinterface and its related methods inProperty,ValueandValueFactoryreplace the deprecatedValue.getStreamandProperty.getStreammethods from JCR 1.0. However, thoughgetStreamhas been deprecated, for reasons of backward compatibility its behavior must still conform to the following rules:- A
Valueobject can be read using type-specificgetmethods. These methods are divided into two groups:- The non-stream
getmethodsgetString(),getBinary(),getDate(),getDecimal(),getLong(),getDouble()andgetBoolean(). -
getStream().
- The non-stream
- Once a
Valueobject has been read once usinggetStream(), all subsequent calls togetStream()will return the sameStreamobject. This may mean, for example, that the stream returned is fully or partially consumed. In order to get a fresh stream theValueobject must be reacquired viaProperty.getValue()orProperty.getValues(). - Once a
Valueobject has been read once usinggetStream(), any subsequent call to any of the non-streamgetmethods will throw anIllegalStateException. In order to successfully invoke a non-streamgetmethod, theValuemust be reacquired viaProperty.getValue()orProperty.getValues(). - Once a
Valueobject has been read once using a non-stream get method, any subsequent call togetStream()will throw anIllegalStateException. In order to successfully invokegetStream(), theValuemust be reacquired viaProperty.getValue()orProperty.getValues().
Two
Valueinstances,v1andv2, are considered equal if and only if:v1.getType() == v2.getType(), and,v1.getString().equals(v2.getString())
Valueinstances 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 ofValueequality 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
Valueinstances that were acquired from the sameSessionand whose contents have not been read. The equality comparison must not change the state of theValueinstances even though thegetString()method in the above definition implies a state change.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description BinarygetBinary()Returns aBinaryrepresentation of this value.booleangetBoolean()Returns aBooleanrepresentation of this value.java.util.CalendargetDate()Returns aCalendarrepresentation of this value.java.math.BigDecimalgetDecimal()Returns aBigDecimalrepresentation of this value.doublegetDouble()Returns adoublerepresentation of this value.longgetLong()Returns alongrepresentation of this value.java.io.InputStreamgetStream()Deprecated.As of JCR 2.0,getBinary()should be used instead.java.lang.StringgetString()Returns aStringrepresentation of this value.intgetType()Returns thetypeof thisValue.
-
-
-
Method Detail
-
getString
java.lang.String getString() throws ValueFormatException, java.lang.IllegalStateException, RepositoryExceptionReturns aStringrepresentation of this value.- Returns:
- A
Stringrepresentation of the value of this property. - Throws:
ValueFormatException- if conversion to aStringis not possible.java.lang.IllegalStateException- ifgetStreamhas previously been called on thisValueinstance. In this case a newValueinstance must be acquired in order to successfully call this method.RepositoryException- if another error occurs.
-
getStream
java.io.InputStream getStream() throws RepositoryExceptionDeprecated.As of JCR 2.0,getBinary()should be used instead.Returns anInputStreamrepresentation of this value. Uses the standard conversion to binary (see JCR specification).It is the responsibility of the caller to close the returned
InputStream.- Returns:
- An
InputStreamrepresentation of this value. - Throws:
RepositoryException- if an error occurs.
-
getBinary
Binary getBinary() throws RepositoryException
Returns aBinaryrepresentation of this value. TheBinaryobject in turn provides methods to access the binary data itself. Uses the standard conversion to binary (see JCR specification).- Returns:
- A
Binaryrepresentation of this value. - Throws:
RepositoryException- if an error occurs.- Since:
- JCR 2.0
-
getLong
long getLong() throws ValueFormatException, RepositoryExceptionReturns alongrepresentation of this value.- Returns:
- A
longrepresentation of this value. - Throws:
ValueFormatException- if conversion to anlongis not possible.RepositoryException- if another error occurs.
-
getDouble
double getDouble() throws ValueFormatException, RepositoryExceptionReturns adoublerepresentation of this value.- Returns:
- A
doublerepresentation of this value. - Throws:
ValueFormatException- if conversion to adoubleis not possible.RepositoryException- if another error occurs.
-
getDecimal
java.math.BigDecimal getDecimal() throws ValueFormatException, RepositoryExceptionReturns aBigDecimalrepresentation of this value.- Returns:
- A
BigDecimalrepresentation of this value. - Throws:
ValueFormatException- if conversion to aBigDecimalis not possible.RepositoryException- if another error occurs.- Since:
- JCR 2.0
-
getDate
java.util.Calendar getDate() throws ValueFormatException, RepositoryExceptionReturns aCalendarrepresentation of this value.The object returned is a copy of the stored value, so changes to it are not reflected in internal storage.
- Returns:
- A
Calendarrepresentation of this value. - Throws:
ValueFormatException- if conversion to aCalendaris not possible.RepositoryException- if another error occurs.
-
getBoolean
boolean getBoolean() throws ValueFormatException, RepositoryExceptionReturns aBooleanrepresentation of this value.- Returns:
- A
Booleanrepresentation of this value. - Throws:
ValueFormatException- if conversion to aBooleanis not possible.RepositoryException- if another error occurs.
-
getType
int getType()
Returns thetypeof thisValue. One of:PropertyType.STRINGPropertyType.DATEPropertyType.BINARYPropertyType.DOUBLEPropertyType.DECIMALPropertyType.LONGPropertyType.BOOLEANPropertyType.NAMEPropertyType.PATHPropertyType.REFERENCEPropertyType.WEAKREFERENCEPropertyType.URI
.PropertyTypeThe type returned is that which was set at property creation.
- Returns:
- an int
-
-