dochelper
Class NaturalOrderParamProcessor

java.lang.Object
  extended by dochelper.NaturalOrderParamProcessor
All Implemented Interfaces:
Configurable, Processor

public class NaturalOrderParamProcessor
extends java.lang.Object
implements Processor

The class NaturalOrderProcessor imlements a natural order sorting mechanism for rresult trees in DocHelper. It implements the Processor interface in order to perform this task. In order to perform its, task, and depending on the direction parameter, the class uses the java TreeMap that nativley implements a sorted tree using Natural order. The result of executing this Processor on a ResultNode that represents the root of a tree will be to sort all of the leaf nodes in reference only with their sibilings. For this generic processor it is not of to sort leaf nodes with regards to leafs in other sections of the tree becuase this could imply chnaging the structure of the tree(shuffling nodes). In DocHelper the first levels of the tree have semantic meaning: Document --> ReecordSet --> Record. Assigning a match within one Record to another record in other to sort all matches looses information. (In what record a match was found.)


Nested Class Summary
 class NaturalOrderParamProcessor.ParamResultNodeComparator
           
 
Field Summary
protected static java.lang.String DIRECTION
          The direction param name for the nautal order processor (asc-desc)
protected  java.util.HashMap<java.lang.String,java.lang.Object> params
          The paramters that describe this Processor
protected static java.lang.String SORT_PARAM
           
 
Constructor Summary
NaturalOrderParamProcessor()
           
 
Method Summary
 void checkParams()
          Checks that the parameters are correct for this type of Renderer.
 void init()
          Initialize the Renderer.
 ResultNode operate(ResultNode doc)
          Performs an operation on a ResultNode tree and returns the resulting tree after the operation.
private  void orderTree(ResultNode doc)
           
 void setParam(java.lang.String paramName, java.lang.Object value)
          Add a parameter to the Configurable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTION

protected static final java.lang.String DIRECTION
The direction param name for the nautal order processor (asc-desc)

See Also:
Constant Field Values

SORT_PARAM

protected static final java.lang.String SORT_PARAM
See Also:
Constant Field Values

params

protected java.util.HashMap<java.lang.String,java.lang.Object> params
The paramters that describe this Processor

Constructor Detail

NaturalOrderParamProcessor

public NaturalOrderParamProcessor()
Method Detail

operate

public ResultNode operate(ResultNode doc)
Description copied from interface: Processor
Performs an operation on a ResultNode tree and returns the resulting tree after the operation.

Specified by:
operate in interface Processor
Parameters:
doc - The node that represent the root of the tree to process.

orderTree

private void orderTree(ResultNode doc)

setParam

public void setParam(java.lang.String paramName,
                     java.lang.Object value)
              throws IllegalParamterTypeException
Description copied from interface: Configurable
Add a parameter to the Configurable. This mechanism allows options to be set for the Configurable. Things like output path, input path, table names, file types, gob patterns, etc should be passed by setting the appropriate params for a Configurable object. DocHelper will guarantee the following execution flow for all Configurables setParam(), checkParams() and init(). It is the responsibility of this method to check correct types for params used.

Specified by:
setParam in interface Configurable
Parameters:
paramName - String Name of the paramter to be stored
value - String value of the named param
Throws:
IllegalParamterTypeException

checkParams

public void checkParams()
                 throws InvalidValueException,
                        MissingArgumentException,
                        ResourceUnavailableException
Description copied from interface: Configurable
Checks that the parameters are correct for this type of Renderer. Implementor should make sure that required parameters are validated and that any semantic and format rules are enforced. DocHelper guarantees that this method will be called before init() and execute(); This method will not return a boolean indicating success, rather, it will fire an Exception indicating error type

Specified by:
checkParams in interface Configurable
Throws:
InvalidValueException
MissingArgumentException
ResourceUnavailableException

init

public void init()
          throws InitializationException,
                 ResourceUnavailableException
Description copied from interface: Configurable
Initialize the Renderer. The implementor should have this method initialize any connections, file checking, class loading etc, that are neccessary setting up properly for use by the execute method.

Specified by:
init in interface Configurable
Throws:
InitializationException
ResourceUnavailableException