org.activemath.presentation.preproc
Interface Task

All Known Implementing Classes:
OmletExpresserTask, PrepareForCnPTask, RefEncoderTask, SymbolDeclarationsTask

public interface Task

A Task is a general processing unit that is called on each of the elements being walked through by the PreProcessor. A task can be purely functional or have some state. In both case, the pre-processor obtains it through a ProxyFactory, weather the latter returns always the same or not, reflects the stateful/purely-functional character of the task.

Tasks are not allowed to throw exceptions. Instead, they should report these errors using the log4j mechanism in a category starting with preproc and their perform(java.util.ListIterator, org.jdom.Element, java.util.Map) method should return false to prevent going down the children hierarchy.

Version:

Field Summary
static String CVS_ID
           
 
Method Summary
 void close()
          Invoked by the pre-processor at the end of PreProcessor.run(org.jdom.Element, java.util.Map).
 void open()
          Invoked by the pre-processor at the beginning of PreProcessor.run(org.jdom.Element, java.util.Map).
 boolean perform(ListIterator currentPos, org.jdom.Element elt, Map properties)
          Invoked by the pre-processor on an element elt to be processed by the task.
 

Field Detail

CVS_ID

static final String CVS_ID
See Also:
Constant Field Values
Method Detail

perform

boolean perform(ListIterator currentPos,
                org.jdom.Element elt,
                Map properties)
Invoked by the pre-processor on an element elt to be processed by the task.

Modifications like replacing, removing or adding an element to the parent of elt should only be performed using the currentPos list-iterator (and, as of this writing, such an operation would fail with JDOM b7 unless your element objects are OJElements. This will be fixed in further release of JDOM).

A task performance should not throw an exception unless the task cannot continue walking the subelements.

Parameters:
elt - the element to process
currentPos - the iterator of all elements child of the same parent, currently enumerating this element may be null in which case the parent was not enumerated (i.e. when elt is the element called on PreProcessor.run(org.jdom.Element, java.util.Map).
properties - An object that lives during the performance and can be used to extract and store states and parameters for the processing action. Typical values include the user and session (as string in keys and value). Properties are passed at startup (i.e. in TaskFactory.make(org.jdom.Element, java.util.Map) and at each perform, they are the same object throughout.

open

void open()
Invoked by the pre-processor at the beginning of PreProcessor.run(org.jdom.Element, java.util.Map).


close

void close()
Invoked by the pre-processor at the end of PreProcessor.run(org.jdom.Element, java.util.Map).