org.jscience.ml.cml
Interface BaseTool

All Known Implementing Classes:
BaseToolImpl

public interface BaseTool

Performs editing functions on a generic CMLObject


Field Summary
static java.lang.String DOUBLE
           
static java.lang.String INTEGER
           
static java.lang.String STRING
           
static java.lang.String XSD_DOUBLE
           
static java.lang.String XSD_INTEGER
           
static java.lang.String XSD_STRING
           
 
Method Summary
 void characters(SaxHandler saxHandler, java.lang.String content)
          SAX2 parsing routine - called from characters() callback

NOT namespace aware

 void copyAttributesFromTo(AbstractBase from, AbstractBase to)
          copy attributes from one AbstractBase to another.
 void endElement(SaxHandler saxHandler)
          SAX2 parsing routine - called from endElement() callback

NOT namespace aware

 boolean equals(BaseTool baseTool)
          is the contained object equal to the other contained object.
 AbstractBase getAbstractBase()
          get abstract base.
 java.lang.reflect.Method[] getDeclaredPublicMethods()
          get all public methods belonging just to this class.
 BaseTool getTestInstance(AbstractCMLDocument doc, int serial)
          a standard instance for testing.
 Workflow getWorkflow()
          get the workflow.
 void mustEqual(BaseTool baseTool)
          throws exception if the contained object is not equal to the other contained object.
 int processCommandLine(java.lang.String[] args, int offset, java.util.List argVector, AbstractCMLDocument doc)
          process the commandline from main routines.
 void processCurrentCommand(Workflow workflow)
          run workflow script or object.
 org.w3c.dom.Element removeElement(java.lang.String elementName)
          removes the first element by tagName

finds first element with that name and removes it from its parent.

 java.lang.Object runMethod(java.lang.String methodS, java.util.List argVector)
          run any public method.
 void setAbstractBase(AbstractBase ab)
          set abstract base

only defined for implemented tools (default => null) should not be required in user code

 void setIgnoreAttribute(java.lang.String name, boolean descend)
          ignore an attribute
 void startElement(SaxHandler saxHandler, org.xml.sax.Attributes attributes)
          SAX2 parsing routine - called from startElement() callback

NOT namespace aware

 void transferChildrenFromTo(AbstractBase from, AbstractBase to)
          transfer children from one AbstractBase to another.
 void writeXML(java.io.Writer w, java.lang.String control)
          write XML, using class-specific information

NOT namespace aware

 

Field Detail

DOUBLE

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

INTEGER

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

STRING

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

XSD_DOUBLE

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

XSD_INTEGER

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

XSD_STRING

static final java.lang.String XSD_STRING
See Also:
Constant Field Values
Method Detail

getAbstractBase

AbstractBase getAbstractBase()
get abstract base.

only defined for implemented tools (default => null)

Returns:
the element associated with this tool (null for default)

setAbstractBase

void setAbstractBase(AbstractBase ab)
set abstract base

only defined for implemented tools (default => null) should not be required in user code

Parameters:
ab - the element associated with this tool

setIgnoreAttribute

void setIgnoreAttribute(java.lang.String name,
                        boolean descend)
ignore an attribute

Parameters:
name - attribute to ignore
descend - carry over to descendants

equals

boolean equals(BaseTool baseTool)
is the contained object equal to the other contained object.

The two objects contained in the elements are compared. The default is to use an element-by-element and attribute-by-attribute comparison. This can be overridden for subclasses. For example the order of children in some elements matters while in others (e.g. molecules) it does not. The compared object must be of the same class but may have different namespace prefix, etc. By default ownerDocuments are ignored (thus molecules in different documents can be compared.)

The tools may have sepcial methods to affect of control equality. Thus it is possible to ignore Ids.

If the reason for non-equality is required, the mustEqual() method should be used.

Parameters:
baseTool - the other element tool (must be of same class)

mustEqual

void mustEqual(BaseTool baseTool)
               throws CMLException
throws exception if the contained object is not equal to the other contained object.

Essentially an assert() mechanism; see equals() for strategy.

Parameters:
baseTool - the other element tool (must be of same class)
Throws:
CMLException - the reason for non-equality

removeElement

org.w3c.dom.Element removeElement(java.lang.String elementName)
removes the first element by tagName

finds first element with that name and removes it from its parent. mainly for debugging

Parameters:
elementName -
Returns:
the element removed

characters

void characters(SaxHandler saxHandler,
                java.lang.String content)
                throws CMLException
SAX2 parsing routine - called from characters() callback

NOT namespace aware

Parameters:
saxHandler - SaxHandler
content - throws exception (probably application specific)
Throws:
CMLException

endElement

void endElement(SaxHandler saxHandler)
                throws CMLException
SAX2 parsing routine - called from endElement() callback

NOT namespace aware

Parameters:
saxHandler - Saxhandler throws exception (probably application specific)
Throws:
CMLException

startElement

void startElement(SaxHandler saxHandler,
                  org.xml.sax.Attributes attributes)
                  throws CMLException
SAX2 parsing routine - called from startElement() callback

NOT namespace aware

Parameters:
saxHandler - Saxhandler
attributes - the attribute list throws exception (probably application specific)
Throws:
CMLException

writeXML

void writeXML(java.io.Writer w,
              java.lang.String control)
              throws CMLException,
                     java.io.IOException
write XML, using class-specific information

NOT namespace aware

Parameters:
w - the writer
control - (concatenation of CML version and array)
Throws:
exception - (probably application specific)
CMLException
java.io.IOException

copyAttributesFromTo

void copyAttributesFromTo(AbstractBase from,
                          AbstractBase to)
copy attributes from one AbstractBase to another.

overwrites existing atts

Parameters:
from - element to copy from
to - element to copy to

transferChildrenFromTo

void transferChildrenFromTo(AbstractBase from,
                            AbstractBase to)
transfer children from one AbstractBase to another.

Parameters:
from - element to copy from
to - element to copy to

processCurrentCommand

void processCurrentCommand(Workflow workflow)
                           throws CMLException
run workflow script or object.

sets workflow to the tool and runs the current command all information (current command, symbolTables can be accessed from workflow

Parameters:
workflow - to process.
Throws:
CMLException

getWorkflow

Workflow getWorkflow()
get the workflow.

Returns:
workflow to use with tool

runMethod

java.lang.Object runMethod(java.lang.String methodS,
                           java.util.List argVector)
run any public method. introspects the above methods Example: CMLVector3 projectOnto(CMLVector3 v) is called with v as arg v1, v2 and floatArg as dontCare and returns Object of type CMLVector3

Parameters:
methodS - case-sensitive?. Returns without action if duplicate method name
argVector - arguments in order. First arg is instance of this
Returns:
any return value (see Method.invoke for classes)

getDeclaredPublicMethods

java.lang.reflect.Method[] getDeclaredPublicMethods()
get all public methods belonging just to this class.

Returns:
array of methods

processCommandLine

int processCommandLine(java.lang.String[] args,
                       int offset,
                       java.util.List argVector,
                       AbstractCMLDocument doc)
process the commandline from main routines. normally subclassed

Parameters:
args - the arguments
offset - current position in args
argVector - vector to accumulate arguments
doc - owner document
Returns:
position in args after parsing

getTestInstance

BaseTool getTestInstance(AbstractCMLDocument doc,
                         int serial)
a standard instance for testing. returns null unless subclassed

Parameters:
doc - the owner document
serial - the instance (1,2,3)
Returns:
the new instance (null unless subclassed)