uk.ac.bham.gloss
Class GlossExecution

java.lang.Object
  extended by uk.ac.bham.gloss.GlossExecution

public class GlossExecution
extends java.lang.Object

A glosser for this system is an binary object that represents a modular vocabulary, ie, it is able to read tokens from a token stream (a Tokenizer object) and create an XML document. This class represents a "run time libary" of methods for such glosses. Copyright Richard Kaye 2007-8 for GLOSS, http://gloss.bham.ac.uk Usage permitted according to the GPL. No waranty.


Field Summary
 java.lang.String mvURI
          The namespace URI of the mv elements.
 java.lang.String mvXMLNS
          The namespace of parameters defining XML namespaces for elements.
 java.lang.String xrURI
          The namespace URI of the xr elements.
 
Constructor Summary
GlossExecution(Glosser g)
           
 
Method Summary
protected  boolean execute(ModeExecution mode, Tokenizer lex, org.w3c.dom.Node exNode, org.w3c.dom.Node outpNode, ParameterContainer params, boolean preserveSpace)
          This method executes all commands given in the children of the node exNode that arises when in mode mode with the output data inserted into outpNode.
protected  java.lang.String getNSfromPars(java.lang.String name, ParameterContainer params)
           
protected  java.lang.String interpolateAttr(java.lang.String attname, java.lang.String defaultVal, org.w3c.dom.Node node, Mode mode, ParameterContainer params)
          Gets an attr="..." attribute from node and returns its value, interpolated against token, params and modeName.
protected  java.lang.String interpolateText(java.lang.String inputString, Mode mode, ParameterContainer params)
          Interpolates several $escapes in pattern: The process is as follows.
protected  java.lang.String interpolateText(java.lang.String inputString, Mode mode, ParameterContainer params, boolean useprefixes)
          version of interpolateText where we can select whether or not to use prefixes
static boolean isWhiteSpace(java.lang.String text)
          returns true if the string is entirely white space false otherwise.
protected  java.lang.String resolvePrefix(java.lang.String name, ParameterContainer prefixes)
          Resolves a name such as "pref:localpart" to "{uri}localpart" Here, uri is the value of "pref" in prefixes.
protected  void startSubProcess(Mode eMode, java.lang.String reference, java.lang.String childrenAttr, java.lang.String useIndAttr, java.lang.String paramAttr, Tokenizer lex, ParameterContainer newparams, org.w3c.dom.Node outpNode, ModeExecution mode, boolean executemode, boolean resolveMode, boolean warnings)
          Starts a new subprocess, ie, a new mode execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mvURI

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

See Also:
Constant Field Values

mvXMLNS

public final java.lang.String mvXMLNS
The namespace of parameters defining XML namespaces for elements.

See Also:
Constant Field Values

xrURI

public final java.lang.String xrURI
The namespace URI of the xr elements.

See Also:
Constant Field Values
Constructor Detail

GlossExecution

public GlossExecution(Glosser g)
Method Detail

isWhiteSpace

public static boolean isWhiteSpace(java.lang.String text)
returns true if the string is entirely white space false otherwise.


execute

protected boolean execute(ModeExecution mode,
                          Tokenizer lex,
                          org.w3c.dom.Node exNode,
                          org.w3c.dom.Node outpNode,
                          ParameterContainer params,
                          boolean preserveSpace)
                   throws GlossException
This method executes all commands given in the children of the node exNode that arises when in mode mode with the output data inserted into outpNode. Returns true if a "return" or "abort" instruction was encountered, false otherwise.

Throws:
GlossException

getNSfromPars

protected java.lang.String getNSfromPars(java.lang.String name,
                                         ParameterContainer params)

interpolateText

protected java.lang.String interpolateText(java.lang.String inputString,
                                           Mode mode,
                                           ParameterContainer params)
                                    throws GlossException
Interpolates several $escapes in pattern: The process is as follows. If the input string is a literal '...' with at least two characters then the content ... is returned verbatim without interpolation. Else we next resolve the resulting string (once) against prefixes; only literal prefixes will be resolved here. Thus pref:... is converted to {uriforpref}... The result is interpolated following the rules: $$ inserts a single $ $: inserts a single : $ (when at end of string) inserts $ ${name} inserts the value of parameter "name" after "name" is itself interpolated (prefix resolution is only performed on "name" if it was given literally and not itself the result of interpolation) or the empty string if "name" is not initialised $d inserts the full data for tok $i inserts the indentation depth (= $c if this is the first token on the line) $n inserts the local name of tok $p inserts the namespace prefix of tok $q inserts the full (qualified) name of tok, equal to either $p:$n or $n $v inserts the value of tok, eg of attribute or nsprefix $l inserts the line number of tok $c inserts the column number of tok $m inserts modeName $x for any other character x, inserts x arguments may be null in which case the relevant interpolants are empty.

Throws:
GlossException

interpolateText

protected java.lang.String interpolateText(java.lang.String inputString,
                                           Mode mode,
                                           ParameterContainer params,
                                           boolean useprefixes)
                                    throws GlossException
version of interpolateText where we can select whether or not to use prefixes

Throws:
GlossException

resolvePrefix

protected java.lang.String resolvePrefix(java.lang.String name,
                                         ParameterContainer prefixes)
                                  throws GlossException
Resolves a name such as "pref:localpart" to "{uri}localpart" Here, uri is the value of "pref" in prefixes.

Throws:
GlossException

interpolateAttr

protected java.lang.String interpolateAttr(java.lang.String attname,
                                           java.lang.String defaultVal,
                                           org.w3c.dom.Node node,
                                           Mode mode,
                                           ParameterContainer params)
                                    throws GlossException
Gets an attr="..." attribute from node and returns its value, interpolated against token, params and modeName. The argument "defaultVal" gives a default value if no such attribute is found or if its value is the empty string.

Throws:
GlossException

startSubProcess

protected void startSubProcess(Mode eMode,
                               java.lang.String reference,
                               java.lang.String childrenAttr,
                               java.lang.String useIndAttr,
                               java.lang.String paramAttr,
                               Tokenizer lex,
                               ParameterContainer newparams,
                               org.w3c.dom.Node outpNode,
                               ModeExecution mode,
                               boolean executemode,
                               boolean resolveMode,
                               boolean warnings)
                        throws GlossException
Starts a new subprocess, ie, a new mode execution. The parameters are as follows. eMode: the new mod to start; reference: a name for the parent process to use in error messages; childrenAttr: the children attribute, ie number of child tokens; useIndAttr: the use-indentation attribute; paramAttr: the parameters attribute; outpNode: the node to write to; mode: the current ModeExecution; executemode: true for "execute", false for "process-tokens"; resolveMode: whether to follow the chain of hooks or use eMode directly.

Throws:
GlossException