net.sourceforge.nite.gui.util
Class ElementToTextDelegate

java.lang.Object
  extended by net.sourceforge.nite.gui.util.ElementToTextDelegate

public class ElementToTextDelegate
extends java.lang.Object

An ElementToTextDelegate returns a String for any NOMElement passed to it. There are three ways the delegate determines this String. In order of preference these are:

TranscriptionToTextDelegate - setTranscriptionToTextDelegate(TranscriptionToTextDelegate)
This delegate allows the programmer to write their own conversion routine by7 providing their own TranscriptionToTextDelegate.getTextForTranscriptionElement(NOMElement)
Attribute - setTranscriptionAttribute(String)
If the TranscriptionToTextDelegate is null, the attribute on the NOMElement whose name matches this string will be returned, if it exists.
Text Content
If both the TranscriptionToTextDelegate and the Attribute are null, the text returned by NOMElement.getText() will be returned. This is the default.

Author:
Craig Nicol

Constructor Summary
ElementToTextDelegate()
          Construct a default delegate that will return the text content of an element.
ElementToTextDelegate(java.lang.String transcriptionAttribute)
          Create a new ElementToTextDelegate using a specified attribute.
ElementToTextDelegate(TranscriptionToTextDelegate transToTextDelegate)
          Create a new ElementToTextDelegate from a custom TranscriptionToTextDelegate.
 
Method Summary
 java.lang.String getTranscriptionAttribute()
          See the documentation of the method setTranscriptionToTextDelegate
 java.lang.String getTranscriptionText(NOMElement nme)
          This method returns the transcript text of a certain transcription element.
 void setTranscriptionAttribute(java.lang.String newName)
          See the documentation of the method setTranscriptionToTextDelegate
 void setTranscriptionToTextDelegate(TranscriptionToTextDelegate newDelegate)
          There are three ways to determine the text that should be used to represent a certain element tle from the transcription layer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementToTextDelegate

public ElementToTextDelegate()
Construct a default delegate that will return the text content of an element.


ElementToTextDelegate

public ElementToTextDelegate(TranscriptionToTextDelegate transToTextDelegate)
Create a new ElementToTextDelegate from a custom TranscriptionToTextDelegate.

Parameters:
transToTextDelegate - the custom delegate to use

ElementToTextDelegate

public ElementToTextDelegate(java.lang.String transcriptionAttribute)
Create a new ElementToTextDelegate using a specified attribute.

Parameters:
transcriptionAttribute -
Method Detail

setTranscriptionToTextDelegate

public void setTranscriptionToTextDelegate(TranscriptionToTextDelegate newDelegate)
There are three ways to determine the text that should be used to represent a certain element tle from the transcription layer.

The one with the highest precedence is the TranscriptionToTextDelegate. If this parameter is set, the text for element tle is determined by a call to getTextForTranscriptionElement.
The one with the second-highest precedence is the parameter transcriptionAttribute. If there is no TranscriptionToTextDelegate set, and this parameter is non-null, the text for element tle is determined by the value of attribute 'transcriptionAttribute' of that element.
If both above parameters are not set, the text representation of element tle is taken to be the text content of the element.

In order to make the text of a transcription element available independent of these different styles of derivation the method getTranscriptionText(net.sourceforge.nite.nom.nomwrite.NOMElement) is used.


setTranscriptionAttribute

public void setTranscriptionAttribute(java.lang.String newName)
See the documentation of the method setTranscriptionToTextDelegate


getTranscriptionAttribute

public java.lang.String getTranscriptionAttribute()
See the documentation of the method setTranscriptionToTextDelegate


getTranscriptionText

public java.lang.String getTranscriptionText(NOMElement nme)
This method returns the transcript text of a certain transcription element. See transcriptionAttribute for information on how that text is derived.

This method should be used whenever the text content for a certain transcription element is needed.

Parameters:
nme - The NOMElement containing transcription data.
Throws:
java.lang.IllegalArgumentException - If called with wrong TYPE of element (not in transcription layer), an IllegalArgumentException is thrown.
java.util.NoSuchElementException - : If the given element does not contain the right attribute transcriptionAttribute when that attribute is needed, a NoSuchElementException is thrown.