org.jboss.dna.graph.request
Class CompositeRequest

java.lang.Object
  extended by org.jboss.dna.graph.request.Request
      extended by org.jboss.dna.graph.request.CompositeRequest
All Implemented Interfaces:
Serializable, Iterable<Request>

@Immutable
public class CompositeRequest
extends Request
implements Iterable<Request>

A request that wraps multiple other requests, allowing multiple requests to be treated as a single request.

Note that Request.isCancelled() and Request.cancel() apply to all requests contained by the composite request. In other words, cancelling this request immediately marks all contained requests as cancelled. However, cancelling any request in the request has the effect of cancelling all other requests in the composite, including the composite. (This is implemented by having all Request objects in the composite share the same cancelled flag object.)

See Also:
Serialized Form

Field Summary
static int UNKNOWN_NUMBER_OF_REQUESTS
           
 
Method Summary
static CompositeRequest add(CompositeRequest composite, Iterator<? extends Request> requests)
          Add requests to the supplied composite request.
static CompositeRequest add(CompositeRequest composite, Request... requests)
          Add requests to the supplied composite request.
 void checkForErrors()
          Check the set of requests for errors.
 boolean equals(Object obj)
          
 List<Request> getRequests()
          Return the unmodifiable requests contained in this composite request.
 boolean isReadOnly()
          Return whether this request only reads information.
 Iterator<Request> iterator()
          
 int size()
          Get the number of requests.
 String toString()
           
static Request with(Iterator<? extends Request> requests)
          Return a request that either wraps multiple requests, or the single request if only one is supplied.
static Request with(List<? extends Request> requests)
          Return a request that either wraps multiple requests, or the single request if only one is supplied.
static Request with(Request... requests)
          Return a request that either wraps multiple requests, or the single request if only one is supplied.
 
Methods inherited from class org.jboss.dna.graph.request.Request
cancel, freeze, getError, hasError, isCancelled, isFrozen, setError, setLatchForFreezing
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_NUMBER_OF_REQUESTS

public static final int UNKNOWN_NUMBER_OF_REQUESTS
See Also:
Constant Field Values
Method Detail

with

public static Request with(Request... requests)
Return a request that either wraps multiple requests, or the single request if only one is supplied.

Parameters:
requests - the requests to wrap
Returns:
the requests wrapped in a CompositeRequest, or if only one request is supplied that single request
Throws:
IllegalArgumentException - if there requests are null, empty, or contains only nulls

with

public static Request with(Iterator<? extends Request> requests)
Return a request that either wraps multiple requests, or the single request if only one is supplied.

Parameters:
requests - the requests to wrap
Returns:
the requests wrapped in a CompositeRequest, or if only one request is supplied that single request
Throws:
IllegalArgumentException - if there requests are null, empty, or contains only nulls

with

public static Request with(List<? extends Request> requests)
Return a request that either wraps multiple requests, or the single request if only one is supplied.

Parameters:
requests - the requests to wrap
Returns:
the requests wrapped in a CompositeRequest, or if only one request is supplied that single request
Throws:
IllegalArgumentException - if there requests are null or empty

add

public static CompositeRequest add(CompositeRequest composite,
                                   Request... requests)
Add requests to the supplied composite request.

Parameters:
composite - the composite request to which the requests are to be added
requests - the requests to wrap
Returns:
the requests wrapped in a CompositeRequest, or if only one request is supplied that single request, or null if there are no request
Throws:
IllegalArgumentException - if the composite request is null

add

public static CompositeRequest add(CompositeRequest composite,
                                   Iterator<? extends Request> requests)
Add requests to the supplied composite request.

Parameters:
composite - the composite request to which the requests are to be added
requests - the requests to wrap
Returns:
the requests wrapped in a CompositeRequest, or if only one request is supplied that single request, or null if there are no request
Throws:
IllegalArgumentException - if the composite request is null

getRequests

public List<Request> getRequests()
Return the unmodifiable requests contained in this composite request.

Returns:
requests

size

public int size()
Get the number of requests.

Returns:
the number of requests

iterator

public Iterator<Request> iterator()

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

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()

checkForErrors

public void checkForErrors()
Check the set of requests for errors. Calling this method will always result in the existing error being reset to a new error or null if there are no errors.


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


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