com.google.appengine.api.labs.taskqueue
Class TaskOptions

java.lang.Object
  extended by com.google.appengine.api.labs.taskqueue.TaskOptions
All Implemented Interfaces:
java.io.Serializable

public class TaskOptions
extends java.lang.Object
implements java.io.Serializable

Contains various options for a task following the builder pattern. Calls to TaskOptions methods may be chained to specify multiple options in the one TaskOptions object.

Notes on usage:
The recommended way to instantiate a TaskOptions object is to statically import TaskOptions.Builder.* and invoke a static creation method followed by an instance mutator (if needed):

 import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*;

 ...
 QueueFactory.getDefaultQueue().add(header("X-HEADER", "value"));

 

See Also:
Serialized Form

Nested Class Summary
static class TaskOptions.Builder
          Provides static creation methods for TaskOptions.
static class TaskOptions.Method
          Methods supported by Queue.
 
Constructor Summary
TaskOptions(TaskOptions options)
          A copy constructor for TaskOptions.
 
Method Summary
 TaskOptions countdownMillis(long countdownMillis)
          Set the number of milliseconds delay before execution of the task.
 TaskOptions etaMillis(long etaMillis)
          Sets the approximate absolute time to execute.
 TaskOptions header(java.lang.String headerName, java.lang.String value)
          Adds a header name/value pair.
 TaskOptions headers(java.util.Map<java.lang.String,java.lang.String> headers)
          Replaces the existing headers with the provided header name/value mapping.
 TaskOptions method(TaskOptions.Method method)
          Set the method used for this task.
 TaskOptions param(java.lang.String name, byte[] value)
          Add a named byte array parameter.
 TaskOptions param(java.lang.String name, java.lang.String value)
          Add a named String parameter.
 TaskOptions payload(byte[] payload, java.lang.String contentType)
          Set the payload with the given content type.
 TaskOptions payload(java.lang.String payload)
          Set the payload by String.
 TaskOptions payload(java.lang.String payload, java.lang.String charset)
          Sets the payload from a String given a specific character set.
 TaskOptions removeHeader(java.lang.String headerName)
          Remove all headers with the given name.
 TaskOptions removeParam(java.lang.String paramName)
          Remove all parameters with the given name.
 TaskOptions taskName(java.lang.String taskName)
          Sets the task name.
 TaskOptions url(java.lang.String url)
          Set the URL.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskOptions

public TaskOptions(TaskOptions options)
A copy constructor for TaskOptions.

Method Detail

taskName

public TaskOptions taskName(java.lang.String taskName)
Sets the task name.

Throws:
java.lang.IllegalArgumentException - The provided name is null, empty or doesn't match the expected pattern.

payload

public TaskOptions payload(java.lang.String payload,
                           java.lang.String charset)
Sets the payload from a String given a specific character set.

Throws:
UnsupportedTranslationException

payload

public TaskOptions payload(byte[] payload,
                           java.lang.String contentType)
Set the payload with the given content type.

Parameters:
payload - The bytes representing the paylaod.
contentType - The content-type of the bytes.
Returns:
TaskOptions object for chaining.

payload

public TaskOptions payload(java.lang.String payload)
Set the payload by String. The charset to convert the String to will be UTF-8.

Parameters:
payload - The String to be used.
Returns:
TaskOptions object for chaining.

headers

public TaskOptions headers(java.util.Map<java.lang.String,java.lang.String> headers)
Replaces the existing headers with the provided header name/value mapping.

Parameters:
headers - The headers to copy.
Returns:
TaskOptions object for chaining.

header

public TaskOptions header(java.lang.String headerName,
                          java.lang.String value)
Adds a header name/value pair.

Throws:
java.lang.IllegalArgumentException

removeHeader

public TaskOptions removeHeader(java.lang.String headerName)
Remove all headers with the given name.


method

public TaskOptions method(TaskOptions.Method method)
Set the method used for this task. Defaults to TaskOptions.Method.POST.


param

public TaskOptions param(java.lang.String name,
                         java.lang.String value)
Add a named String parameter.

Parameters:
name - Name of the parameter. Must not be null or empty.
value - The value of the parameter will undergo a "UTF-8" character encoding transformation upon being added to the queue. value must not be null.
Throws:
java.lang.IllegalArgumentException

param

public TaskOptions param(java.lang.String name,
                         byte[] value)
Add a named byte array parameter.

Parameters:
name - Name of the parameter. Must not be null or empty.
value - A byte array and encoded as-is (i.e. without character encoding transformations). value must not be null.
Throws:
java.lang.IllegalArgumentException

removeParam

public TaskOptions removeParam(java.lang.String paramName)
Remove all parameters with the given name.

Parameters:
paramName - Name of the parameter. Must not be null or empty.

url

public TaskOptions url(java.lang.String url)
Set the URL.

Default value is null.

Parameters:
url - String containing URL.

countdownMillis

public TaskOptions countdownMillis(long countdownMillis)
Set the number of milliseconds delay before execution of the task.


etaMillis

public TaskOptions etaMillis(long etaMillis)
Sets the approximate absolute time to execute. (i.e. etaMillis is comparable with System.currentTimeMillis()).