notio
Class TranslationContext
java.lang.Object
|
+--notio.TranslationContext
- All Implemented Interfaces:
- java.io.Serializable
- public class TranslationContext
- extends java.lang.Object
- implements java.io.Serializable
A class for holding information related to translation so it can be
given to different parsers and generators to ensure consistent
representations. A TranslationContext consists of a set of TranslationInfoUnits.
Translators can add, retrieve, and remove TranslationInfoUnits from a context.
The context has no understanding about the nature of the units it carries and
only a particular translator knows which units it needs and understands. Translators
must agree on a TranslationInfoUnit name and sub-interface in order to share
information. Note that the term 'context' here does not refer to the conceptual
graph idea of a context.
- See Also:
TranslationInfoUnit
,
Parser
,
Generator
, Serialized Form
Constructor Summary |
TranslationContext()
Constructs a new TranslationContext containing no TranslationInfoUnits. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TranslationContext
public TranslationContext()
- Constructs a new TranslationContext containing no TranslationInfoUnits.
addUnit
public void addUnit(TranslationInfoUnit newUnit)
- Adds the specified unit to this context under the unit's name. The name is
determined by a call to getUnitName() in the unit. If the unit is already part
of this context, nothing happens. If another unit has been added to this context
under the same name, it is replaced by the new unit.
- Parameters:
newUnit
- the unit to be added.- Throws:
java.IllegalArgumentException
- if the unit's name is null.- See Also:
TranslationInfoUnit.getUnitName()
removeUnit
public void removeUnit(TranslationInfoUnit deadUnit)
- Removes the specified unit from this context. If the unit is not part of this
context, nothing happens.
- Parameters:
deadUnit
- the unit to be removed.
getUnit
public TranslationInfoUnit getUnit(java.lang.String unitName)
- Returns the unit corresponding to the specified name, or null if no unit with that
name is currently in this context.
- Parameters:
unitName
- the name of the unit being retrieved.
resetUnits
public void resetUnits()
- Calls resetUnit() in all units in this context.
This effectively clears all information relating to earlier translation sessions
from this context.
- See Also:
TranslationInfoUnit.resetUnit()
Copyright 1998-2001 Finnegan Southey