notio
Class TranslationContext

java.lang.Object
  |
  +--notio.TranslationContext

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.

See Also:
Serialized Form

Constructor Summary
TranslationContext()
          Constructs a new translation context.
TranslationContext(TranslationContext originalContext)
          Constructs a new translation context that is a copy of the specified original.
 
Method Summary
 void clearDefiningLabelToCoreferenceSetMapping()
          Clears all existing mappings between coreference labels and coreference sets.
 void clearForeignMarkerIDToNativeMarkerMapping()
          Clears all existing mappings between foreign marker ID's and native markers.
 CoreferenceSet getCoreferenceSetByDefiningLabel(java.lang.String definingLabel)
          Returns the coreference set associated with the specified defining label in this translation context.
 java.lang.String getDefiningLabelByCoreferenceSet(CoreferenceSet corefSet)
          Returns the defining label associated with the specified coreference set in this translation context.
 java.lang.String getForeignMarkerIDByNativeMarker(Marker marker)
          Returns the foreign marker ID associated with the specified native marker in this translation context.
 java.lang.String getLastDefiningLabel()
          Returns the last defining label generated by this context or null if no labels have generated.
 Marker getNativeMarkerByForeignMarkerID(java.lang.String foreignID)
          Returns the native marker associated with the specified foreign marker ID in this translation context.
 java.lang.String getNextAvailableDefiningLabel()
          Returns a new defining label that is not already present in the defining label/coreference set mapping.
 void mapDefiningLabelToCoreferenceSet(java.lang.String definingLabel, CoreferenceSet corefSet)
          Creates a two-way mapping between a defining label and a coreference set instance.
 void mapForeignMarkerIDToNativeMarker(java.lang.String foreignID, Marker marker)
          Creates a two-way mapping between a foreign marker ID and a native marker instance.
 void resetAvailableDefiningLabel()
          Resets the generator for defining labels so that it starts again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranslationContext

public TranslationContext()
Constructs a new translation context.

TranslationContext

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

mapDefiningLabelToCoreferenceSet

public void mapDefiningLabelToCoreferenceSet(java.lang.String definingLabel,
                                             CoreferenceSet corefSet)
Creates a two-way mapping between a defining label and a coreference set instance. This table may be used by parsers to associate coreference sets with defining labels. This is particularly necessary for parsing or generating nested graphs with lines of identity. It is difficult for a parser or generator to intelligently decide when this mapping is no longer valid (e.g. when parsing a new graph that uses the same defining labels) so it may be cleared by the user or controlling application using the clearDefiningLabelToCoreferenceSetMapping() method.
Parameters:
definingLabel - the defining label being mapped.
corefSet - the coreference set being mapped.

getCoreferenceSetByDefiningLabel

public CoreferenceSet getCoreferenceSetByDefiningLabel(java.lang.String definingLabel)
Returns the coreference set associated with the specified defining label in this translation context.
Parameters:
definingLabel - the defining label used for lookup.
Returns:
the coreference set associated with definingLabel, or null if no mapping exists.

getDefiningLabelByCoreferenceSet

public java.lang.String getDefiningLabelByCoreferenceSet(CoreferenceSet corefSet)
Returns the defining label associated with the specified coreference set in this translation context.
Parameters:
corefSet - the coreference set used for lookup.
Returns:
the defining label associated with the set, or null if no mapping exists.

clearDefiningLabelToCoreferenceSetMapping

public void clearDefiningLabelToCoreferenceSetMapping()
Clears all existing mappings between coreference labels and coreference sets.

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.

getNextAvailableDefiningLabel

public java.lang.String getNextAvailableDefiningLabel()
Returns a new defining label that is not already present in the defining label/coreference set mapping. There are no constraints on the form of the label other than that they conform to a valid CGIF identifier. Otherwise, labels' forms are determined by the underlying implementation.
Returns:
a new, unique, and unused defining label.

resetAvailableDefiningLabel

public void resetAvailableDefiningLabel()
Resets the generator for defining labels so that it starts again. This method would typically be called after clearing the defining label - coreference set mapping so that labels may be reused in a new translation, if possible. Implementations are not required to honour this although they should silently do nothing rather than throwing an exception. If possible, implementations should reset their label generators so that they produce a sequence of labels as if this were a newly constructed context.

getLastDefiningLabel

public java.lang.String getLastDefiningLabel()
Returns the last defining label generated by this context or null if no labels have generated. Note that this method does not generated any new labels.
Returns:
the last defining label generated by this context or null.


Copyright 1998-1999 Finnegan Southey