org.apache.jackrabbit.commons
Class AbstractProperty

java.lang.Object
  extended by org.apache.jackrabbit.commons.AbstractItem
      extended by 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 Summary
AbstractProperty()
           
 
Method Summary
 void accept(ItemVisitor visitor)
          Accepts the given item visitor.
 boolean getBoolean()
          Returns the boolean value of this property.
 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.
 Node getNode()
          Returns the node referenced by this property.
 String getPath()
          Returns the path of this property.
 InputStream getStream()
          Returns the binary value of this property.
 String getString()
          Returns the string value of this property.
 int getType()
          Returns the type of this property.
 boolean isNode()
          Returns false.
 void remove()
          Removes this property.
 void setValue(boolean value)
          Sets the value of this property.
 void setValue(Calendar value)
          Sets the value of this property.
 void setValue(double value)
          Sets the value of this property.
 void setValue(InputStream value)
          Sets the value of this property.
 void setValue(long value)
          Sets the value of this property.
 void setValue(Node value)
          Sets the value of this property.
 void setValue(String value)
          Sets the value of this property.
 void setValue(String[] values)
          Sets the values of this property.
 void setValue(Value value)
          Sets the value of this property.
 void setValue(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jcr.Property
getDefinition, getValue, getValues
 
Methods inherited from interface javax.jcr.Item
getAncestor, getDepth, getName, getParent, getSession, isModified, isNew, isSame, refresh, save
 

Constructor Detail

AbstractProperty

public AbstractProperty()
Method Detail

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

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

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

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

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

getNode

public Node getNode()
             throws RepositoryException
Returns the node referenced by this property.

The default implementation checks that this property is a reference property (or tries to convert the property value to a reference) and uses Session.getNodeByUUID(String) to retrieve the referenced node.

Specified by:
getNode in interface Property
Returns:
node referenced by this property
Throws:
RepositoryException - if an 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

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

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


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.