Class AbstractNode
- java.lang.Object
- 
- org.apache.jackrabbit.commons.AbstractItem
- 
- org.apache.jackrabbit.commons.AbstractNode
 
 
- 
 public abstract class AbstractNode extends AbstractItem implements Node Abstract base class for implementing the JCRNodeinterface.Itemmethods without a default implementation:- Item.accept(javax.jcr.ItemVisitor)
- Item.getName()
- Item.getParent()
- Item.getSession()
- Item.isModified()
- Item.isNew()
- Item.isSame(Item)
- Item.refresh(boolean)
- Item.remove()
- Item.save()
 Nodemethods without a default implementation:- Node.addMixin(String)
- Node.addNode(String)
- Node.addNode(String, String)
- Node.canAddMixin(String)
- Node.cancelMerge(Version)
- Node.checkin()
- Node.checkout()
- Node.doneMerge(Version)
- Node.getBaseVersion()
- Node.getCorrespondingNodePath(String)
- Node.getDefinition()
- Node.getIndex()
- Node.getLock()
- Node.getNode(String)
- Node.getNodes()
- Node.getNodes(String)
- Node.getPrimaryItem()
- Node.getProperties()
- Node.getProperties(String)
- Node.getReferences()
- Node.lock(boolean, boolean)
- Node.merge(String, boolean)
- Node.orderBefore(String, String)
- Node.removeMixin(String)
- Node.restore(Version, String, boolean)
- Node.setProperty(String, Value)
- Node.setProperty(String, Value[])
- Node.unlock()
- Node.update(String)
 
- 
- 
Field Summary- 
Fields inherited from interface javax.jcr.NodeJCR_CHILD_NODE_DEFINITION, JCR_CONTENT, JCR_FROZEN_NODE, JCR_PROPERTY_DEFINITION, JCR_ROOT_VERSION, JCR_VERSION_LABELS
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractNode()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ItemVisitor visitor)Accepts the given item visitor.NodeType[]getMixinNodeTypes()Returns the declared mixin node types of this node.StringgetPath()Returns the path of this node.NodeTypegetPrimaryNodeType()Returns the primary node type of this node.PropertygetProperty(String relPath)Returns the property at the given relative path from this node.StringgetUUID()Returns the UUID of this node.VersionHistorygetVersionHistory()Returns the version history of this node.booleanhasNode(String relPath)Checks whether a node at the given relative path exists.booleanhasNodes()Checks if this node has one or more properties.booleanhasProperties()Checks if this node has one or more properties.booleanhasProperty(String relPath)Checks whether a property at the given relative path exists.booleanholdsLock()Checks if this node holds a lock.booleanisCheckedOut()Checks whether this node is checked out.booleanisLocked()Checks if this node is locked.booleanisNode()Returnstrue.booleanisNodeType(String name)Checks whether this node is of the given type.voidrestore(String versionName, boolean removeExisting)Restores this node to the version with the given name.voidrestore(Version version, boolean removeExisting)Restores this node to the given version.voidrestoreByLabel(String versionLabel, boolean removeExisting)Restores this node to the version with the given label.PropertysetProperty(String name, boolean value)Sets the value of the named property.PropertysetProperty(String name, double value)Sets the value of the named property.PropertysetProperty(String name, long value)Sets the value of the named property.PropertysetProperty(String name, InputStream value)Sets the value of the named property.PropertysetProperty(String name, String value)Sets the value of the named property.PropertysetProperty(String name, String[] strings)Sets the value of the named property.PropertysetProperty(String name, String[] strings, int type)Sets the value of the named property.PropertysetProperty(String name, String value, int type)Sets the value of the named property.PropertysetProperty(String name, Calendar value)Sets the value of the named property.PropertysetProperty(String name, Node value)Sets the value of the named property.PropertysetProperty(String name, Value[] values, int type)Sets the value of the named property.PropertysetProperty(String name, Value value, int type)Sets the value of the named property.- 
Methods inherited from class org.apache.jackrabbit.commons.AbstractItemgetAncestor, getDepth, toString
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface javax.jcr.ItemgetAncestor, getDepth, getName, getParent, getSession, isModified, isNew, isSame, refresh, remove, save
 - 
