6.2.4 Property Read Methods

The following are the level 1 methods of Property. They are used for reading a property. The Property interface has other methods as well, though in a level 1-only implementation they will either do nothing or throw an exception.

javax.jcr.
Property

Value

getValue()

Returns the value of this property as a Value object.

If this property is multi-valued, this method throws a ValueFormatException.

The object returned is a copy of the stored value and is immutable.

A RepositoryException is thrown if an error occurs.

Value[]

getValues()

Returns an array of all the values of this property. This method is used to access multi-value properties.

If the property is single-valued, this method throws a ValueFormatException.

The array returned is a copy of the stored values, so changes to it are not reflected in internal storage.

A RepositoryException is thrown if an error occurs.

String

getString()

Returns a String representation of the value of this property. A shortcut for Property.getValue().getString(). See 6.2.7 Value.

If this property is multi-valued, this method throws a ValueFormatException.

If the value of this property cannot be converted to a String, a ValueFormatException is thrown.

A RepositoryException is thrown if another error occurs.

InputStream

getStream()

Returns an InputStream representation of the value of this property. A shortcut for Property.getValue().getStream(). See 6.2.7 Value.

If this property is multi-valued, this method throws a ValueFormatException.

A RepositoryException is thrown if another error occurs.

long

getLong()

Returns a long representation of the value of this property. A shortcut for Property.getValue().getLong(). See 6.2.7 Value.

If this property is multi-valued, this method throws a ValueFormatException.

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

A RepositoryException is thrown if another error occurs.

double

getDouble()

Returns a double representation of the value of this property. A shortcut for Property.getValue().getDouble(). See 6.2.7 Value.

If this property is multi-valued, this method throws a ValueFormatException.

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

A RepositoryException is thrown if another error occurs.

Calendar

getDate()

Returns a Calendar representation of the value of this property. A shortcut for Property.getValue().getDate() See 6.2.7 Value.

The object returned is a copy of the stored value, so changes to it are not reflected in internal storage.

If this property is multi-valued, this method throws a ValueFormatException.

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

A RepositoryException is thrown if another error occurs.

boolean

getBoolean()

Returns a boolean representation of the value of this property. A shortcut for Property.getValue().getBoolean(). See 6.2.7 Value.

If this property is multi-valued, this method throws a ValueFormatException.

If the value of this property cannot be converted to a boolean, a ValueFormatException is thrown.

A RepositoryException is thrown if another error occurs.

Item

getNode()

If this property is of type REFERENCE this method returns the Node to which this property refers.

If this property is multi-valued, this method throws a ValueFormatException.

If this property cannot be converted to a reference, then a ValueFormatException is thrown.

If this property is a REFERENCE property but is currently part of the frozen state of a version in version storage, this method will throw a ValueFormatException.

A RepositoryException is thrown if another error occurs.

long

getLength()

Returns the length of the value of this property in bytes if the value is a PropertyType.BINARY, otherwise it returns the number of characters needed to display the value in its string form as defined in 6.2.6 Property Type Conversion.

Returns –1 if the implementation cannot determine the length of the value.

If this property is multi-valued, this method throws a ValueFormatException.

A RepositoryException is thrown if another error occurs.

long[]

getLengths()

Returns an array holding the lengths of the values of this (multi-value) property in bytes if the values are PropertyType.BINARY, otherwise it returns the number of characters needed to display each value in its string form as defined in 6.2.6 Property Type Conversion). The order of the length values corresponds to the order of the values in the property.

Returns a –1 in the appropriate position if the implementation cannot determine the length of a value.

If this property is single-valued, this method throws a ValueFormatException.

A RepositoryException is thrown if another error occurs.

int

getType()

Returns the type of this Property. The type returned is that which was set at property creation. Note that for some property p, the type returned by p.getType() may differ from the type returned by p.getDefinition.getRequiredType() only in the case where the latter returns UNDEFINED. The type of a property instance is never UNDEFINED (it must always have some actual type). See 6.2.5 Property Types and 6.7.18 Discovery of Constraints on Existing Items.