org.modeshape.graph.request
Class ReadBranchRequest

java.lang.Object
  extended by org.modeshape.graph.request.Request
      extended by org.modeshape.graph.request.CacheableRequest
          extended by org.modeshape.graph.request.ReadBranchRequest
All Implemented Interfaces:
Serializable, Iterable<Location>, Cacheable

@NotThreadSafe
public class ReadBranchRequest
extends CacheableRequest
implements Iterable<Location>

Instruction to read the properties and children of the nodes in the branch at the supplied location. The children of the nodes at the bottom of the branch are not read.

See Also:
Serialized Form

Field Summary
static int DEFAULT_MAXIMUM_DEPTH
           
static int NO_MAXIMUM_DEPTH
           
 
Constructor Summary
ReadBranchRequest(Location at, String workspaceName)
          Create a request to read the branch at the supplied location, to a maximum depth of 2.
ReadBranchRequest(Location at, String workspaceName, int maxDepth)
          Create a request to read the branch (of given depth) at the supplied location.
 
Method Summary
 Location at()
          Get the location defining the top of the branch to be read
 void cancel()
          Cancel this request.
 boolean equals(Object obj)
          
 Location getActualLocationOfNode()
          Get the actual location of the node that was read.
 List<Location> getChildren(Location parent)
          Get the children of the node at the supplied location.
 Location getLocationFor(Path path)
          Get the location for the supplied path.
 Map<Name,Property> getPropertiesFor(Location location)
          Get the nodes that make up this branch.
 RequestType getType()
          Returns the type of the request
 int hashCode()
          
 boolean includes(Location location)
          Return whether this branch contains the specified location.
 boolean includes(Path path)
          Return whether this branch contains the specified path.
 String inWorkspace()
          Get the name of the workspace in which the branch exists.
 boolean isReadOnly()
          Return whether this request only reads information.
 Iterator<Location> iterator()
           The resulting iterator accesses the Location objects in the branch, in pre-order traversal order.
 int maximumDepth()
          Get the maximum depth of the branch that is to be read.
 void setActualLocationOfNode(Location actual)
          Sets the actual and complete location of the node being read.
 void setChildren(Location parent, List<Location> children)
          Record the children for a parent node in the branch.
 void setChildren(Location parent, Location... children)
          Record the children for a parent node in the branch.
 void setProperties(Location node, Iterable<Property> properties)
          Add a node that was read from the RepositoryConnection.
 void setProperties(Location node, Property... properties)
          Add a node that was read from the RepositoryConnection.
 String toString()
          
 
Methods inherited from class org.modeshape.graph.request.CacheableRequest
getCachePolicy, getTimeLoaded, setCachePolicy, setTimeLoaded
 
Methods inherited from class org.modeshape.graph.request.Request
checkNotFrozen, freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAXIMUM_DEPTH

public static final int DEFAULT_MAXIMUM_DEPTH
See Also:
Constant Field Values

NO_MAXIMUM_DEPTH

public static final int NO_MAXIMUM_DEPTH
See Also:
Constant Field Values
Constructor Detail

ReadBranchRequest

public ReadBranchRequest(Location at,
                         String workspaceName)
Create a request to read the branch at the supplied location, to a maximum depth of 2.

Parameters:
at - the location of the branch
workspaceName - the name of the workspace containing the parent
Throws:
IllegalArgumentException - if the location or workspace name is null

ReadBranchRequest

public ReadBranchRequest(Location at,
                         String workspaceName,
                         int maxDepth)
Create a request to read the branch (of given depth) at the supplied location.

Parameters:
at - the location of the branch
workspaceName - the name of the workspace containing the branch
maxDepth - the maximum depth to read
Throws:
IllegalArgumentException - if the location or workspace name is null or if the maximum depth is not positive
Method Detail

isReadOnly

public boolean isReadOnly()
Return whether this request only reads information.

