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 Detail

      • JCR_PRIMARY_TYPE

        static final java.lang.String JCR_PRIMARY_TYPE
        A constant for the property name jcr:primaryType (in expanded form), declared in node type nt:base.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_MIXIN_TYPES

        static final java.lang.String JCR_MIXIN_TYPES
        A constant for the property name jcr:mixinTypes (in expanded form), declared in node type nt:base.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CONTENT

        static final java.lang.String JCR_CONTENT
        A constant for the property name jcr:content (in expanded form), declared in node type nt:linkedFile. Note, jcr:content is also the name of a child node declared in nt:file.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_DATA

        static final java.lang.String JCR_DATA
        A constant for the property name jcr:data (in expanded form), declared in node type nt:resource.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_PROTOCOL

        static final java.lang.String JCR_PROTOCOL
        A constant for the property name jcr:protocol (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_HOST

        static final java.lang.String JCR_HOST
        A constant for the property name jcr:host (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_PORT

        static final java.lang.String JCR_PORT
        A constant for the property name jcr:port (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_REPOSITORY

        static final java.lang.String JCR_REPOSITORY
        A constant for the property name jcr:repository (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_WORKSPACE

        static final java.lang.String JCR_WORKSPACE
        A constant for the property name jcr:workspace (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_PATH

        static final java.lang.String JCR_PATH
        A constant for the property name jcr:path (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_ID

        static final java.lang.String JCR_ID
        A constant for the property name jcr:id (in expanded form), declared in node type nt:address.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_UUID

        static final java.lang.String JCR_UUID
        A constant for the property name jcr:uuid (in expanded form), declared in node type mix:referenceable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_TITLE

        static final java.lang.String JCR_TITLE
        A constant for the property name jcr:title (in expanded form), declared in node types mix:title and nt:activity.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_DESCRIPTION

        static final java.lang.String JCR_DESCRIPTION
        A constant for the property name jcr:description (in expanded form), declared in node type mix:title.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CREATED

        static final java.lang.String JCR_CREATED
        A constant for the property name jcr:created (in expanded form), declared in node types mix:created and nt:version.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CREATED_BY

        static final java.lang.String JCR_CREATED_BY
        A constant for the property name jcr:createdBy (in expanded form), declared in node type mix:created.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_LAST_MODIFIED

        static final java.lang.String JCR_LAST_MODIFIED
        A constant for the property name jcr:lastModified (in expanded form), declared in node type mix:lastModified.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_LAST_MODIFIED_BY

        static final java.lang.String JCR_LAST_MODIFIED_BY
        A constant for the property name jcr:lastModifiedBy (in expanded form), declared in node type mix:lastModified.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_LANGUAGE

        static final java.lang.String JCR_LANGUAGE
        A constant for the property name jcr:language (in expanded form), declared in node types mix:language and nt:query.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_MIMETYPE

        static final java.lang.String JCR_MIMETYPE
        A constant for the property name jcr:mimeType (in expanded form), declared in node type mix:mimeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_ENCODING

        static final java.lang.String JCR_ENCODING
        A constant for the property name jcr:encoding (in expanded form), declared in node type mix:mimeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_NODE_TYPE_NAME

        static final java.lang.String JCR_NODE_TYPE_NAME
        A constant for the property name jcr:nodeTypeName (in expanded form), declared in node type nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_SUPERTYPES

        static final java.lang.String JCR_SUPERTYPES
        A constant for the property name jcr:supertypes (in expanded form), declared in node type nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_IS_ABSTRACT

        static final java.lang.String JCR_IS_ABSTRACT
        A constant for the property name jcr:isAbstract (in expanded form), declared in node type nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_IS_MIXIN

        static final java.lang.String JCR_IS_MIXIN
        A constant for the property name jcr:isMixin (in expanded form), declared in node type nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_HAS_ORDERABLE_CHILD_NODES

        static final java.lang.String JCR_HAS_ORDERABLE_CHILD_NODES
        A constant for the property name jcr:hasOrderableChildNodes (in expanded form), declared in node type nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_PRIMARY_ITEM_NAME

        static final java.lang.String JCR_PRIMARY_ITEM_NAME
        A constant for the property name jcr:primaryItemName (in expanded form), declared in node type nt:nodeType.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_REQUIRED_TYPE

        static final java.lang.String JCR_REQUIRED_TYPE
        A constant for the property name jcr:requiredType (in expanded form), declared in node type nt:propertyDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_VALUE_CONSTRAINTS

        static final java.lang.String JCR_VALUE_CONSTRAINTS
        A constant for the property name jcr:valueConstraints (in expanded form), declared in node type nt:propertyDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_DEFAULT_VALUES

        static final java.lang.String JCR_DEFAULT_VALUES
        A constant for the property name jcr:defaultValues (in expanded form), declared in node type nt:propertyDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_MULTIPLE

        static final java.lang.String JCR_MULTIPLE
        A constant for the property name jcr:multiple (in expanded form), declared in node type nt:propertyDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_REQUIRED_PRIMARY_TYPES

        static final java.lang.String JCR_REQUIRED_PRIMARY_TYPES
        A constant for the property name jcr:requiredPrimaryTypes (in expanded form), declared in node type nt:childNodeDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_DEFAULT_PRIMARY_TYPE

        static final java.lang.String JCR_DEFAULT_PRIMARY_TYPE
        A constant for the property name jcr:defaultPrimaryType (in expanded form), declared in node type nt:childNodeDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_SAME_NAME_SIBLINGS

        static final java.lang.String JCR_SAME_NAME_SIBLINGS
        A constant for the property name jcr:sameNameSiblings (in expanded form), declared in node type nt:childNodeDefinition.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_LOCK_OWNER

        static final java.lang.String JCR_LOCK_OWNER
        A constant for the property name jcr:lockOwner (in expanded form), declared in node type mix:lockable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_LOCK_IS_DEEP

        static final java.lang.String JCR_LOCK_IS_DEEP
        A constant for the property name jcr:lockIsDeep (in expanded form), declared in node type mix:lockable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_LIFECYCLE_POLICY

        static final java.lang.String JCR_LIFECYCLE_POLICY
        A constant for the property name jcr:lifecyclePolicy (in expanded form), declared in node type mix:lifecycle.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CURRENT_LIFECYCLE_STATE

        static final java.lang.String JCR_CURRENT_LIFECYCLE_STATE
        A constant for the property name jcr:currentLifecycleState (in expanded form), declared in node type mix:lifecycle.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_IS_CHECKED_OUT

        static final java.lang.String JCR_IS_CHECKED_OUT
        A constant for the property name jcr:isCheckedOut (in expanded form), declared in node type mix:simpleVersionable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_FROZEN_PRIMARY_TYPE

        static final java.lang.String JCR_FROZEN_PRIMARY_TYPE
        A constant for the property name jcr:frozenPrimaryType (in expanded form), declared in node type nt:frozenNode.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_FROZEN_MIXIN_TYPES

        static final java.lang.String JCR_FROZEN_MIXIN_TYPES
        A constant for the property name jcr:frozenMixinTypes (in expanded form), declared in node type nt:frozenNode.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_FROZEN_UUID

        static final java.lang.String JCR_FROZEN_UUID
        A constant for the property name jcr:frozenUuid (in expanded form), declared in node type nt:frozenNode.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_VERSION_HISTORY

        static final java.lang.String JCR_VERSION_HISTORY
        A constant for the property name jcr:versionHistory (in expanded form), declared in node type mix:versionable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_BASE_VERSION

        static final java.lang.String JCR_BASE_VERSION
        A constant for the property name jcr:baseVersion (in expanded form), declared in node type mix:versionable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_PREDECESSORS

        static final java.lang.String JCR_PREDECESSORS
        A constant for the property name jcr:predecessors (in expanded form), declared in node types mix:versionable and nt:version.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_MERGE_FAILED

        static final java.lang.String JCR_MERGE_FAILED
        A constant for the property name jcr:mergeFailed (in expanded form), declared in node type mix:versionable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CONFIGURATION

        static final java.lang.String JCR_CONFIGURATION
        A constant for the property name jcr:configuration (in expanded form), declared in node type mix:versionable.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_VERSIONABLE_UUID

        static final java.lang.String JCR_VERSIONABLE_UUID
        A constant for the property name jcr:versionableUuid (in expanded form), declared in node type nt:version.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_COPIED_FROM

        static final java.lang.String JCR_COPIED_FROM
        A constant for the property name jcr:copiedFrom (in expanded form), declared in node type nt:version.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_SUCCESSORS

        static final java.lang.String JCR_SUCCESSORS
        A constant for the property name jcr:successors (in expanded form), declared in node type nt:versione.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_CHILD_VERSION_HISTORY

        static final java.lang.String JCR_CHILD_VERSION_HISTORY
        A constant for the property name jcr:childVersionHistory (in expanded form), declared in node type nt:versionedChild.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_ROOT

        static final java.lang.String JCR_ROOT
        A constant for the property name jcr:root (in expanded form), declared in node type nt:configuration.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
      • JCR_STATEMENT

        static final java.lang.String JCR_STATEMENT
        A constant for the property name jcr:statement (in expanded form), declared in node type nt:query.
        Since:
        JCR 2.0
        See Also:
        Constant Field Values
    • Method Detail

      • setValue

        void setValue​(Value value)
               throws ValueFormatException,
                      VersionException,
                      LockException,
                      ConstraintViolationException,
                      RepositoryException
        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

        void setValue​(Value[] values)
               throws ValueFormatException,
                      VersionException,
                      LockException,
                      ConstraintViolationException,
                      RepositoryException
        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.
      • getValues

        Value[] getValues()
                   throws ValueFormatException,
                          RepositoryException
        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

        java.lang.String getString()
                            throws ValueFormatException,
                                   RepositoryException
        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:
        Value
      • getStream

        java.io.InputStream getStream()
                               throws ValueFormatException,
                                      RepositoryException
        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:
        Value
      • 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:
        Value
      • getDecimal

        java.math.BigDecimal getDecimal()
                                 throws ValueFormatException,
                                        RepositoryException
        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:
        Value
      • getDate

        java.util.Calendar getDate()
                            throws ValueFormatException,
                                   RepositoryException
        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:
        Value
      • 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:
        Value
      • getNode

        Node getNode()
              throws ItemNotFoundException,
                     ValueFormatException,
                     RepositoryException
        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

        Property getProperty()
                      throws ItemNotFoundException,
                             ValueFormatException,
                             RepositoryException
        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:
        NodeType.getPropertyDefinitions()
      • 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.