Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.request
Class FunctionRequest

    java.lang.Object
      org.modeshape.graph.request.Request
          org.modeshape.graph.request.FunctionRequest

All Implemented Interfaces:
  Serializable, Cloneable

    public final class FunctionRequest

extends Request
implements Cloneable

See Also:
  Serialized Form

Constructor Summary
`FunctionRequest(Function function, Location at, String workspaceName, Map<String,Serializable> inputs)` Create a request to execute the function at the supplied location.

Method Summary
`void` | `addActualRequest(Request request)` Add an actual request created and executed by the invocation of this function.
`void` | `addActualRequests(Iterable<Request> requests)` Add the actual requests created and executed by the invocation of this function.
`Location` | `at()` Get the location defining the node that is to be read.
`void` | `cancel()` Cancel this request.
`FunctionRequest` | `clone()` This method does not clone the results.
`protected
`<T> T`
` | `convert(String name, Class<T> type, T defaultValue, Map<String,Serializable> values, ExecutionContext context)`
`protected
`<T> T`
` | `convert(String name, PropertyType type, T defaultValue, Map<String,Serializable> values, ExecutionContext context)`
`boolean` | `equals(Object obj)`
`Function` | `function()` Get the function implementation
`Location` | `getActualLocationOfNode()` Get the actual location of the node whose children and properties were read.
`int` | `getActualRequestCount()` Get the number of actual requests created and executed by the invocation of this function.
`Iterator<Request>` | `getActualRequests()` Get the actual requests created and executed by the invocation of this function.
`RequestType` | `getType()` Returns the type of the request
`int` | `hashCode()`
`Object` | `input(String name)` Get the value for the named input to this function.
`
`<T> T`
` | `input(String name, Class<T> type, T defaultValue, ExecutionContext context)` Get the value for the named input to this function.
`
`<T> T`
` | `input(String name, PropertyType type, T defaultValue, ExecutionContext context)` Get the value for the named input to this function.
`Map<String,Serializable>` | `inputs()` The unmodifiable map of input parameter name to value.
`String` | `inWorkspace()` Get the name of the workspace in which the function is being applied.
`boolean` | `isReadOnly()` Return whether this request only reads information.
`Object` | `output(String name)` Get the value for the named output to this function.
`
`<T> T`
` | `output(String name, Class<T> type, ExecutionContext context)` Get the value for the named output to this function.
`
`<T> T`
` | `output(String name, Class<T> type, T defaultValue, ExecutionContext context)` Get the value for the named output to this function.
`
`<T> T`
` | `output(String name, PropertyType type, T defaultValue, ExecutionContext context)` Get the value for the named output to this function.
`Map<String,Serializable>` | `outputs()` The unmodifiable map of input parameter name to value.
`void` | `setActualLocationOfNode(Location actual)` Sets the actual and complete location of the node whose children and properties have been read.
`Serializable` | `setOutput(String name, Serializable value)` Set the value for the named output parameter for the function.
`String` | `toString()`

Methods inherited from class org.modeshape.graph.request.Request
`checkNotFrozen, freeze, getError, hasError, isCancelled, isFrozen, printable, printable, setError, setLatchForFreezing`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### FunctionRequest

    public FunctionRequest(Function function,
                           Location at,
                           String workspaceName,
                           Map<String,Serializable> inputs)

  Create a request to execute the function at the supplied location.

  Parameters:
    `function` - the function to be performed
    `at` - the location of the node to be read
    `workspaceName` - the name of the workspace containing the node
    `inputs` - the immutable map of input names to values for the function invocation, or null if there are no inputs
  Throws:
    `IllegalArgumentException` - if the function, location or workspace name is null

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 node that is to be read.

  Returns:
    the location of the node; never null

### inWorkspace

    public String inWorkspace()

  Get the name of the workspace in which the function is being applied.

  Returns:
    the name of the workspace; never null

### inputs

    public Map<String,Serializable> inputs()

  The unmodifiable map of input parameter name to value.

  Returns:
    the map of input names to values; never null but possibly empty

### input

    public Object input(String name)

  Get the value for the named input to this function. The actual value is returned as-is.

  Parameters:
    `name` - the name of the input parameter
  Returns:
    the (possibly null) value for the named input, or the specified default value if there is no such named parameter

