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.function
Interface FunctionContext

    public interface FunctionContext

The context in which a `Function` is executed.

Method Summary
`Location` | `appliedAt()` Get the location of the node at which the function is to be applied.
`RequestBuilder` | `builder()` Return a build that can be used to build, immediately execute, and return the executed requests.
`void` | `execute(Request request)` Immediately execute the supplied request on this connector.
`ExecutionContext` | `getExecutionContext()` The context in which this function is executing.
`DateTime` | `getNowInUtc()` Get the 'current time' for this processor, which is usually a constant during its lifetime.
`Object` | `input(String name)` Get the value for the named input to this function.
`
`<T> T`
` | `input(String name, Class<T> type)` Get the value for the named input to this function.
`
`<T> T`
` | `input(String name, Class<T> type, T defaultValue)` Get the value for the named input to this function.
`
`<T> T`
` | `input(String name, PropertyType type, T defaultValue)` Get the value for the named input to this function.
`boolean` | `isCancelled()` Determine whether this execution has been cancelled.
`
`<T> T`
` | `output(String name, Class<T> type, T defaultValue)` Get the value for the named output to this function.
`
`<T> T`
` | `output(String name, PropertyType type, T defaultValue)` Get the value for the named output to this function.
`void` | `setError(Throwable t)` Record that an error occurred.
`void` | `setOutput(String name, Serializable value)` Set the value for the named output parameter for the function.
`String` | `workspace()` Get the name of the workspace in which this function is being applied.

Method Detail

### getExecutionContext

    ExecutionContext getExecutionContext()

  The context in which this function is executing.

  Returns:
    the execution context; never null

### appliedAt

    Location appliedAt()

  Get the location of the node at which the function is to be applied.

  Returns:
    the location where the function is to be applied; never null

### workspace

    String workspace()

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

  Returns:
    the workspace name

### input

    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 null if there is no such named parameter

### input

    <T> T input(String name,
                Class<T> type)

  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
  Returns:
    the (possibly null) value for the named input, or null if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### input

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

  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 for the parameter
  Returns:
    the (possibly null) value for the named input, or the default value if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### input

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

  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 for the parameter
  Returns:
    the (possibly null) value for the named input, or the default value if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### output

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

  Get the value for the named output 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.

  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 parameter
  Returns:
    the (possibly null) value for the named output, or the default value if there is no such named parameter
  Throws:
    `ValueFormatException` - if the conversion from to the expected value could not be performed

### output

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

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

    void setOutput(String name,
                   Serializable value)

  Set the value for the named output parameter for the function.

  Parameters:
    `name` - the name of the output parameter; may not be null
    `value` - the value for the named parameter; must be `Serializable`

### execute

    void execute(Request request)

  Immediately execute the supplied request on this connector. Note that the caller is responsible for checking whether the supplied request `has an error`, and if that error results in an error condition of the caller, then the caller is responsible for `setting the error on this context`.

  Parameters:
    `request` - the request to be performed; may not be null
  See Also:
    `builder()`

### builder

    RequestBuilder builder()

  Return a build that can be used to build, immediately execute, and return the executed requests. When this is used, there is no need to `execute(Request)` them manually.

  Returns:
    the builder; never null
  See Also:
    `execute(Request)`

### getNowInUtc

    DateTime getNowInUtc()

  Get the 'current time' for this processor, which is usually a constant during its lifetime.

  Returns:
    the current time in UTC; never null

### setError

    void setError(Throwable t)

  Record that an error occurred.

  Parameters:
    `t` - the exception

### isCancelled

    boolean isCancelled()

  Determine whether this execution has been cancelled. This should be checked periodically in longer-running functions.

  Returns:
    true if the execution has been cancelled, or false otherwise

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.