Specified by:
isReadOnly in class Request
Returns:
true if this request reads information, or false if it requests that the repository content be changed in some way
See Also:
Request.isReadOnly()

at

public Location at()
Get the location defining the top of the branch to be read

Returns:
the location of the branch; never null

inWorkspace

public String inWorkspace()
Get the name of the workspace in which the branch exists.

Returns:
the name of the workspace; never null

maximumDepth

public int maximumDepth()
Get the maximum depth of the branch that is to be read.

Returns:
the maximum depth; always positive

includes

public boolean includes(Location location)
Return whether this branch contains the specified location.

Parameters:
location - the location
Returns:
true if this branch includes the location, or false otherwise

includes

public boolean includes(Path path)
Return whether this branch contains the specified path.

Parameters:
path - the path
Returns:
true if this branch includes the path, or false otherwise

getLocationFor

public Location getLocationFor(Path path)
Get the location for the supplied path.

Parameters:
path - the path
Returns:
the location for the path, or null if the path is not known

setProperties

public void setProperties(Location node,
                          Property... properties)
Add a node that was read from the RepositoryConnection. This method does not verify or check that the node is indeed on the branch and that it is at a level prescribed by the request.

Parameters:
node - the location of the node that appears on this branch; must have a path
properties - the properties on the node
Throws:
IllegalArgumentException - if the node is null
IllegalStateException - if the request is frozen

setProperties

public void setProperties(Location node,
                          Iterable<Property> properties)
Add a node that was read from the RepositoryConnection. This method does not verify or check that the node is indeed on the branch and that it is at a level prescribed by the request.

Parameters:
node - the location of the node that appears on this branch; must have a path
properties - the properties on the node
Throws:
IllegalArgumentException - if the node is null
IllegalStateException - if the request is frozen

setChildren

public void setChildren(Location parent,
                        Location... children)
Record the children for a parent node in the branch.

Parameters:
parent - the location of the parent; must have a path
children - the location of each child, in the order they appear in the parent
Throws:
IllegalStateException - if the request is frozen

setChildren

public void setChildren(Location parent,
                        List<Location> children)
Record the children for a parent node in the branch.

Parameters:
parent - the location of the parent; must have a path
children - the location of each child, in the order they appear in the parent
Throws:
IllegalStateException - if the request is frozen

getPropertiesFor

public Map<Name,Property> getPropertiesFor(Location location)
Get the nodes that make up this branch. If this map is empty, the branch has not yet been read. The resulting map maintains the order that the nodes were added.

Parameters:
location - the location of the node for which the properties are to be obtained
Returns:
the properties for the location, as a map keyed by the property name, or null if there is no such location
See Also:
iterator()

getChildren

public List<Location> getChildren(Location parent)
Get the children of the node at the supplied location.

Parameters:
parent - the location of the parent
Returns:
the children, or null if there are no children (or if the parent has not been read)

iterator

public Iterator<Location> iterator()

The resulting iterator accesses the Location objects in the branch, in pre-order traversal order.

Specified by:
iterator in interface Iterable<Location>
See Also:
Iterable.iterator()

setActualLocationOfNode

public void setActualLocationOfNode(Location actual)
Sets the actual and complete location of the node being read. This method must be called when processing the request, and the actual location must have a path.

Parameters:
actual - the actual location of the node being read, or null if the current location should be used
Throws:
IllegalArgumentException - if the actual location is null or does not have a path

getActualLocationOfNode

public Location getActualLocationOfNode()
Get the actual location of the node that was read.

Returns:
the actual location, or null if the actual location was not set

cancel

public void cancel()
Cancel this request. After this method is called, the cancellation flag is set, and any current or future processing of the request may be affected by the cancellation. (Note however, that processors may choose to not respect this request.)

This method is safe to be called by different threads.

Overrides:
cancel in class Request
See Also:
Request.cancel()

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

getType

public RequestType getType()
Description copied from class: Request
Returns the type of the request

Specified by:
getType in class Request
Returns:
the type of the request


Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.