org.springbyexample.jcr
Class JcrRecurser

java.lang.Object
  extended by org.springbyexample.jcr.JcrRecurser
Direct Known Subclasses:
JcrContentRecurser

@Component
public class JcrRecurser
extends Object

Used for recursing through the repository. It also can start at a specified path (default is the root node) and also matching on specific nodes if a node name is specified. If no specific node names are specified, all nodes will be processed.

Author:
David Winterfeldt

Field Summary
protected  Set<String> matchingNodes
           
protected  String path
           
protected  String pathDelim
           
protected  org.springmodules.jcr.JcrTemplate template
           
 
Constructor Summary
JcrRecurser()
          Constructor.
JcrRecurser(Set<String> matchingNodes)
          Constructor.
JcrRecurser(String path)
          Constructor.
JcrRecurser(String path, Set<String> matchingNodes)
          Constructor.
 
Method Summary
 void addMatchingNode(String nodeName)
          Add matching node.
 Set<String> getMatchingNodeSet()
          Gets matching names.
 String getPath()
          Gets relative path from root to start recursing.
 String getPathDelim()
          Gets path delimiter.
 javax.jcr.Node getStartNode(javax.jcr.Node root)
          Gets start node.
 org.springmodules.jcr.JcrTemplate getTemplate()
          Gets JCR template.
 void recurse(JcrNodeCallback callback)
          Recurses through all nodes processing the callback when a matching node is found.
protected  void recurseNodes(javax.jcr.Session session, org.springmodules.jcr.JcrConstants jcrConstants, javax.jcr.Node node, JcrNodeCallback callback)
          Recurse nodes.
 void setMatchingNodeSet(Set<String> matchingNodes)
          Sets matching names.
 void setPath(String path)
          Sets relative path from root to start recursing.
 void setPathDelim(String pathDelim)
          Sets path delimiter.
 void setTemplate(org.springmodules.jcr.JcrTemplate template)
          Sets JCR template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

template

@Autowired
protected org.springmodules.jcr.JcrTemplate template

path

protected String path

pathDelim

protected String pathDelim

matchingNodes

protected Set<String> matchingNodes
Constructor Detail

JcrRecurser

public JcrRecurser()
Constructor.


JcrRecurser

public JcrRecurser(String path)
Constructor.

Parameters:
path - Relative path from root to start recursing.

JcrRecurser

public JcrRecurser(Set<String> matchingNodes)
Constructor.

Parameters:
matchingNodes - Set of node names to match for callbacks.

JcrRecurser

public JcrRecurser(String path,
                   Set<String> matchingNodes)
Constructor.

Parameters:
path - Relative path from root to start recursing.
matchingNodes - Set of node names to match for callbacks.
Method Detail

getTemplate

public org.springmodules.jcr.JcrTemplate getTemplate()
Gets JCR template.


setTemplate

public void setTemplate(org.springmodules.jcr.JcrTemplate template)
Sets JCR template.


getPath

public String getPath()
Gets relative path from root to start recursing.


setPath

public void setPath(String path)
Sets relative path from root to start recursing.


getPathDelim

public String getPathDelim()
Gets path delimiter.


setPathDelim

public void setPathDelim(String pathDelim)
Sets path delimiter.


getMatchingNodeSet

public Set<String> getMatchingNodeSet()
Gets matching names. If any node names match, then the JcrNodeCallback will be run. If no specific node names are specified, all nodes will be processed.


setMatchingNodeSet

public void setMatchingNodeSet(Set<String> matchingNodes)
Sets matching names. If any node names match, then the JcrNodeCallback will be run. If no specific node names are specified, all nodes will be processed.


addMatchingNode

public void addMatchingNode(String nodeName)
Add matching node.


recurse

public void recurse(JcrNodeCallback callback)
Recurses through all nodes processing the callback when a matching node is found.


getStartNode

public javax.jcr.Node getStartNode(javax.jcr.Node root)
                            throws javax.jcr.PathNotFoundException,
                                   javax.jcr.RepositoryException
Gets start node. If a path was specified, it will find the node matching the path (ex: 'albums/album') from the root. Otherwise the root passed in will be returned.

Throws:
javax.jcr.PathNotFoundException
javax.jcr.RepositoryException

recurseNodes

protected void recurseNodes(javax.jcr.Session session,
                            org.springmodules.jcr.JcrConstants jcrConstants,
                            javax.jcr.Node node,
                            JcrNodeCallback callback)
                     throws IOException,
                            javax.jcr.RepositoryException
Recurse nodes.

Throws:
IOException
javax.jcr.RepositoryException


Copyright © 2008-2012 Spring by Example. All Rights Reserved.