Interface BaseTool

All Known Implementing Classes:
BaseToolImpl

public interface BaseTool
Performs editing functions on a generic CMLObject
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Field Details

  • Method Details

    • 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(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

      Element removeElement(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, 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, 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(Writer w, String control) throws CMLException, IOException
      write XML, using class-specific information

      NOT namespace aware

      Parameters:
      w - the writer
      control - (concatenation of CML version and array)
    • 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

      Object runMethod(String methodS, List<Object> 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

      Method[] getDeclaredPublicMethods()
      get all public methods belonging just to this class.
      Returns:
      array of methods
    • processCommandLine

      int processCommandLine(String[] args, int offset, List<Object> 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)