com.scit.sling.test
Class ResourceNode

java.lang.Object
  extended by com.scit.sling.test.ResourceNode

public class ResourceNode
extends Object

This class is used to represent a JRC subtree. You can use it directly to create a tree then build a MockResourceResolver via MockResourceFactory.buildMockRepository(ResourceNode) or you can use the provided MockResourceFactory#buildRepositoryFromJson(String, java.io.InputStream) factory methods.

Direct Usage

base = new ResourceNode("/content/geometrixx/en", "products");
base.addProperty("jcr:createdBy", "system");
base.addProperty("jcr:primaryType", "cq:Page");
jcrContent = new ResourceNode("base", "jcr:content");
base.addChild(jcrContent);
jcrContent.addProperty("sling:resourceType", "geometrixx/components/contentpage");
jcrContent.addProperty("jcr:createdBy", "system");


Constructor Summary
ResourceNode(ResourceNode parent, String name)
           
ResourceNode(String basePath, String name)
          Create a root node that represents a location somewhere on a resource tree.
 
Method Summary
 void addChild(ResourceNode node)
          Add a child and possibly another subtree
 void addProperty(String name, Object value)
          Add a property node
 String fullContent(int depth)
           
 LinkedList<ResourceNode> getChildren()
           
 String getPath()
           
 org.apache.sling.api.resource.ValueMap getProperties()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceNode

public ResourceNode(String basePath,
                    String name)
Create a root node that represents a location somewhere on a resource tree.

Parameters:
basePath - the parent path of this node (blank if it's meant to be the root)
name - the name of this node

ResourceNode

public ResourceNode(ResourceNode parent,
                    String name)
Method Detail

getChildren

public LinkedList<ResourceNode> getChildren()

addProperty

public void addProperty(String name,
                        Object value)
Add a property node

Parameters:
name - the property name
value - the value

getPath

public String getPath()
Returns:
the full "jcr:path" of the resource

toString

public String toString()
Overrides:
toString in class Object

fullContent

public String fullContent(int depth)
Returns:
the whole tree (this node and all sub nodes) as a nicely formatted tree upto depth

addChild

public void addChild(ResourceNode node)
Add a child and possibly another subtree

Parameters:
node -

getProperties

public org.apache.sling.api.resource.ValueMap getProperties()
Returns:
a list of all properties


Copyright © 2013 Southern Cross IT. All rights reserved.