Class AbstractProperty

java.lang.Object
org.apache.jackrabbit.commons.AbstractItem
org.apache.jackrabbit.commons.AbstractProperty
All Implemented Interfaces:
Item, Property

public abstract class AbstractProperty extends AbstractItem implements Item, Property
Abstract base class for implementing the JCR Property interface.

Item methods without a default implementation:

Property methods without a default implementation:

NOTE: Many of the default method implementations in this base class rely on the parent node being accessible through the Item.getParent() call. It is possible (though unlikely) that access controls deny access to a containing node even though a property is accessible. In such cases the default method implementations in this class will not work.

  • Constructor Details

    • AbstractProperty

      public AbstractProperty()
  • Method Details

    • accept

      public void accept(ItemVisitor visitor) throws RepositoryException
      Accepts the given item visitor.

      The default implementation calls ItemVisitor.visit(Property) on the given visitor with this property as the argument.

      Specified by:
      accept in interface Item
      Parameters:
      visitor - item visitor
      Throws:
      RepositoryException - if an error occurs
    • getPath

      public String getPath() throws RepositoryException
      Returns the path of this property.

      The default implementation constructs the path from the path of the parent node and the name of this property.

      Specified by:
      getPath in interface Item
      Returns:
      property path
      Throws:
      RepositoryException - if an error occurs
    • isNode

      public boolean isNode()
      Returns false.
      Specified by:
      isNode in interface Item
      Returns:
      false
    • remove

      public void remove() throws RepositoryException
      Removes this property.

      The default implementation calls Node.setProperty(String, Value) with a null value on the parent node.

      Specified by:
      remove in interface Item
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getBoolean

      public boolean getBoolean() throws RepositoryException
      Returns the boolean value of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getBoolean in interface Property
      Returns:
      boolean value
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getDate

      public Calendar getDate() throws RepositoryException
      Returns the date value of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getDate in interface Property
      Returns:
      date value
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getDouble

      public double getDouble() throws RepositoryException
      Returns the double value of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getDouble in interface Property
      Returns:
      double value
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getLength

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

      The default implementation measures the length of the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getLength in interface Property
      Returns:
      length of the property value
      Throws:
      RepositoryException - if an error occurs
    • getLengths

      public long[] getLengths() throws RepositoryException
      Returns the lengths of the values of this property.

      The default implementation measures the lengths of the Value instances returned by the generic Property.getValues() method.

      Specified by:
      getLengths in interface Property
      Returns:
      lengths of the property values
      Throws:
      RepositoryException - if an error occurs
    • getLong

      public long getLong() throws RepositoryException
      Returns the long value of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getLong in interface Property
      Returns:
      long value
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getNode

      public Node getNode() throws 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.

      Specified by:
      getNode in interface 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

      public Property getProperty() throws 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.

      Specified by:
      getProperty in interface Property
      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.
    • getStream

      public InputStream getStream() throws RepositoryException
      Returns the binary value of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getStream in interface Property
      Returns:
      binary value
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getString

      public String getString() throws RepositoryException
      Returns the string value of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getString in interface Property
      Returns:
      string value
      Throws:
      RepositoryException - if an error occurs
      See Also:
    • getType

      public int getType() throws RepositoryException
      Returns the type of this property.

      The default implementation forwards the method call to the Value instance returned by the generic Property.getValue() method.

      Specified by:
      getType in interface Property
      Returns:
      property type
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(Value value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, Value) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(Value[] values) throws RepositoryException
      Sets the values of this property.

      The default implementation forwards the call to the Node.setProperty(String, Value[]) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      values - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(String value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, String) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(String[] values) throws RepositoryException
      Sets the values of this property.

      The default implementation forwards the call to the Node.setProperty(String, String[]) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      values - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(InputStream value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, InputStream) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(long value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, long) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(double value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, double) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(Calendar value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, Calendar) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(boolean value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, boolean) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs
    • setValue

      public void setValue(Node value) throws RepositoryException
      Sets the value of this property.

      The default implementation forwards the call to the Node.setProperty(String, Node) method of the parent node using the name of this property.

      Specified by:
      setValue in interface Property
      Parameters:
      value - passed through
      Throws:
      RepositoryException - if an error occurs