info.magnolia.jcr.wrapper
Class InheritanceNodeWrapper

java.lang.Object
  extended by info.magnolia.jcr.wrapper.DelegateNodeWrapper
      extended by info.magnolia.jcr.wrapper.ChildWrappingNodeWrapper
          extended by info.magnolia.jcr.wrapper.InheritanceNodeWrapper
All Implemented Interfaces:
NodeWrapperFactory, Cloneable, javax.jcr.Item, javax.jcr.Node

public class InheritanceNodeWrapper
extends ChildWrappingNodeWrapper

This wrapper inherits nodes from the parent hierarchy. The method isAnchor() defines the anchor to which the inheritance is performed relative to. By default the anchor is of type (mgnl:content).

The inheritance is then performed as follows:

The getNodes() and getNodes(String) methods merge the direct and inherited children by first adding the inherited children to the iterator and then the direct children.

Version:
$Id$

Field Summary
 
Fields inherited from class info.magnolia.jcr.wrapper.DelegateNodeWrapper
wrapped
 
Fields inherited from interface javax.jcr.Node
JCR_CHILD_NODE_DEFINITION, JCR_CONTENT, JCR_FROZEN_NODE, JCR_PROPERTY_DEFINITION, JCR_ROOT_VERSION, JCR_VERSION_LABELS
 
Constructor Summary
InheritanceNodeWrapper(javax.jcr.Node node)
           
InheritanceNodeWrapper(javax.jcr.Node node, AbstractPredicate<javax.jcr.Node> filter)
           
InheritanceNodeWrapper(javax.jcr.Node node, javax.jcr.Node start)
           
InheritanceNodeWrapper(javax.jcr.Node node, javax.jcr.Node start, AbstractPredicate<javax.jcr.Node> filter)
           
 
Method Summary
protected  InheritanceNodeWrapper findAnchor()
          Find the anchor for this node.
protected  InheritanceNodeWrapper findNextAnchor()
          Find next anchor.
 javax.jcr.Node getNode(String relPath)
           
 javax.jcr.NodeIterator getNodes()
           
 javax.jcr.NodeIterator getNodes(String namePattern)
           
protected  javax.jcr.Node getNodeSafely(InheritanceNodeWrapper anchor, String path)
          This method returns null if no node has been found.
protected  javax.jcr.Node getNodeSafely(String relPath)
          This method returns null if no node has been found.
 javax.jcr.Property getProperty(String relPath)
           
 boolean hasNode(String relPath)
           
 boolean hasProperty(String name)
           
protected  boolean isAnchor()
          True if this node is an anchor.
 boolean isInherited()
          True if this is not a sub node of the starting point.
protected  String resolveInnerPath()
          Returns the inner path of the this node up to the anchor.
 javax.jcr.Node wrapNode(javax.jcr.Node node)
           
 
Methods inherited from class info.magnolia.jcr.wrapper.ChildWrappingNodeWrapper
addNode, addNode, getNodes, wrapNodeIterator
 
Methods inherited from class info.magnolia.jcr.wrapper.DelegateNodeWrapper
accept, addMixin, canAddMixin, cancelMerge, checkin, checkout, clone, deepUnwrap, doneMerge, followLifecycleTransition, getAllowedLifecycleTransistions, getAncestor, getBaseVersion, getCorrespondingNodePath, getDefinition, getDepth, getIdentifier, getIndex, getLock, getMixinNodeTypes, getName, getParent, getPath, getPrimaryItem, getPrimaryNodeType, getProperties, getProperties, getProperties, getReferences, getReferences, getSession, getSharedSet, getUUID, getVersionHistory, getWeakReferences, getWeakReferences, getWrappedNode, hasNodes, hasProperties, holdsLock, initClone, isCheckedOut, isLocked, isModified, isNew, isNode, isNodeType, isSame, lock, merge, orderBefore, refresh, remove, removeMixin, removeShare, removeSharedSet, restore, restore, restore, restoreByLabel, save, setPrimaryType, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setWrappedNode, toString, unlock, update
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InheritanceNodeWrapper

