javax.jcr
Interface Value


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.).

Any implementation of this interface must adhere to the following behavior:

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

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.


Method Summary
 boolean getBoolean()
          Returns a Boolean representation of this value.
 java.util.Calendar getDate()
          Returns a Calendar representation of this value.
 double getDouble()
          Returns a double representation of this value.
 long getLong()
          Returns a long representation of this value.
 java.io.InputStream getStream()
          Returns an InputStream representation of this value.
 java.lang.String getString()
          Returns a String representation of this value.
 int getType()
          Returns the type of this Value.
 

Method Detail

getString

public java.lang.String getString()
                           throws ValueFormatException,
                                  java.lang.IllegalStateException,
                                  RepositoryException
Returns a String representation of this value.

If this value cannot be converted to a string, a ValueFormatException is thrown.

If getStream has previously been called on this Value instance, an IllegalStateException is thrown. In this case a new Value instance must be acquired in order to successfully call getString.

A RepositoryException is thrown if another error occurs.

Returns:
A String representation of the value of this property.
Throws:
ValueFormatException - if conversion to a String is not possible.
java.lang.IllegalStateException - if getStream has previously been called on this Value instance.
RepositoryException - if another error occurs.

getStream

public java.io.InputStream getStream()
                              throws java.lang.IllegalStateException,
                                     RepositoryException
Returns an InputStream representation of this value. Uses the standard conversion to binary (see JCR specification)

If a non-stream get method has previously been called on this Value instance, an IllegalStateException is thrown. In this case a new Value instance must be acquired in order to successfully call getStream.

A RepositoryException is thrown if another error occurs.

Returns:
An InputStream representation of this value.
Throws:
java.lang.IllegalStateException - if a non-stream get method has previously been called on this Value instance.
RepositoryException - if another error occurs.

getLong

public long getLong()
             throws ValueFormatException,
                    java.lang.IllegalStateException,
                    RepositoryException
Returns a long representation of this value.

If this value cannot be converted to a long, a ValueFormatException is thrown.

If getStream has previously been called on this Value instance, an IllegalStateException is thrown. In this case a new Value instance must be acquired in order to successfully call getLong.

A RepositoryException is thrown if another error occurs.

Returns:
A long representation of this value.
Throws:
ValueFormatException - if conversion to an long is not possible.
java.lang.IllegalStateException - if getStream has previously been called on this Value instance.
RepositoryException - if another error occurs.

getDouble

public double getDouble()
                 throws ValueFormatException,
                        java.lang.IllegalStateException,
                        RepositoryException
Returns a double representation of this value.

If this value cannot be converted to a double, a ValueFormatException is thrown.

If getStream has previously been called on this Value instance, an IllegalStateException is thrown. In this case a new Value instance must be acquired in order to successfully call getDouble.

A RepositoryException is thrown if another error occurs.

Returns:
A double representation of this value.
Throws:
ValueFormatException - if conversion to a double is not possible.
java.lang.IllegalStateException - if getStream has previously been called on this Value instance.
RepositoryException - if another error occurs.

getDate

public java.util.Calendar getDate()
                           throws ValueFormatException,
                                  java.lang.IllegalStateException,
                                  RepositoryException
Returns a 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.

If this value cannot be converted to a Calendar, a ValueFormatException is thrown.

If getStream has previously been called on this Value instance, an IllegalStateException is thrown. In this case a new Value instance must be acquired in order to successfully call getDate.

A RepositoryException is thrown if another error occurs.

Returns:
A Calendar representation of this value.
Throws:
ValueFormatException - if conversion to a Calendar is not possible.
java.lang.IllegalStateException - if getStream has previously been called on this Value instance.
RepositoryException - if another error occurs.

getBoolean

public boolean getBoolean()
                   throws ValueFormatException,
                          java.lang.IllegalStateException,
                          RepositoryException
Returns a Boolean representation of this value.

If this value cannot be converted to a Boolean, a ValueFormatException is thrown.

If getStream has previously been called on this Value instance, an IllegalStateException is thrown. In this case a new Value instance must be acquired in order to successfully call getBoolean.

A RepositoryException is thrown if another error occurs.

Returns:
A Boolean representation of this value.
Throws:
ValueFormatException - if conversion to a Boolean is not possible.
java.lang.IllegalStateException - if getStream has previously been called on this Value instance.
RepositoryException - if another error occurs.

getType

public int getType()
Returns the type of this Value. One of: See PropertyType.

The type returned is that which was set at property creation.



Copyright © 2004-2005 Day Software Management AG. All Rights Reserved.