Package javax.jcr

Interface Property

All Superinterfaces:
Item
All Known Implementing Classes:
AbstractProperty

public interface Property extends Item
A Property object represents the smallest granularity of content storage. It has a single parent node and no children. A property consists of a name and a value, or in the case of multi-value properties, a set of values all of the same type. See Value.
  • Field Details

  • Method Details

    • setValue

      Sets the value of this property to value. If this property's property type is not constrained by the node type of its parent node, then the property type is changed to that of the supplied value. If the property type is constrained, then a best-effort conversion is attempted.

      This method is a session-write and therefore requires a save to dispatch the change.

      A ConstraintViolationException will be thrown either immediately, on dispatch, or on persist, if the change would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.

      A VersionException will be thrown either immediately, on dispatch, or on persist, if this property belongs to a node that is versionable and checked-in or is non-versionable but whose nearest versionable ancestor is checked-in. Implementations may differ on when this validation is performed.

      A LockException will be thrown either immediately, on dispatch, or on persist, if a lock prevents the setting of the value. Implementations may differ on when this validation is performed.

      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to the values array. If this property's property type is not constrained by the node type of its parent node, then the property type may be changed. If the property type is constrained, then a best-effort conversion is attempted, according to an implemention-dependent definition of "best effort". The change will be persisted (if valid) on save.

      A ConstraintViolationException will be thrown either immediately, on dispatch, or on persist, if the change would violate a node type or implementation-specific constraint. Implementations may differ on when this validation is performed.

      A VersionException will be thrown either immediately, on dispatch, or on persist, if this property belongs to a node that is read-only due to a checked-in node. Implementations may differ on when this validation is performed.

      A LockException will be thrown either immediately, on dispatch, or on persist, if a lock prevents the setting of the value. Implementations may differ on when this validation is performed.

      Parameters:
      values - The new values to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified values is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a String.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified values is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to the values array. Same as setValue(Value[] values) except that the values are specified as a String[].
      Parameters:
      values - The new values to set the property to.
      Throws:
      ValueFormatException - if the type or format of one or more of the specified values is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Deprecated.
      As of JCR 2.0, setValue(Binary) should be used instead.
      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as an InputStream.

      The passed stream is closed before this method returns either normally or because of an exception.

      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a Binary.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
      Since:
      JCR 2.0
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a long.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a double.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a BigDecimal.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
      Since:
      JCR 2.0
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a Calendar.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets the value of this property to value. Same as setValue(Value value) except that the value is specified as a boolean.
      Parameters:
      value - The new value to set the property to.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • setValue

      Sets this REFERENCE or WEAKREFERNCE property to refer to the specified node.
      Parameters:
      value - The node to which this property will refer.
      Throws:
      ValueFormatException - if the type or format of the specified value is incompatible with the type of this property the specified node is not referenceable.
      VersionException - if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately.
      LockException - if a lock prevents the setting of the value and this implementation performs this validation immediately.
      ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
      RepositoryException - if another error occurs.
    • getValue

      Returns the value of this property as a Value object.

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

      Returns:
      the Value.
      Throws:
      ValueFormatException - if the property is multi-valued.
      RepositoryException - if another error occurs.
    • getValues

      Returns an array of all the values of this property. Used to access multi-value properties. The array returned is a copy of the stored values, so changes to it are not reflected in internal storage.
      Returns:
      a Value array.
      Throws:
      ValueFormatException - if the property is single-valued.
      RepositoryException - if another error occurs.
    • getString

      Returns a String representation of the value of this property. A shortcut for Property.getValue().getString().
      Returns:
      A string representation of the value of this property.
      Throws:
      ValueFormatException - if conversion to a String is not possible or if the property is multi-valued.
      RepositoryException - if another error occurs.
      See Also:
    • getStream

      Deprecated.
      As of JCR 2.0, getBinary() should be used instead.
      Returns an InputStream representation of the value of this property. A shortcut for Property.getValue().getStream().

      It is the responsibility of the caller to close the returned InputStream.

      Returns:
      A stream representation of the value of this property.
      Throws:
      ValueFormatException - if the property is multi-valued.
      RepositoryException - if another error occurs
      See Also:
    • getBinary

      Returns a Binary representation of the value of this property. A shortcut for Property.getValue().getBinary().
      Returns:
      A Binary representation of the value of this property.
      Throws:
      ValueFormatException - if the property is multi-valued.
      RepositoryException - if another error occurs.
      Since:
      JCR 2.0
      See Also:
    • getLong

      Returns a long representation of the value of this property. A shortcut for Property.getValue().getLong().
      Returns:
      A long representation of the value of this property.
      Throws:
      ValueFormatException - if conversion to a long is not possible or if the property is multi-valued.
      RepositoryException - if another error occurs.
      See Also:
    • getDouble

      double getDouble() throws ValueFormatException, RepositoryException
      Returns a double representation of the value of this property. A shortcut for Property.getValue().getDouble().
      Returns:
      A double representation of the value of this property.
      Throws:
      ValueFormatException - if conversion to a double is not possible or if the property is multi-valued.
      RepositoryException - if another error occurs.
      See Also:
    • getDecimal

      Returns a BigDecimal representation of the value of this property. A shortcut for Property.getValue().getDecimal().
      Returns:
      A BigDecimal representation of the value of this property.
      Throws:
      ValueFormatException - if conversion to a BigDecimal is not possible or if the property is multi-valued.
      RepositoryException - if another error occurs
      Since:
      JCR 2.0
      See Also:
    • getDate

      Returns a Calendar representation of the value of this property. A shortcut for Property.getValue().getDate().
      Returns:
      A Calendar representation of the value of this property.
      Throws:
      ValueFormatException - if conversion to a string is not possible or if the property is multi-valued.
      RepositoryException - if another error occurs.
      See Also:
    • getBoolean

      boolean getBoolean() throws ValueFormatException, RepositoryException
      Returns a boolean representation of the value of this property. A shortcut for Property.getValue().getBoolean().
      Returns:
      A boolean representation of the value of this property.
      Throws:
      ValueFormatException - if conversion to a boolean is not possible or if the property is multi-valued.
      RepositoryException - if another error occurs.
      See Also:
    • getNode

      If this property is of type REFERENCE, WEAKREFERENCE or PATH (or convertible to one of these types) this method returns the Node to which this property refers.

      If this property is of type PATH and it contains a relative path, it is interpreted relative to the parent node of this property. For example "." refers to the parent node itself, ".." to the parent of the parent node and "foo" to a sibling node of this property.

      Returns:
      the referenced Node
      Throws:
      ValueFormatException - if this property cannot be converted to a referring type (REFERENCE, WEAKREFERENCE or PATH), if the property is multi-valued or if this property is a referring type but is currently part of the frozen state of a version in version storage.
      ItemNotFoundException - If this property is of type PATH or WEAKREFERENCE and no target node accessible by the current Session exists in this workspace. Note that this applies even if the property is a PATHS and a property exists at the specified location. To dereference to a target property (as opposed to a target node), the method Property.getProperty is used.
      RepositoryException - if another error occurs.
    • getProperty

      If this property is of type PATH (or convertible to this type) this method returns the Property to which this property refers.

      If this property contains a relative path, it is interpreted relative to the parent node of this property. Therefore, when resolving such a relative path, the segment "." refers to the parent node itself, ".." to the parent of the parent node and "foo" to a sibling property of this property or this property itself.

      For example, if this property is located at /a/b/c and it has a value of "../d" then this method will return the property at /a/d if such exists.

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

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

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

      Returns:
      the referenced property
      Throws:
      ValueFormatException - if this property cannot be converted to a PATH, if the property is multi-valued or if this property is a referring type but is currently part of the frozen state of a version in version storage.
      ItemNotFoundException - If no property accessible by the current Session exists in this workspace at the specified path. Note that this applies even if a node exists at the specified location. To dereference to a target node, the method Property.getNode is used.
      RepositoryException - if another error occurs.
      Since:
      JCR 2.0
    • getLength

      long getLength() throws ValueFormatException, RepositoryException
      Returns the length of the value of this property.

      For a BINARY property, getLength returns the number of bytes. For other property types, getLength returns the same value that would be returned by calling String.length() on the value when it has been converted to a STRING according to standard JCR property type conversion.

      Returns -1 if the implementation cannot determine the length.

      Returns:
      an long.
      Throws:
      ValueFormatException - if this property is multi-valued.
      RepositoryException - if another error occurs.
    • getLengths

      long[] getLengths() throws ValueFormatException, RepositoryException
      Returns an array holding the lengths of the values of this (multi-value) property in bytes where each is individually calculated as described in getLength().

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

      Returns:
      an array of lengths
      Throws:
      ValueFormatException - if this property is single-valued.
      RepositoryException - if another error occurs.
    • getDefinition

      PropertyDefinition getDefinition() throws RepositoryException
      Returns the property definition that applies to this property. In some cases there may appear to be more than one definition that could apply to this node. However, it is assumed that upon creation or change of this property, a single particular definition is chosen by the implementation. It is that definition that this method returns. How this governing definition is selected upon property creation or change from among others which may have been applicable is an implementation issue and is not covered by this specification.
      Returns:
      a PropertyDefinition object.
      Throws:
      RepositoryException - if an error occurs.
      See Also:
    • getType

      int getType() throws RepositoryException
      Returns the type of this Property. One of:
      • PropertyType.STRING
      • PropertyType.BINARY
      • PropertyType.DATE
      • PropertyType.DOUBLE
      • PropertyType.LONG
      • PropertyType.BOOLEAN
      • PropertyType.NAME
      • PropertyType.PATH
      • PropertyType.REFERENCE
      • PropertyType.WEAKREFERENCE
      • PropertyType.URI
      The type returned is that which was set at property creation. Note that for some property p, the type returned by p.getType() will 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).
      Returns:
      an int
      Throws:
      RepositoryException - if an error occurs
    • isMultiple

      boolean isMultiple() throws RepositoryException
      Returns true if this property is multi-valued and false if this property is single-valued.
      Returns:
      true if this property is multi-valued; false otherwise.
      Throws:
      RepositoryException - if an error occurs.