Class AbstractProperty
- java.lang.Object
-
- org.apache.jackrabbit.commons.AbstractItem
-
- org.apache.jackrabbit.commons.AbstractProperty
-
- All Implemented Interfaces:
javax.jcr.Item
,javax.jcr.Property
public abstract class AbstractProperty extends AbstractItem implements javax.jcr.Item, javax.jcr.Property
Abstract base class for implementing the JCRProperty
interface.Item
methods without a default implementation:Item.getName()
Item.getParent()
Item.getSession()
Item.isModified()
Item.isNew()
Item.isSame(Item)
Item.refresh(boolean)
Item.save()
Property
methods without a default implementation:Property.getDefinition()
Property.getValue()
Property.getValues()
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.
-
-
Field Summary
-
Fields inherited from interface javax.jcr.Property
JCR_ACTIVITY, JCR_AUTOCREATED, JCR_BASE_VERSION, JCR_CHILD_VERSION_HISTORY, JCR_CONFIGURATION, JCR_CONTENT, JCR_COPIED_FROM, JCR_CREATED, JCR_CREATED_BY, JCR_CURRENT_LIFECYCLE_STATE, JCR_DATA, JCR_DEFAULT_PRIMARY_TYPE, JCR_DEFAULT_VALUES, JCR_DESCRIPTION, JCR_ENCODING, JCR_FROZEN_MIXIN_TYPES, JCR_FROZEN_PRIMARY_TYPE, JCR_FROZEN_UUID, JCR_HAS_ORDERABLE_CHILD_NODES, JCR_HOST, JCR_ID, JCR_IS_ABSTRACT, JCR_IS_CHECKED_OUT, JCR_IS_MIXIN, JCR_LANGUAGE, JCR_LAST_MODIFIED, JCR_LAST_MODIFIED_BY, JCR_LIFECYCLE_POLICY, JCR_LOCK_IS_DEEP, JCR_LOCK_OWNER, JCR_MANDATORY, JCR_MERGE_FAILED, JCR_MIMETYPE, JCR_MIXIN_TYPES, JCR_MULTIPLE, JCR_NAME, JCR_NODE_TYPE_NAME, JCR_ON_PARENT_VERSION, JCR_PATH, JCR_PORT, JCR_PREDECESSORS, JCR_PRIMARY_ITEM_NAME, JCR_PRIMARY_TYPE, JCR_PROTECTED, JCR_PROTOCOL, JCR_REPOSITORY, JCR_REQUIRED_PRIMARY_TYPES, JCR_REQUIRED_TYPE, JCR_ROOT, JCR_SAME_NAME_SIBLINGS, JCR_STATEMENT, JCR_SUCCESSORS, JCR_SUPERTYPES, JCR_TITLE, JCR_UUID, JCR_VALUE_CONSTRAINTS, JCR_VERSION_HISTORY, JCR_VERSIONABLE_UUID, JCR_WORKSPACE
-
-
Constructor Summary
Constructors Constructor Description AbstractProperty()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(javax.jcr.ItemVisitor visitor)
Accepts the given item visitor.boolean
getBoolean()
Returns the boolean value of this property.java.util.Calendar
getDate()
Returns the date value of this property.double
getDouble()
Returns the double value of this property.long
getLength()
Returns the length of the value of this property.long[]
getLengths()
Returns the lengths of the values of this property.long
getLong()
Returns the long value of this property.javax.jcr.Node
getNode()
If this property is of typeREFERENCE
,WEAKREFERENCE
orPATH
(or convertible to one of these types) this method returns theNode
to which this property refers.java.lang.String
getPath()
Returns the path of this property.javax.jcr.Property
getProperty()
If this property is of typePATH
(or convertible to this type) this method returns theProperty
to which this property refers.java.io.InputStream
getStream()
Returns the binary value of this property.java.lang.String
getString()
Returns the string value of this property.int
getType()
Returns the type of this property.boolean
isNode()
Returnsfalse
.void
remove()
Removes this property.void
setValue(boolean value)
Sets the value of this property.void
setValue(double value)
Sets the value of this property.void
setValue(long value)
Sets the value of this property.void
setValue(java.io.InputStream value)
Sets the value of this property.void
setValue(java.lang.String value)
Sets the value of this property.void
setValue(java.lang.String[] values)
Sets the values of this property.void
setValue(java.util.Calendar value)
Sets the value of this property.void
setValue(javax.jcr.Node value)
Sets the value of this property.void
setValue(javax.jcr.Value value)
Sets the value of this property.void
setValue(javax.jcr.Value[] values)
Sets the values of this property.-
Methods inherited from class org.apache.jackrabbit.commons.AbstractItem
getAncestor, getDepth, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
accept
public void accept(javax.jcr.ItemVisitor visitor) throws javax.jcr.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 interfacejavax.jcr.Item
- Parameters:
visitor
- item visitor- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getPath
public java.lang.String getPath() throws javax.jcr.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 interfacejavax.jcr.Item
- Returns:
- property path
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
isNode
public boolean isNode()
Returnsfalse
.- Specified by:
isNode
in interfacejavax.jcr.Item
- Returns:
false
-
remove
public void remove() throws javax.jcr.RepositoryException
Removes this property.The default implementation calls
Node.setProperty(String, Value)
with anull
value on the parent node.- Specified by:
remove
in interfacejavax.jcr.Item
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getBoolean
public boolean getBoolean() throws javax.jcr.RepositoryException
Returns the boolean value of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getBoolean
in interfacejavax.jcr.Property
- Returns:
- boolean value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getDate
public java.util.Calendar getDate() throws javax.jcr.RepositoryException
Returns the date value of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getDate
in interfacejavax.jcr.Property
- Returns:
- date value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getDouble
public double getDouble() throws javax.jcr.RepositoryException
Returns the double value of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getDouble
in interfacejavax.jcr.Property
- Returns:
- double value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getLength
public long getLength() throws javax.jcr.RepositoryException
Returns the length of the value of this property.The default implementation measures the length of the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getLength
in interfacejavax.jcr.Property
- Returns:
- length of the property value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getLengths
public long[] getLengths() throws javax.jcr.RepositoryException
Returns the lengths of the values of this property.The default implementation measures the lengths of the
Value
instances returned by the genericProperty.getValues()
method.- Specified by:
getLengths
in interfacejavax.jcr.Property
- Returns:
- lengths of the property values
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getLong
public long getLong() throws javax.jcr.RepositoryException
Returns the long value of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getLong
in interfacejavax.jcr.Property
- Returns:
- long value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getNode
public javax.jcr.Node getNode() throws javax.jcr.ValueFormatException, javax.jcr.RepositoryException
If this property is of typeREFERENCE
,WEAKREFERENCE
orPATH
(or convertible to one of these types) this method returns theNode
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 interfacejavax.jcr.Property
- Returns:
- the referenced Node
- Throws:
javax.jcr.ValueFormatException
- if this property cannot be converted to a referring type (REFERENCE
,WEAKREFERENCE
orPATH
), 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.javax.jcr.ItemNotFoundException
- If this property is of typePATH
orWEAKREFERENCE
and no target node accessible by the currentSession
exists in this workspace. Note that this applies even if the property is aPATHS
and a property exists at the specified location. To dereference to a target property (as opposed to a target node), the methodProperty.getProperty
is used.javax.jcr.RepositoryException
- if another error occurs.
-
getProperty
public javax.jcr.Property getProperty() throws javax.jcr.RepositoryException
If this property is of typePATH
(or convertible to this type) this method returns theProperty
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 aValueFormatException
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 interfacejavax.jcr.Property
- Returns:
- the referenced property
- Throws:
javax.jcr.ValueFormatException
- if this property cannot be converted to aPATH
, 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.javax.jcr.ItemNotFoundException
- If no property accessible by the currentSession
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 methodProperty.getNode
is used.javax.jcr.RepositoryException
- if another error occurs.
-
getStream
public java.io.InputStream getStream() throws javax.jcr.RepositoryException
Returns the binary value of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getStream
in interfacejavax.jcr.Property
- Returns:
- binary value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getString
public java.lang.String getString() throws javax.jcr.RepositoryException
Returns the string value of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getString
in interfacejavax.jcr.Property
- Returns:
- string value
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
getType
public int getType() throws javax.jcr.RepositoryException
Returns the type of this property.The default implementation forwards the method call to the
Value
instance returned by the genericProperty.getValue()
method.- Specified by:
getType
in interfacejavax.jcr.Property
- Returns:
- property type
- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(javax.jcr.Value value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(javax.jcr.Value[] values) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
values
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(java.lang.String value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(java.lang.String[] values) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
values
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(java.io.InputStream value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(long value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(double value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(java.util.Calendar value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(boolean value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
setValue
public void setValue(javax.jcr.Node value) throws javax.jcr.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 interfacejavax.jcr.Property
- Parameters:
value
- passed through- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
-