### input

    public <T> T input(String name,
                       Class<T> type,
                       T defaultValue,
                       ExecutionContext context)

  Get the value for the named input to this function. If the actual value corresponds to a `PropertyType`, then the value will be converted to the specified type using the `ExecutionContext`'s `ValueFactories`. Otherwise, the value will simply be cast to the supplied type.

  Type Parameters:
    `T` - the desired type of the value
  Parameters:
    `name` - the name of the input parameter
    `type` - the expected type of the value
    `defaultValue` - the default value to use, if the input doesn't have the named parameter
    `context` - the execution context to be used for converting the value; may not be null
  Returns:
    the (possibly null) value for the named input, or the specified default value if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### input

    public <T> T input(String name,
                       PropertyType type,
                       T defaultValue,
                       ExecutionContext context)

  Get the value for the named input to this function. The actual value will be converted to the specified type using the `ExecutionContext`'s `ValueFactories`.

  Type Parameters:
    `T` - the desired type of the value
  Parameters:
    `name` - the name of the input parameter
    `type` - the expected type of the value
    `defaultValue` - the default value to use, if the input doesn't have the named parameter
    `context` - the execution context to be used for converting the value; may not be null
  Returns:
    the (possibly null) value for the named input, or the specified default value if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### function

    public Function function()

  Get the function implementation

  Returns:
    the function implementation; never null

### outputs

    public Map<String,Serializable> outputs()

  The unmodifiable map of input parameter name to value.

  Returns:
    the map of input names to values; never null but possibly empty

### output

    public Object output(String name)

  Get the value for the named output to this function. The actual value is returned as-is.

  Parameters:
    `name` - the name of the output parameter
  Returns:
    the (possibly null) value for the named output, or null if there is no such named parameter

### output

    public <T> T output(String name,
                        Class<T> type,
                        ExecutionContext context)

  Get the value for the named output to this function.

  Type Parameters:
    `T` - the desired type of the value
  Parameters:
    `name` - the name of the output parameter
    `type` - the expected type of the value used to convert the actual value using the
    `context` - the execution context to be used for converting the value; may not be null
  Returns:
    the (possibly null) value for the named output, or null if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### output

    public <T> T output(String name,
                        Class<T> type,
                        T defaultValue,
                        ExecutionContext context)

  Get the value for the named output to this function.

  Type Parameters:
    `T` - the desired type of the value
  Parameters:
    `name` - the name of the output parameter
    `type` - the expected type of the value used to convert the actual value using the
    `defaultValue` - the default value for the output parameter, if there is no such named parameter
    `context` - the execution context to be used for converting the value; may not be null
  Returns:
    the (possibly null) value for the named output, or the specified default if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### output

    public <T> T output(String name,
                        PropertyType type,
                        T defaultValue,
                        ExecutionContext context)

  Get the value for the named output to this function. The actual value will be converted to the specified type using the `ExecutionContext`'s `ValueFactories`.

  This is a convenience method, as the value would have already been set by the same function invocation using `setOutput(String, Serializable)`.

  Type Parameters:
    `T` - the desired type of the value
  Parameters:
    `name` - the name of the output parameter
    `type` - the expected type of the value
    `defaultValue` - the default value for the output parameter, if there is no such named parameter
    `context` - the execution context to be used for converting the value; may not be null
  Returns:
    the (possibly null) value for the named output, or null if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### setOutput

    public Serializable setOutput(String name,
                                  Serializable value)

  Set the value for the named output parameter for the function. If the value is nul, the parameter will be removed.

  Parameters:
    `name` - the name of the output parameter; may not be null
    `value` - the value for the named parameter; may be null
  Returns:
    the prior value for this named parameter
  Throws:
    `IllegalArgumentException` - if the name is null or empty
    `IllegalStateException` - if the request is frozen

### addActualRequest

    public void addActualRequest(Request request)

  Add an actual request created and executed by the invocation of this function. This method will be called by the `Processor` and should not be called elsewhere.

  Parameters:
    `request` - the request
  Throws:
    `IllegalArgumentException` - if the request reference is null

### addActualRequests

    public void addActualRequests(Iterable<Request> requests)

  Add the actual requests created and executed by the invocation of this function. This method will be called by the `Processor` and should not be called elsewhere.

  Parameters:
    `requests` - the requests
  Throws:
    `IllegalArgumentException` - if the requests reference is null

### getActualRequestCount

    public int getActualRequestCount()

  Get the number of actual requests created and executed by the invocation of this function. This will always be 0 before the request is processed.

  Returns:
    the number of actual requests; never negative

### getActualRequests

    public Iterator<Request> getActualRequests()

  Get the actual requests created and executed by the invocation of this function. These may be read requests or `change requests`.

  Returns:
    the actual requests that the function created and executed; never null

### setActualLocationOfNode

    public void setActualLocationOfNode(Location actual)

  Sets the actual and complete location of the node whose children and properties 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 is null or does not have a path.
    `IllegalStateException` - if the request is frozen

### getActualLocationOfNode

    public Location getActualLocationOfNode()

  Get the actual location of the node whose children and properties 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()`

### 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

### clone

    public FunctionRequest clone()

  This method does not clone the results.

  Overrides:
    `clone` in class `Object`

### convert

    protected final <T> T convert(String name,
                                  Class<T> type,
                                  T defaultValue,
                                  Map<String,Serializable> values,
                                  ExecutionContext context)

### convert

    protected final <T> T convert(String name,
                                  PropertyType type,
                                  T defaultValue,
                                  Map<String,Serializable> values,
                                  ExecutionContext context)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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