Methods inherited from interface javax.jcr.NodeaddMixin, addNode, addNode, canAddMixin, cancelMerge, checkin, checkout, doneMerge, followLifecycleTransition, getAllowedLifecycleTransistions, getBaseVersion, getCorrespondingNodePath, getDefinition, getIdentifier, getIndex, getLock, getNode, getNodes, getNodes, getNodes, getPrimaryItem, getProperties, getProperties, getProperties, getReferences, getReferences, getSharedSet, getWeakReferences, getWeakReferences, lock, merge, orderBefore, removeMixin, removeShare, removeSharedSet, restore, setPrimaryType, setProperty, setProperty, setProperty, setProperty, unlock, update
 
- 
 
- 
- 
- 
Method Detail- 
acceptpublic void accept(ItemVisitor visitor) throws RepositoryException Accepts the given item visitor.The default implementation calls ItemVisitor.visit(Node)on the given visitor with this node as the argument.- Specified by:
- acceptin interface- Item
- Parameters:
- visitor- item visitor
- Throws:
- RepositoryException- if an error occurs
 
 - 
getPathpublic String getPath() throws RepositoryException Returns the path of this node.The default implementation recursively calls this method on the parent node and appends the name and optionally the index of this node to construct the full path. Returns "/" if the parent node is not available (i.e. this is the root node). - Specified by:
- getPathin interface- Item
- Returns:
- node path
- Throws:
- RepositoryException- if an error occurs
 
 - 
getMixinNodeTypespublic NodeType[] getMixinNodeTypes() throws RepositoryException Returns the declared mixin node types of this node.The default implementation uses the values of the jcr:mixinTypesproperty to look up the mixin node types from theNodeTypeManagerof the current workspace.- Specified by:
- getMixinNodeTypesin interface- Node
- Returns:
- mixin node types
- Throws:
- RepositoryException- if an error occurs
 
 - 
getPrimaryNodeTypepublic NodeType getPrimaryNodeType() throws RepositoryException Returns the primary node type of this node.The default implementation uses the value of the jcr:primaryTypeproperty to look up the primary node type from theNodeTypeManagerof the current workspace.- Specified by:
- getPrimaryNodeTypein interface- Node
- Returns:
- primary node type
- Throws:
- RepositoryException- if an error occurs
 
 - 
getPropertypublic Property getProperty(String relPath) throws PathNotFoundException, RepositoryException Returns the property at the given relative path from this node.The default implementation looks up the parent node of the given relative path and iterates through the properties of that node to find and return the identified property. - Specified by:
- getPropertyin interface- Node
- Parameters:
- relPath- relative path of the property
- Returns:
- property
- Throws:
- PathNotFoundException- if the property is not found
- RepositoryException- if an error occurs
 
 - 
getUUIDpublic String getUUID() throws UnsupportedRepositoryOperationException, RepositoryException Returns the UUID of this node.The default implementation checks if this node is referenceable (i.e. of type mix:referenceable) and returns the contents of thejcr:uuidproperty if it is.- Specified by:
- getUUIDin interface- Node
- Returns:
- node UUID
- Throws:
- UnsupportedRepositoryOperationException- if this node is not referenceable
- RepositoryException- if an error occurs
 
 - 
getVersionHistorypublic VersionHistory getVersionHistory() throws RepositoryException Returns the version history of this node.The default implementation returns the containing version history of the base version of this node. - Specified by:
- getVersionHistoryin interface- Node
- Returns:
- version history
- Throws:
- RepositoryException- if an error occurs
 
 - 
