info.magnolia.jcr.inheritance
Class InheritanceContentDecorator

java.lang.Object
  extended by info.magnolia.jcr.decoration.AbstractContentDecorator
      extended by info.magnolia.jcr.inheritance.InheritanceContentDecorator
All Implemented Interfaces:
ContentDecorator, Cloneable
Direct Known Subclasses:
DefaultInheritanceContentDecorator

public class InheritanceContentDecorator
extends AbstractContentDecorator
implements Cloneable

Provides inheritance on JCR level by applying wrapper objects. The inheritance destination node gets nodes and properties from a list of source nodes. Subclasses can customize which nodes are inherited and how the inherited nodes are ordered.

Limitations:

Version:
$Id$

Nested Class Summary
 class InheritanceContentDecorator.DestinationNodeInheritanceNodeWrapper
          Wrapper applied to the destination node.
 
Constructor Summary
InheritanceContentDecorator(javax.jcr.Node destination)
           
 
Method Summary
 void addSource(javax.jcr.Node source)
           
protected  javax.jcr.PropertyIterator combinePropertyIterators(javax.jcr.PropertyIterator destinationProperties, List<javax.jcr.PropertyIterator> sourceProperties)
          Combines the inherited properties and provides them as a PropertyIterator.
 javax.jcr.Node getDestination()
           
protected  boolean inheritsNodes(javax.jcr.Node node)
          Decides if a node inherits child nodes.
protected  boolean inheritsProperties(javax.jcr.Node node)
          Decides if a node inherits properties.
 boolean isMultipleWrapEnabled()
          Tells if multiple wrapping with this content decorator is enabled.
protected  boolean isSourceChildInherited(javax.jcr.Node node)
          Decides if a specific child node of one of the source should be inherited.
protected  javax.jcr.NodeIterator sortInheritedNodes(javax.jcr.NodeIterator destinationChildren, List<javax.jcr.NodeIterator> sourceChildren)
          Sorts the inherited nodes and provides a NodeIterator representing that order.
 javax.jcr.Node wrapNode(javax.jcr.Node node)
           
 
Methods inherited from class info.magnolia.jcr.decoration.AbstractContentDecorator
evaluateNode, evaluateProperty, wrapNodeIterator, wrapProperty, wrapPropertyIterator, wrapSession, wrapWorkspace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InheritanceContentDecorator

public InheritanceContentDecorator(javax.jcr.Node destination)
                            throws javax.jcr.RepositoryException
Throws:
javax.jcr.RepositoryException
Method Detail

wrapNode

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

getDestination

public javax.jcr.Node getDestination()

addSource

public void addSource(javax.jcr.Node source)

inheritsNodes

protected boolean inheritsNodes(javax.jcr.Node node)
                         throws javax.jcr.RepositoryException
Decides if a node inherits child nodes. By default always returns true.

Parameters:
node - the destination node or a source node
Returns:
true if the node inherits nodes
Throws:
javax.jcr.RepositoryException

inheritsProperties

protected boolean inheritsProperties(javax.jcr.Node node)
                              throws javax.jcr.RepositoryException
Decides if a node inherits properties. By default always returns true.

Parameters:
node - the destination node or a source node
Returns:
true if the node inherits properties
Throws:
javax.jcr.RepositoryException

isSourceChildInherited

protected boolean isSourceChildInherited(javax.jcr.Node node)
                                  throws javax.jcr.RepositoryException
Decides if a specific child node of one of the source should be inherited. By default always returns true.

Parameters:
node - a child of one of the source nodes
Returns:
true if the node is inherited
Throws:
javax.jcr.RepositoryException

sortInheritedNodes

protected javax.jcr.NodeIterator sortInheritedNodes(javax.jcr.NodeIterator destinationChildren,
                                                    List<javax.jcr.NodeIterator> sourceChildren)
                                             throws javax.jcr.RepositoryException
Sorts the inherited nodes and provides a NodeIterator representing that order. By default orders nodes from the top-most source first and nodes from the destination last.

Parameters:
destinationChildren - children of the destination node
sourceChildren - children of each of the source nodes in bottom-up order
Returns:
Throws:
javax.jcr.RepositoryException

combinePropertyIterators

protected javax.jcr.PropertyIterator combinePropertyIterators(javax.jcr.PropertyIterator destinationProperties,
                                                              List<javax.jcr.PropertyIterator> sourceProperties)
                                                       throws javax.jcr.RepositoryException
Combines the inherited properties and provides them as a PropertyIterator. By default properties in the destination node overrides properties from source nodes. Properties on source node have preference in a bottom to top order.

Parameters:
destinationProperties - properties of the destination node
sourceProperties - properties of the source nodes in bottom-up order
Returns:
Throws:
javax.jcr.RepositoryException

isMultipleWrapEnabled

public boolean isMultipleWrapEnabled()
Description copied from interface: ContentDecorator
Tells if multiple wrapping with this content decorator is enabled.

Specified by:
isMultipleWrapEnabled in interface ContentDecorator


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