Class BaseToolImpl
java.lang.Object
org.episteme.natural.chemistry.loaders.cml.cmlimpl.BaseToolImpl
- All Implemented Interfaces:
BaseTool
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractBaseprotected static Stringprotected booleanprotected Constructor<?>[]protected Method[]protected AbstractCMLDocumentprotected static Stringprotected static JumboLoggerprotected static Stringprotected WorkflowFields inherited from interface BaseTool
DOUBLE, INTEGER, STRING, XSD_DOUBLE, XSD_INTEGER, XSD_STRING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectednew BaseTool.protectedBaseToolImpl(AbstractBase base) BaseToolImpl(AbstractCMLDocument document) new BaseTool containing a new AbstractBase. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(SaxHandler saxHandler, String content) SAX2 parsing routine - called from characters() callbackstatic voidclears an editorTable.protected voidstatic StringconvertClassToInterface(String className) converts CML classname to interface. e.g. converts org.episteme.natural.chemistry.loaders.cml.cmlimpl.Vector3Impl to org.episteme.natural.chemistry.loaders.cml.CMLVector3 and CMLBaseImpl to AbstractBasestatic StringconvertInterfaceToClass(String interfaceName) converts CMLInterface to class. e.g. converts org.episteme.natural.chemistry.loaders.cml.CMLVector3 to org.episteme.natural.chemistry.loaders.cml.cmlimpl.Vector3Impl and AbstractBase to CMLBaseImplvoidcopyAttributesFromTo(AbstractBase from, AbstractBase to) copy attributes from one AbstractBase to another.static BaseToolcreateToolForName(String baseName) constructs a tools class object.protected voidoutput string if debug setvoidendElement(SaxHandler saxHandler) SAX2 parsing routine - called from endElement() callbackbooleanis the contained object equal to the other contained object.get abstract baseprotected Constructor<?> getConstructor(List<Object> argVector) booleangetDebug()debug statusConstructor<?>[]get all public constructors belonging just to this class.Method[]get all public methods belonging just to this class.protected static double[]getDoubleArgs(int start, int nargs, String[] args) protected MethodgetTestInstance(AbstractCMLDocument doc, int serial) a standard instance for testing. returns null unless subclassedstatic BaseToolgetTool(AbstractBase base) gets tool or creates new one.static BaseToolgetTool(AbstractBase base, BaseTool tool) gets existing tool forbaseor returnstoolafter initialising it withbase.protected MethodgetUniqueMethod(String methodS) gets unique method if possible does not use args at presentget the workflow.protected voidvoidthrows exception if the contained object is not equal to the other contained object.voidmustEqualAttributes(BaseTool otherTool) voidmustEqualChildNodes(BaseTool otherTool) voidprocessArgs(String[] args) process args.intprocessCommandLine(String[] args, int offset, List<Object> argVector, AbstractCMLDocument doc) process the commandline from main routines. normally subclassedvoidprocessCurrentCommand(Workflow workflow) run workflow script or object.removeElement(String elementName) removes the first element by tagNamerunConstructor(List<Object> argVector) run any public constructor introspects the above constructors Example: CMLVector3 projectOnto(CMLVector3 v) is called with v as arg v1, v2 and floatArg as dontCare and returns Object of type CMLVector3run 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 Returns without action if duplicate method namevoidset abstract basevoidsetDebug(boolean d) toggle debuggingvoidsetIgnoreAttribute(String name, boolean descend) ignore an attributestatic voidsetToolPackage(String pName) set Tool package.voidstartElement(SaxHandler saxHandler, Attributes attributes) SAX2 parsing routine - called from startElement() callbackprotected voidsuperInit(AbstractBase base) voidtest all declared public methods. introspects args and creates test instances from primitives or getTestInstance(); cannot create arg which require arrays so skips method also may skip some superclassesvoidtransferChildrenFromTo(AbstractBase from, AbstractBase to) transfer children from one AbstractBase to another.protected voidvoidwrite XML, using class-specific information
-
Field Details
-
jumboLogger
-
editorPackageName
-
CONSTRUCT
-
TEST
-
baseToolTable
-
abstractBase
-
document
-
debug
protected boolean debug -
ignoreAttributeTable
-
workflow
-
declaredPublicMethods
-
declaredPublicConstructors
-
-
Constructor Details
-
BaseToolImpl
protected BaseToolImpl()new BaseTool. only for use by subclasses -
BaseToolImpl
new BaseTool containing a new AbstractBase. uses document as owner- Parameters:
document- the owner document
-
BaseToolImpl
-
-
Method Details
-
superInit
-
getTool
gets tool or creates new one.- Parameters:
base-- Returns:
- the tool (null if molecule is null)
-
getTool
gets existing tool forbaseor returnstoolafter initialising it withbase.- Parameters:
base- the item that you want a tool fortool- the tool to use should base not already have one- Returns:
- the tool (null if molecule is null)
-
getCMLDocument
-
getAbstractBase
get abstract base only defined for implemented editors (default => null)- Specified by:
getAbstractBasein interfaceBaseTool- Returns:
- the element associated with this editor (null for default)
-
setAbstractBase
set abstract base only defined for implemented editors (default => null) should not be required in user code- Specified by:
setAbstractBasein interfaceBaseTool- Parameters:
ab- the element associated with this editor
-
equals
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.) childElements are compared using their equals() methods The editors may have special 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. -
mustEqual
throws exception if the contained object is not equal to the other contained object. see equals() for strategy.- Specified by:
mustEqualin interfaceBaseTool- Parameters:
otherTool- the other element (must be of same class)- Throws:
CMLException- the reason for non-equality
-
mustEqualAttributes
- Throws:
CMLException
-
mustEqualChildNodes
- Throws:
CMLException
-
setIgnoreAttribute
ignore an attribute- Specified by:
setIgnoreAttributein interfaceBaseTool- Parameters:
name- attribute to ignoredescend- carry over to descendants
-
removeElement
removes the first element by tagName finds first element with that name and removes it from its parent. mainly for debugging- Specified by:
removeElementin interfaceBaseTool- Parameters:
elementName-- Returns:
- the element removed
-
characters
SAX2 parsing routine - called from characters() callback NOT namespace aware- Specified by:
charactersin interfaceBaseTool- Parameters:
saxHandler- SaxHandlercontent- throws exception (probably application specific)- Throws:
CMLException
-
endElement
SAX2 parsing routine - called from endElement() callback NOT namespace aware- Specified by:
endElementin interfaceBaseTool- Parameters:
saxHandler- Saxhandler throws exception (probably application specific)- Throws:
CMLException
-
startElement
SAX2 parsing routine - called from startElement() callback NOT namespace aware- Specified by:
startElementin interfaceBaseTool- Parameters:
saxHandler- Saxhandlerattributes- the attribute list throws exception (probably application specific)- Throws:
CMLException
-
writeXML
write XML, using class-specific information NOT namespace aware -
setDebug
public void setDebug(boolean d) toggle debugging- Parameters:
d- debug
-
getDebug
public boolean getDebug()debug status- Returns:
- is debug set
-
debug
-
copyAttributesFromTo
copy attributes from one AbstractBase to another. overwrites existing atts- Specified by:
copyAttributesFromToin interfaceBaseTool- Parameters:
from- element to copy fromto- element to copy to
-
transferChildrenFromTo
transfer children from one AbstractBase to another.- Specified by:
transferChildrenFromToin interfaceBaseTool- Parameters:
from- element to copy fromto- element to copy to
-
clear
clears an editorTable.- Parameters:
editorTable- the table to clear
-
setToolPackage
set Tool package.- Parameters:
pName- the package in which Tools will be found
-
createToolForName
-
processCurrentCommand
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- Specified by:
processCurrentCommandin interfaceBaseTool- Parameters:
workflow- to process.- Throws:
CMLException
-
getWorkflow
get the workflow.- Specified by:
getWorkflowin interfaceBaseTool- Returns:
- workflow
-
formatNumber
-
getDeclaredPublicConstructors
get all public constructors belonging just to this class.- Returns:
- array of constructors
-
getDeclaredPublicMethods
get all public methods belonging just to this class.- Specified by:
getDeclaredPublicMethodsin interfaceBaseTool- Returns:
- array of methods
-
runConstructor
run any public constructor introspects the above constructors Example: CMLVector3 projectOnto(CMLVector3 v) is called with v as arg v1, v2 and floatArg as dontCare and returns Object of type CMLVector3- Parameters:
argVector- arguments in order.- Returns:
- the constructor value
-
runMethod
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 Returns without action if duplicate method name -
getMethod
-
getConstructor
-
getUniqueMethod
-
getDoubleArgs
-
usage
-
constructorsUsage
protected void constructorsUsage() -
methodsUsage
protected void methodsUsage() -
testMethods
public void testMethods()test all declared public methods. introspects args and creates test instances from primitives or getTestInstance(); cannot create arg which require arrays so skips method also may skip some superclasses -
convertInterfaceToClass
converts CMLInterface to class. e.g. converts org.episteme.natural.chemistry.loaders.cml.CMLVector3 to org.episteme.natural.chemistry.loaders.cml.cmlimpl.Vector3Impl and AbstractBase to CMLBaseImpl- Parameters:
interfaceName- the interface- Returns:
- the class name
-
convertClassToInterface
converts CML classname to interface. e.g. converts org.episteme.natural.chemistry.loaders.cml.cmlimpl.Vector3Impl to org.episteme.natural.chemistry.loaders.cml.CMLVector3 and CMLBaseImpl to AbstractBase- Parameters:
className-- Returns:
- the interface name
-
processArgs
-
getTestInstance
a standard instance for testing. returns null unless subclassed- Specified by:
getTestInstancein interfaceBaseTool- Parameters:
doc- the owner documentserial- the instance (1,2,3)- Returns:
- null
-
processCommandLine
public int processCommandLine(String[] args, int offset, List<Object> argVector, AbstractCMLDocument doc) process the commandline from main routines. normally subclassed- Specified by:
processCommandLinein interfaceBaseTool- Parameters:
args- the argumentsoffset- current position in argsargVector- vector to accumulate argumentsdoc- owner document- Returns:
- position in args after parsing
-