hasNodepublic boolean hasNode(String relPath) throws RepositoryException Checks whether a node at the given relative path exists.The default implementation looks up the node using Node.getNode(String)and returnstrueif aPathNotFoundExceptionis not thrown.- Specified by:
- hasNodein interface- Node
- Parameters:
- relPath- relative path
- Returns:
- trueif a node exists at the given path,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
hasNodespublic boolean hasNodes() throws RepositoryExceptionChecks if this node has one or more properties.The default implementation calls Node.getNodes()and returnstrueiff returned iterator has at least one element.- Specified by:
- hasNodesin interface- Node
- Returns:
- trueif this node has child nodes,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
hasPropertiespublic boolean hasProperties() throws RepositoryExceptionChecks if this node has one or more properties.The default implementation calls Node.getProperties()and returnstrueiff returned iterator has at least one element.Note that in normal circumstances (i.e. no weird access controls) this method will always return truesince all nodes always have at least thejcr:primaryTypeproperty.- Specified by:
- hasPropertiesin interface- Node
- Returns:
- trueif this node has properties,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
hasPropertypublic boolean hasProperty(String relPath) throws RepositoryException Checks whether a property at the given relative path exists.The default implementation looks up the property using Node.getProperty(String)and returnstrueif aPathNotFoundExceptionis not thrown.- Specified by:
- hasPropertyin interface- Node
- Parameters:
- relPath- relative path
- Returns:
- trueif a property exists at the given path,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
holdsLockpublic boolean holdsLock() throws RepositoryExceptionChecks if this node holds a lock.The default implementation calls Node.getLock()and returnstrueiff the holding node of the lock is the same as this node.- Specified by:
- holdsLockin interface- Node
- Returns:
- trueif this node holds a lock,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
isCheckedOutpublic boolean isCheckedOut() throws RepositoryExceptionChecks whether this node is checked out.The default implementation checks the jcr:isCheckedOutproperty if this node is versionable, and recursively calls this method on the parent node if this node is not versionable. A non-versionable root node always returnstruefrom this method.- Specified by:
- isCheckedOutin interface- Node
- Returns:
- trueif this node is checked out,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
isLockedpublic boolean isLocked() throws RepositoryExceptionChecks if this node is locked.The default implementation calls Node.getLock()and returnstrueiff aLockExceptionis not thrown.- Specified by:
- isLockedin interface- Node
- Returns:
- trueif this node is locked,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
isNodeTypepublic boolean isNodeType(String name) throws RepositoryException Checks whether this node is of the given type.The default implementation iterates through the primary and mixin types and all the supertypes of this node, returning trueif a type with the given name is encountered. Returnsfalseif none of the types matches.- Specified by:
- isNodeTypein interface- Node
- Parameters:
- name- type name
- Returns:
- trueif this node is of the given type,- falseotherwise
- Throws:
- RepositoryException- if an error occurs
 
 - 
restorepublic void restore(String versionName, boolean removeExisting) throws RepositoryException Restores this node to the version with the given name.The default implement retrieves the named Versionfrom the associatedVersionHistoryand forwards the call to theNode.restore(Version, boolean)method.- Specified by:
- restorein interface- Node
- Parameters:
- versionName- version name
- removeExisting- passed through
- Throws:
- RepositoryException- if an error occurs
 
 - 
restorepublic void restore(Version version, boolean removeExisting) throws RepositoryException Restores this node to the given version.The default implementation forwards the call to the Node.restore(Version, String, boolean)method using the relative path ".".- Specified by:
- restorein interface- Node
- Parameters:
- version- passed through
- removeExisting- passed through
- Throws:
- RepositoryException- if an error occurs
 
 - 
restoreByLabelpublic void restoreByLabel(String versionLabel, boolean removeExisting) throws RepositoryException Restores this node to the version with the given label.The default implement retrieves the labeled Versionfrom the associatedVersionHistoryand forwards the call to theNode.restore(Version, boolean)method.- Specified by:
- restoreByLabelin interface- Node
- Parameters:
- versionLabel- version label
- removeExisting- passed through
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, String[] strings) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstances from the given string values and forwards the call to theNode.setProperty(String, Value[])method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- strings- string values
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, String value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given string value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- string value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, InputStream value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given binary value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- binary value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, boolean value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given boolean value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- boolean value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, double value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given double value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- double value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, long value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given long value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- long value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, Calendar value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given date value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- date value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, Node value) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance from the given reference value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- reference value
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, Value value, int type) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto convert the given value to the given type and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- property value
- type- property type
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, Value[] values, int type) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto convert the given values to the given type and forwards the call to theNode.setProperty(String, Value[])method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- values- property values
- type- property type
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, String[] strings, int type) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto createValueinstances of the given type from the given string values and forwards the call to theNode.setProperty(String, Value[])method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- strings- string values
- type- property type
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 - 
setPropertypublic Property setProperty(String name, String value, int type) throws RepositoryException Sets the value of the named property.The default implementation uses the ValueFactoryof the currentSessionto create aValueinstance of the given type from the given string value and forwards the call to theNode.setProperty(String, Value)method.- Specified by:
- setPropertyin interface- Node
- Parameters:
- name- property name
- value- string value
- type- property type
- Returns:
- modified property
- Throws:
- RepositoryException- if an error occurs
 
 
- 
 
-