uk.ac.bham.gloss
Class ModeExecution

java.lang.Object
  extended by uk.ac.bham.gloss.Mode
      extended by uk.ac.bham.gloss.ModeExecution

public class ModeExecution
extends Mode

A mode is a record of various data within the mv:mode tag. Several of these are needed to gloss a text file: this class represents the run-time data and execution of a mode. A mode executes in the context of a glosser, and gloss execution, with a tokenizer and a place to put output. A mode has certain data and attributes read from the parsed XML MV file.


Field Summary
 java.lang.String mvURI
          The namespace URI of the mv elements.
 
Fields inherited from class uk.ac.bham.gloss.Mode
acceptDef, capturedModes, children, childrenDef, EXECUTE_TYPE, executeMode, INCLUDE_TYPE, modeElt, modeElts, modeName, modeType, postProcessMode, preProcessMode, PROCESS_TYPE, processMode, template, templateDef, typeString, UNDEFINED_TYPE, useIndentation, useIndentationDef
 
Constructor Summary
ModeExecution(Glosser g, Mode m, Tokenizer l, Mode pME, Mode pTok, ParameterContainer pc, org.w3c.dom.Node n)
          constructor: construct a ModeExecution from Mode m, Tokenizer l, Glosser g and parent p, putting data in output Node n.
 
Method Summary
 java.lang.String accept()
          returns the "accept" attribute
 void adjustChildren(int v)
          add or subtract to/from total number of children
 org.w3c.dom.NodeList children()
          returns the children of the mode
 int childrenToFind()
          returns the number of children to find
 int depth()
          Returns the depth of the current token read by this mode.
protected  void execute()
           
 GlossExecution execution()
          accessor
 void exportParameter(java.lang.String name, ParameterContainer pc)
          Exports the value of the parameter "name" from "pc" to the parent ME, and continues recursively exporting to other ancestors; the last ancestor exported to is the first found in the same namespace, or the root if no such ancestor is found.
protected  org.w3c.dom.Element findMatch(Mode mode, Token tok, ParameterContainer params)
          This method searches for a match for token tok amongst the nodes in the mode mode (and any included modes linked from this).
 Glosser glosser()
          accessor
 boolean inheritParent()
          returns the use inherit-parent status
 Tokenizer lex()
          accessor
 Logger logger()
          accessor
 ModeExecution makeChild(Mode mode, Tokenizer l, ParameterContainer pc, org.w3c.dom.Node n)
          factory method: makes a child ModeExecution object
 java.lang.String name()
          Returns the name of the current mode being executed.
protected  Mode newModeAfterMatch()
          This variable contains a reference to the new mode included from the current one after doing findMatch.
 org.w3c.dom.Node outpNode()
          accessor
 ParameterContainer parameters()
          Returns ParameterContainer for this mode
 Mode parent()
          returns the parent mode
 Mode parentTok()
          returns the parent mode
 ParameterContainer prefixes()
          Returns the container of prefixes.
 void setChildrenRemaining(int v)
          set number of children remaining
 void setChildrenTotal(int v)
          set total number of children
 void setExecuteTokenMode(boolean val)
          Sets "execute token mode" which is a special mode in which all children="..." and children-XXX="..." attributes are ignored and a single token is executed then control is returned.
 ModeExecution setInheritParent(boolean ip)
          returns the state of this mode, whether it should inherit its parent
 ModeExecution setUseIndentation(boolean ui)
          overrides default behaviour for this mode (set in <mv:mode ...> element) to use or not use indentation.
protected  boolean testMatch(Token tok, java.lang.String matchStr, java.lang.String attrname)
          Performs a match of tok against matchStr, where matchStr is a non-null strings.
 Token token()
          Returns the current token read by this mode.
 java.lang.String toString()
          Returns a string representation of this mode.
 boolean useIndentation()
          returns the use indentation status
 
Methods inherited from class uk.ac.bham.gloss.Mode
actionMode, executeMode, getCapturedMode, isExecuteType, isIncludeType, isProcessType, isUndefinedType, node, postProcessMode, preProcessMode, processMode, resolvePrefix, setAccept, setActionMode, setCapturedMode, type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mvURI

public final java.lang.String mvURI
The namespace URI of the mv elements.

See Also:
Constant Field Values
Constructor Detail

ModeExecution

