SMILA 1.0 API documentation

org.eclipse.smila.taskworker.output
Class Outputs

java.lang.Object
  extended by org.eclipse.smila.taskworker.io.IODataObjects
      extended by org.eclipse.smila.taskworker.output.Outputs

public class Outputs
extends IODataObjects

Returned by TaskContext.getOutputs() this class provides access to the data objects associated by a task to the output slots of a worker. It can create different kinds of Output wrappers on these data objects that make access for the workers easier. You can create only a single output wrapper for each data object. On the second call, only null will be returned.

See Also:
StreamOutput, RecordOutput, KvoOutput, AppendableOutput

Field Summary
 
Fields inherited from class org.eclipse.smila.taskworker.io.IODataObjects
_dataObjects, _ioData
 
Constructor Summary
Outputs(java.util.Map<java.lang.String,java.util.List<BulkInfo>> dataObjects, ObjectStoreService objectStore)
           
 
Method Summary
 void abortAll()
          Abort all open data objects, if necessary.
 void addOutputCounters(java.util.Map<java.lang.String,java.lang.Number> counters)
          aggregate counters of output slots.
protected  boolean canCreate(java.lang.String slotName, int index)
          check if index is valid for slotname and no input object has yet been created for this object.
 void commitAll()
          Commit all open data objects, if necessary.
<T extends Output>
T
getAsOutput(java.lang.String slotName, java.lang.Class<T> inputClass)
          Generic method to create output wrapper for the first data object in a slot.
<T extends Output>
T
getAsOutput(java.lang.String slotName, int index, java.lang.Class<T> outputClass)
          Generic method to create output wrappers.
 RecordOutput getAsRecordOutput(java.lang.String slotName)
           
 RecordOutput getAsRecordOutput(java.lang.String slotName, int index)
           
 StreamOutput getAsStreamOutput(java.lang.String slotName)
           
 StreamOutput getAsStreamOutput(java.lang.String slotName, int index)
           
 BulkInfo getDataObject(java.lang.String slotName, int index)
           
protected  boolean isMultiple(java.lang.String slotName)
           
 void setOutputModes(java.util.Map<java.lang.String,java.util.Collection<OutputMode>> outputModes)
           
 
Methods inherited from class org.eclipse.smila.taskworker.io.IODataObjects
addCounters, getDataObject, getDataObjectCount, getIOData, getObjectStore, putIOData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Outputs

public Outputs(java.util.Map<java.lang.String,java.util.List<BulkInfo>> dataObjects,
               ObjectStoreService objectStore)
Parameters:
dataObjects - The data objects
objectStore - The reference to the object store service
Method Detail

setOutputModes

public void setOutputModes(java.util.Map<java.lang.String,java.util.Collection<OutputMode>> outputModes)
Parameters:
outputModes - the output modes for the output slots.

getAsOutput

public <T extends Output> T getAsOutput(java.lang.String slotName,
                                        java.lang.Class<T> inputClass)
Generic method to create output wrapper for the first data object in a slot. See getAsOutput(String, int, Class) for details, this method just calls this method with index = 0

Returns:
first data object in given slot prepared for custom access. Null, if slot is not set, or an output wrapper has already been created earlier.
Throws:
java.lang.IllegalArgumentException - if the outputClass cannot be instantiated.

getAsOutput

public <T extends Output> T getAsOutput(java.lang.String slotName,
                                        int index,
                                        java.lang.Class<T> outputClass)
Generic method to create output wrappers. Any predefined subclass of Output can be used as well as custom defined class if you need it (be sure to implement the necessary constructor). For example, to get an Key-Value-Object wrapper for the first object in slot "kvoOutputSlot", use KvoOutput kvo = taskContext.getOutputs().getAsOutput("kvoOutputSlot", KvoOutput.class);

Returns:
n-th data object in given slot prepared for custom access. Null, if slot is not set, has less objects, or a wrapper has already been created earlier.
Throws:
java.lang.IllegalArgumentException - if the outputClass cannot be instantiated.
See Also:
StreamOutput, RecordOutput, KvoOutput, AppendableOutput

getAsStreamOutput

public StreamOutput getAsStreamOutput(java.lang.String slotName,
                                      int index)
Parameters:
slotName - The slot name
index - The index
Returns:
The data object as StreamOutput with given slot name and index

getAsStreamOutput

public StreamOutput getAsStreamOutput(java.lang.String slotName)
Parameters:
slotName - The slot name
Returns:
The first data object as StreamOutput with given slot name

getAsRecordOutput

public RecordOutput getAsRecordOutput(java.lang.String slotName,
                                      int index)
Parameters:
slotName - The slot name
index - The index
Returns:
The data object as RecordOutput with given slot name and index

getAsRecordOutput

public RecordOutput getAsRecordOutput(java.lang.String slotName)
Parameters:
slotName - The slot name
Returns:
The first data object as RecordOutput with given slot name

commitAll

public void commitAll()
               throws ObjectStoreException,
                      java.io.IOException
Commit all open data objects, if necessary. Called by WorkerManager after task has finished.

Throws:
ObjectStoreException
java.io.IOException

abortAll

public void abortAll()
              throws ObjectStoreException,
                     java.io.IOException
Abort all open data objects, if necessary. Called by WorkerManager after task has finished.

Throws:
ObjectStoreException
java.io.IOException

addOutputCounters

public void addOutputCounters(java.util.Map<java.lang.String,java.lang.Number> counters)
aggregate counters of output slots. Called by WorkerManager after task has finished.


isMultiple

protected boolean isMultiple(java.lang.String slotName)
Returns:
whether given slot can have multiple output objects.

canCreate

protected boolean canCreate(java.lang.String slotName,
                            int index)
Description copied from class: IODataObjects
check if index is valid for slotname and no input object has yet been created for this object.

Overrides:
canCreate in class IODataObjects

getDataObject

public BulkInfo getDataObject(java.lang.String slotName,
                              int index)
Overrides:
getDataObject in class IODataObjects
Returns:
n-th data object in given slot. Null, if slot is not set or has less objects.

SMILA 1.0 API documentation