uk.ac.bham.gloss
Class Glosser

java.lang.Object
  extended by uk.ac.bham.gloss.Glosser
All Implemented Interfaces:
Locator

public class Glosser
extends java.lang.Object
implements Locator

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. The same glosser once built can parse several token streams producing several XML documents. For information on the format and commands available in the mv file see the modularvocabulary.dtd dtd file and notes further down in the documentation for this class.


Field Summary
 java.lang.String mvURI
          The namespace URI of the mv elements.
 
Constructor Summary
Glosser(org.w3c.dom.Document mV, javax.xml.parsers.DocumentBuilder dB, Logger l)
          Construct a glosser object using the modularvocab from the parsed mv document given and the logger given.
Glosser(java.lang.String modularvocab, Logger l)
          Construct a glosser object using the modularvocab from the URI given and the logger object given.
 
Method Summary
 int col()
          returns -1 to say the column number of position in the MV document is not available
protected  void compileMode(Mode mode)
          This method compiles the mode given.
 java.lang.String doc()
          returns the name of the MV document
 GlossExecution execution()
          The accessor method for the execution object.
protected  Mode findMode(java.lang.String modeName)
          Find the element describing the mode given by modeName.
protected  void getModes(org.w3c.dom.Element mvElt, ParameterContainer prefixes)
          The getModes method collects together all the modes for this MV and compiles or preprocesses them.
 java.lang.String getValue(java.lang.String key)
          Returns the value of the parameter with this name or null if there is no such parameter.
 org.w3c.dom.Document gloss(java.lang.String documentname, java.io.InputStreamReader isr)
          Glosses token data from InputStreamReader "isr" against the modular vocabulary preloaded in this glosser.
 org.w3c.dom.Document gloss(Tokenizer lex)
          Glosses token data from the Tokenizer given against the modular vocabulary preloaded in this glosser.
protected  void initParameters(org.w3c.dom.Element mvElt, ParameterContainer params, ParameterContainer prefixes)
           
 int line()
          returns -1 to say the line number of position in the MV document is not available
 Logger logger()
          accessor for this glosser's logger object
 void putValue(java.lang.String key, java.lang.String value)
          Puts a new parameter into the list of global parameters or overwrites an existing one.
 void putValues(ParameterContainer pc)
          Puts a set of parameter into the list of global parameters.
protected  void resolveMode(Mode m)
          This method resolves any remaining mode attributes from any declared template for that mode.
 void setLogger(Logger l)
          Sets the logger of this glosser.
 
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
Constructor Detail

Glosser

public Glosser(java.lang.String modularvocab,
               Logger l)
        throws org.xml.sax.SAXException,
               javax.xml.parsers.ParserConfigurationException,
               java.io.IOException,
               GlossException
Construct a glosser object using the modularvocab from the URI given and the logger object given.

Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException
GlossException

Glosser

public Glosser(org.w3c.dom.Document mV,
               javax.xml.parsers.DocumentBuilder dB,
               Logger l)
        throws org.xml.sax.SAXException,
               javax.xml.parsers.ParserConfigurationException,
               java.io.IOException,
               GlossException
Construct a glosser object using the modularvocab from the parsed mv document given and the logger given.

Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException
GlossException
Method Detail

logger

public Logger logger()
accessor for this glosser's logger object


setLogger

public void setLogger(Logger l)
Sets the logger of this glosser.


doc

public java.lang.String doc()
returns the name of the MV document

Specified by:
doc in interface Locator

col

public int col()
returns -1 to say the column number of position in the MV document is not available

Specified by:
col in interface Locator

line

public int line()
returns -1 to say the line number of position in the MV document is not available

Specified by:
line in interface Locator

getValue

public java.lang.String getValue(java.lang.String key)
Returns the value of the parameter with this name or null if there is no such parameter.


putValue

public void putValue(java.lang.String key,
                     java.lang.String value)
              throws GlossException
Puts a new parameter into the list of global parameters or overwrites an existing one. Neither argument may be null.

Throws:
GlossException

putValues

public void putValues(ParameterContainer pc)
               throws GlossException
Puts a set of parameter into the list of global parameters.

Throws:
GlossException

execution

public GlossExecution execution()
The accessor method for the execution object.


getModes

protected void getModes(org.w3c.dom.Element mvElt,
                        ParameterContainer prefixes)
                 throws GlossException
The getModes method collects together all the modes for this MV and compiles or preprocesses them. It works recursively on children of mvElt carrying around a list of known prefixes and their current values.

Throws:
GlossException

resolveMode

protected void resolveMode(Mode m)
                    throws GlossException
This method resolves any remaining mode attributes from any declared template for that mode. It is called when a mode has been read, and the modeMap is a map of all known modes.

Throws:
GlossException

compileMode

protected void compileMode(Mode mode)
                    throws GlossException
This method compiles the mode given. In particular it resolves any hooks present in the mode.

Throws:
GlossException

findMode

protected Mode findMode(java.lang.String modeName)
                 throws GlossException
Find the element describing the mode given by modeName.

Throws:
GlossException

gloss

public org.w3c.dom.Document gloss(java.lang.String documentname,
                                  java.io.InputStreamReader isr)
                           throws GlossException,
                                  java.io.IOException
Glosses token data from InputStreamReader "isr" against the modular vocabulary preloaded in this glosser. The parsing is always started in mode "main".

Throws:
GlossException
java.io.IOException

gloss

public org.w3c.dom.Document gloss(Tokenizer lex)
                           throws GlossException
Glosses token data from the Tokenizer given against the modular vocabulary preloaded in this glosser. The parsing is always started in mode "main".

Throws:
GlossException

initParameters

protected void initParameters(org.w3c.dom.Element mvElt,
                              ParameterContainer params,
                              ParameterContainer prefixes)
                       throws GlossException
Throws:
GlossException