public ModeExecution(Glosser g,
                     Mode m,
                     Tokenizer l,
                     Mode pME,
                     Mode pTok,
                     ParameterContainer pc,
                     org.w3c.dom.Node n)
constructor: construct a ModeExecution from Mode m, Tokenizer l, Glosser g and parent p, putting data in output Node n.

Method Detail

glosser

public Glosser glosser()
accessor


execution

public GlossExecution execution()
accessor


lex

public Tokenizer lex()
accessor


outpNode

public org.w3c.dom.Node outpNode()
accessor


logger

public Logger logger()
accessor


setExecuteTokenMode

public void setExecuteTokenMode(boolean val)
Sets "execute token mode" which is a special mode in which all children="..." and children-XXX="..." attributes are ignored and a single token is executed then control is returned. By default this mode is false.


accept

public java.lang.String accept()
returns the "accept" attribute

Overrides:
accept in class Mode

useIndentation

public boolean useIndentation()
returns the use indentation status

Overrides:
useIndentation in class Mode

setUseIndentation

public ModeExecution setUseIndentation(boolean ui)
overrides default behaviour for this mode (set in <mv:mode ...> element) to use or not use indentation. Returns this ModeExecution object.


inheritParent

public boolean inheritParent()
returns the use inherit-parent status


setInheritParent

public ModeExecution setInheritParent(boolean ip)
returns the state of this mode, whether it should inherit its parent


children

public org.w3c.dom.NodeList children()
returns the children of the mode

Overrides:
children in class Mode

prefixes

public ParameterContainer prefixes()
Returns the container of prefixes.

Overrides:
prefixes in class Mode

toString

public java.lang.String toString()
Returns a string representation of this mode.

Overrides:
toString in class Mode

parameters

public ParameterContainer parameters()
Returns ParameterContainer for this mode


parent

public Mode parent()
returns the parent mode

Overrides:
parent in class Mode

parentTok

public Mode parentTok()
returns the parent mode


name

public java.lang.String name()
Returns the name of the current mode being executed.

Overrides:
name in class Mode

token

public Token token()
Returns the current token read by this mode.

Overrides:
token in class Mode

depth

public int depth()
Returns the depth of the current token read by this mode.

Overrides:
depth in class Mode

setChildrenTotal

public void setChildrenTotal(int v)
set total number of children


adjustChildren

public void adjustChildren(int v)
add or subtract to/from total number of children


setChildrenRemaining

public void setChildrenRemaining(int v)
set number of children remaining


childrenToFind

public int childrenToFind()
returns the number of children to find

Overrides:
childrenToFind in class Mode

exportParameter

public void exportParameter(java.lang.String name,
                            ParameterContainer pc)
                     throws GlossException
Exports the value of the parameter "name" from "pc" to the parent ME, and continues recursively exporting to other ancestors; the last ancestor exported to is the first found in the same namespace, or the root if no such ancestor is found.

Throws:
GlossException

makeChild

public ModeExecution makeChild(Mode mode,
                               Tokenizer l,
                               ParameterContainer pc,
                               org.w3c.dom.Node n)
                        throws GlossException
factory method: makes a child ModeExecution object

Throws:
GlossException

execute

protected void execute()
                throws GlossException
Throws:
GlossException

newModeAfterMatch

protected Mode newModeAfterMatch()
This variable contains a reference to the new mode included from the current one after doing findMatch. It will be null unless findMatch(...) returns a node from a different Mode.


testMatch

protected boolean testMatch(Token tok,
                            java.lang.String matchStr,
                            java.lang.String attrname)
                     throws GlossException
Performs a match of tok against matchStr, where matchStr is a non-null strings. If matchStr does not start with '$' then this is the same as equality of strings. Otherwise matchStr = "$xxx--yyy||zzz||uuu--vvv||www" or something like this; characters \ - or | (or any other) in xxx etc should be escaped with \. The parameter type is the type of the token and determines range etc. The attrname argument says whether token data, value, fullname localname, or prefix is to be matched.

Throws:
GlossException

findMatch

protected org.w3c.dom.Element findMatch(Mode mode,
                                        Token tok,
                                        ParameterContainer params)
                                 throws GlossException
This method searches for a match for token tok amongst the nodes in the mode mode (and any included modes linked from this). It returns a matching mv:match or mv:default node, or null if none can be found. It also sets newModeAfterMatch() to null if there is no match or the match was found in this mode, or to the successful included mode otherwise.

Throws:
GlossException