org.jboss.dna.graph.request
Class ReadBlockOfChildrenRequest

java.lang.Object
  extended by org.jboss.dna.graph.request.Request
      extended by org.jboss.dna.graph.request.CacheableRequest
          extended by org.jboss.dna.graph.request.ReadBlockOfChildrenRequest
All Implemented Interfaces:
Serializable, Cacheable

public class ReadBlockOfChildrenRequest
extends CacheableRequest

Instruction to read a block of the children of a node, where the block is dictated by the starting index and the maximum number of children to include in the block. This command is useful when paging through a large number of children.

See Also:
ReadNextBlockOfChildrenRequest, Serialized Form

Field Summary
static int INDEX_NOT_USED
           
 
Constructor Summary
ReadBlockOfChildrenRequest(Location of, String workspaceName, int startingIndex, int count)
          Create a request to read a block of the children of a node at the supplied location.
 
Method Summary
 void addChild(Location child)
          Add to the list of children that has been read the child with the given path and identification properties.
 void addChild(Path pathToChild, Property idProperty)
          Add to the list of children that has been read the child with the given path and identification property.
 void addChild(Path pathToChild, Property firstIdProperty, Property... remainingIdProperties)
          Add to the list of children that has been read the child with the given path and identification properties.
 void addChildren(Iterable<Location> children)
          Add to the list of children that has been read the supplied children with the given path and identification properties.
 void cancel()
          Cancel this request.
 int count()
          Get the maximum number of children that may be returned in the block.
 int endingBefore()
          Get the index past the last child that is to be included in the block.
 boolean equals(Object obj)
          
 Location getActualLocationOfNode()
          Get the actual location of the node whose children were read.
 List<Location> getChildren()
          Get the children that were read from the RepositoryConnection after the request was processed.
 int hashCode()
          
 String inWorkspace()
          Get the name of the workspace in which the parent and children exist.
 boolean isReadOnly()
          Return whether this request only reads information.
 Location of()
          Get the location defining the node whose children are to be read.
 void setActualLocationOfNode(Location actual)
          Sets the actual and complete location of the node whose children have been read.
 int startingAtIndex()
          Get the starting index of the block, which is the index of the first child to include.
 String toString()
          
 
Methods inherited from class org.jboss.dna.graph.request.CacheableRequest
getCachePolicy, getTimeLoaded, setCachePolicy, setTimeLoaded
 
Methods inherited from class org.jboss.dna.graph.request.Request
freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEX_NOT_USED

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

ReadBlockOfChildrenRequest

public ReadBlockOfChildrenRequest(Location of,
                                  String workspaceName,
                                  int startingIndex,
                                  int count)
Create a request to read a block of the children of a node at the supplied location. The block is defined by the starting index of the first child and the number of children to include. Note that this index is not the same-name-sibiling index, but rather is the index of the child as if the children were in an array.

Parameters:
of - the location of the node whose children are to be read
workspaceName - the name of the workspace containing the parent
startingIndex - the zero-based index of the first child to be included in the block
count - the maximum number of children that should be included in the block
Throws:
IllegalArgumentException - if the location or workspace name is null, if startingIndex is negative, or if count is less than 1.
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()

of

public Location of()
Get the location defining the node whose children are to be read.

Returns:
the location of the parent node; never null

inWorkspace

public String inWorkspace()
Get the name of the workspace in which the parent and children exist.

Returns:
the name of the workspace; never null

count

public int count()
Get the maximum number of children that may be returned in the block.

Returns:
the block's maximum count
See Also:
startingAtIndex(), endingBefore()

startingAtIndex

public int startingAtIndex()
Get the starting index of the block, which is the index of the first child to include. This index corresponds to the index of all children in the list, not the same-name-sibiling index.

Returns:
the (zero-based) child index at which this block starts; never negative and always less than endingBefore()
See Also:
endingBefore(), count()

endingBefore

public int endingBefore()
Get the index past the last child that is to be included in the block. This index corresponds to the index of all children in the list, not the same-name-sibiling index.

Returns:
the index just past the last child included in the block; always positive and always greater than startingAtIndex().
See Also:
startingAtIndex(), count()

getChildren

public List<Location> getChildren()
Get the children that were read from the RepositoryConnection after the request was processed. Each child is represented by a location.

Returns:
the children that were read; never null

addChildren

public void addChildren(Iterable<Location> children)
Add to the list of children that has been read the supplied children with the given path and identification properties. The children are added in order.

Parameters:
children - the locations of the children that were read
Throws:
IllegalArgumentException - if the parameter is null
IllegalStateException - if the request is frozen
See Also:
addChild(Location), addChild(Path, Property), addChild(Path, Property, Property...)

addChild

public void addChild(Location child)
Add to the list of children that has been read the child with the given path and identification properties. The children should be added in order.

Parameters:
child - the location of the child that was read
Throws:
IllegalArgumentException - if the location is null
IllegalStateException - if the request is frozen
See Also:
addChild(Path, Property), addChild(Path, Property, Property...)

addChild

public void addChild(Path pathToChild,
                     Property firstIdProperty,
                     Property... remainingIdProperties)
Add to the list of children that has been read the child with the given path and identification properties. The children should be added in order.

Parameters:
pathToChild - the path of the child that was just read
firstIdProperty - the first identification property of the child that was just read
remainingIdProperties - the remaining identification properties of the child that was just read
Throws:
IllegalArgumentException - if the path or identification properties are null
IllegalStateException - if the request is frozen
See Also:
addChild(Location), addChild(Path, Property)

addChild

public void addChild(Path pathToChild,
                     Property idProperty)
Add to the list of children that has been read the child with the given path and identification property. The children should be added in order.

Parameters:
pathToChild - the path of the child that was just read
idProperty - the identification property of the child that was just read
Throws:
IllegalArgumentException - if the path or identification properties are null
IllegalStateException - if the request is frozen
See Also:
addChild(Location), addChild(Path, Property, Property...)

setActualLocationOfNode

public void setActualLocationOfNode(Location actual)
Sets the actual and complete location of the node whose children have been 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 does not represent the same location as the current location, or if the actual location does not have a path.
IllegalStateException - if the request is frozen

getActualLocationOfNode

public Location getActualLocationOfNode()
Get the actual location of the node whose children were 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()


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