notio.translators
Class MarkerTable

java.lang.Object
  |
  +--notio.translators.SimpleInfoUnit
        |
        +--notio.translators.MarkerTable
All Implemented Interfaces:
java.io.Serializable, TranslationInfoUnit

public class MarkerTable
extends SimpleInfoUnit

A TranslationInfoUnit that serves as a symbol table relating foreign markers to native markers.

See Also:
Serialized Form

Constructor Summary
MarkerTable()
          Constructs a new MarkerTable.
MarkerTable(MarkerTable originalTable)
          Constructs a new MarkerTable that is a copy of the specified original.
 
Method Summary
 void clearForeignMarkerIDToNativeMarkerMapping()
          Clears all existing mappings between foreign marker ID's and native markers.
 TranslationInfoUnit copyUnit()
          Returns a duplicate of this information unit that is distinct from the original.
 java.lang.String getForeignMarkerIDByNativeMarker(Marker marker)
          Returns the foreign marker ID associated with the specified native marker in this translation context.
 Marker getNativeMarkerByForeignMarkerID(java.lang.String foreignID)
          Returns the native marker associated with the specified foreign marker ID in this translation context.
 void mapForeignMarkerIDToNativeMarker(java.lang.String foreignID, Marker marker)
          Creates a two-way mapping between a foreign marker ID and a native marker instance.
 void resetUnit()
          Resets this information unit to its initial state.
 
Methods inherited from class notio.translators.SimpleInfoUnit
getUnitName, setUnitName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkerTable

public MarkerTable()
Constructs a new MarkerTable.

MarkerTable

public MarkerTable(MarkerTable originalTable)
Constructs a new MarkerTable that is a copy of the specified original. Changes to the new table will not affect the old one or vice versa.
Parameters:
originalContext - the translation context to be copied.
Method Detail

mapForeignMarkerIDToNativeMarker

public void mapForeignMarkerIDToNativeMarker(java.lang.String foreignID,
                                             Marker marker)
Creates a two-way mapping between a foreign marker ID and a native marker instance. This is used to facilitate marker assignment and lookup while translating. During parsing, newly encountered foreign marker ID's can have a corresponding native marker instantiated and a mapping created. Subsequent references to the foreign ID during during parsing can then use the same native marker. The table may be used for generation purposes in order to preserve consistency between parsed and generated markers. This mapping may need to be cleared in some situations. For example, when parsing two graphs in succession that contain identical foreign marker ID's but whose resulting markers should not be identical internally. Exactly when the table should be cleared should be decided by the application.
Parameters:
foreignID - the foreign marker ID being mapped.
marker - the native marker being mapped.

getNativeMarkerByForeignMarkerID

public Marker getNativeMarkerByForeignMarkerID(java.lang.String foreignID)
Returns the native marker associated with the specified foreign marker ID in this translation context.
Parameters:
foreignID - the foreign marker ID used for lookup.
Returns:
the native marker associated with foreignID, or null if no mapping exists.

getForeignMarkerIDByNativeMarker

public java.lang.String getForeignMarkerIDByNativeMarker(Marker marker)
Returns the foreign marker ID associated with the specified native marker in this translation context.
Parameters:
marker - the native marker used for lookup.
Returns:
the foreign marker ID associated with the marker, or null if no mapping exists.

clearForeignMarkerIDToNativeMarkerMapping

public void clearForeignMarkerIDToNativeMarkerMapping()
Clears all existing mappings between foreign marker ID's and native markers.

resetUnit

public void resetUnit()
Resets this information unit to its initial state. This method can be called by translators in order to ensure that a unit contains no information relating to earlier translation sessions.

copyUnit

public TranslationInfoUnit copyUnit()
Returns a duplicate of this information unit that is distinct from the original. This means that changes to the original will not affect the duplicate and vice versa.
Returns:
a duplicate of this unit.


Copyright 1998-2001 Finnegan Southey