public InheritanceNodeWrapper(javax.jcr.Node node)

InheritanceNodeWrapper

public InheritanceNodeWrapper(javax.jcr.Node node,
                              AbstractPredicate<javax.jcr.Node> filter)

InheritanceNodeWrapper

public InheritanceNodeWrapper(javax.jcr.Node node,
                              javax.jcr.Node start,
                              AbstractPredicate<javax.jcr.Node> filter)

InheritanceNodeWrapper

public InheritanceNodeWrapper(javax.jcr.Node node,
                              javax.jcr.Node start)
Method Detail

findAnchor

protected InheritanceNodeWrapper findAnchor()
                                     throws javax.jcr.RepositoryException
Find the anchor for this node.

Throws:
javax.jcr.RepositoryException

findNextAnchor

protected InheritanceNodeWrapper findNextAnchor()
                                         throws javax.jcr.RepositoryException
Find next anchor.

Throws:
javax.jcr.RepositoryException

isAnchor

protected boolean isAnchor()
True if this node is an anchor. By default true if this node is of type MgnlNodeType.NT_CONTENT.


getNodeSafely

protected javax.jcr.Node getNodeSafely(String relPath)
                                throws javax.jcr.RepositoryException
This method returns null if no node has been found.

Throws:
javax.jcr.RepositoryException

resolveInnerPath

protected String resolveInnerPath()
                           throws javax.jcr.RepositoryException
Returns the inner path of the this node up to the anchor.

Throws:
javax.jcr.RepositoryException

getNodeSafely

protected javax.jcr.Node getNodeSafely(InheritanceNodeWrapper anchor,
                                       String path)
                                throws javax.jcr.RepositoryException
This method returns null if no node has been found.

Throws:
javax.jcr.RepositoryException

hasNode

public boolean hasNode(String relPath)
                throws javax.jcr.RepositoryException
Specified by:
hasNode in interface javax.jcr.Node
Overrides:
hasNode in class DelegateNodeWrapper
Throws:
javax.jcr.RepositoryException

getNode

public javax.jcr.Node getNode(String relPath)
                       throws javax.jcr.PathNotFoundException,
                              javax.jcr.RepositoryException
Specified by:
getNode in interface javax.jcr.Node
Overrides:
getNode in class ChildWrappingNodeWrapper
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException

getNodes

public javax.jcr.NodeIterator getNodes()
                                throws javax.jcr.RepositoryException
Specified by:
getNodes in interface javax.jcr.Node
Overrides:
getNodes in class ChildWrappingNodeWrapper
Throws:
javax.jcr.RepositoryException

getNodes

public javax.jcr.NodeIterator getNodes(String namePattern)
                                throws javax.jcr.RepositoryException
Specified by:
getNodes in interface javax.jcr.Node
Overrides:
getNodes in class ChildWrappingNodeWrapper
Throws:
javax.jcr.RepositoryException

getProperty

public javax.jcr.Property getProperty(String relPath)
                               throws javax.jcr.PathNotFoundException,
                                      javax.jcr.RepositoryException
Specified by:
getProperty in interface javax.jcr.Node
Overrides:
getProperty in class DelegateNodeWrapper
Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException

hasProperty

public boolean hasProperty(String name)
                    throws javax.jcr.RepositoryException
Specified by:
hasProperty in interface javax.jcr.Node
Overrides:
hasProperty in class DelegateNodeWrapper
Throws:
javax.jcr.RepositoryException

isInherited

public boolean isInherited()
True if this is not a sub node of the starting point.


wrapNode

public javax.jcr.Node wrapNode(javax.jcr.Node node)
Specified by:
wrapNode in interface NodeWrapperFactory
Overrides:
wrapNode in class ChildWrappingNodeWrapper


Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.