Class Translation

java.lang.Object
  extended by Translation

public class Translation
extends java.lang.Object

This class represents the translation of some piece of text into some other language. But the class does not hold any copy of the original text. So its name is a little misleading. It should be called something like TextFragmentInLanguage.


Field Summary
static java.lang.String FIELDNAME
          this should be dealt with elsewhere such as in the DataFile object
private  java.lang.String languageCode
          An RFC defined 2 letter language code.
static java.lang.String SEPARATOR
          this should be dealt with elsewhere such as in the DataFile object
private  java.lang.String translation
           
 
Constructor Summary
Translation()
           
Translation(java.lang.String sDataString)
           
Translation(java.lang.String sTranslation, java.lang.String sLanguageCode)
           
 
Method Summary
 java.lang.String debug()
           
 java.lang.String getLanguageCode()
          returns a two letter code which represents the human natural language in which this translation is written.
 java.lang.String getTranslation()
          returns some text
static void main(java.lang.String[] args)
          A main method only exists in order to test this class but probably some kind of testing and debugging framework would be less cluttered
 void parseDataString(java.lang.String sDataString)
          if the data string which is supplied to this method is in a format which the object does not recognize, then the object has a choice; either the object could throw some kind of UnrecognizedDataFormatException or the object could quietly set a flag indicating bad data and return.
 java.lang.String print()
          provide a textual representation of the data contained by the Translation object.
 void setTranslation(java.lang.String sNewTranslation)
           
 java.lang.String toString()
          over-ride the default Object class method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

translation

private java.lang.String translation

languageCode

private java.lang.String languageCode
An RFC defined 2 letter language code. Technically this probably should be an enumerated type


FIELDNAME

public static java.lang.String FIELDNAME
this should be dealt with elsewhere such as in the DataFile object


SEPARATOR

public static java.lang.String SEPARATOR
this should be dealt with elsewhere such as in the DataFile object

Constructor Detail

Translation

public Translation(java.lang.String sTranslation,
                   java.lang.String sLanguageCode)

Translation

public Translation()

Translation

public Translation(java.lang.String sDataString)
Method Detail

parseDataString

public void parseDataString(java.lang.String sDataString)
if the data string which is supplied to this method is in a format which the object does not recognize, then the object has a choice; either the object could throw some kind of UnrecognizedDataFormatException or the object could quietly set a flag indicating bad data and return. I tend to be inclined to the latter. My dislike of throwing exceptions is a prejudice about performance; if an exception is thrown then it must be caught, and using try catch blocks seems not to be efficient, but this is more superstition than anything


getTranslation

public java.lang.String getTranslation()
returns some text


getLanguageCode

public java.lang.String getLanguageCode()
returns a two letter code which represents the human natural language in which this translation is written. This 2 letter code should conform to the relevant rfc specification and may be checked by the java Locale class.


setTranslation

public void setTranslation(java.lang.String sNewTranslation)

print

public java.lang.String print()
provide a textual representation of the data contained by the Translation object. The format of this textual representation will depend on the intended use of the string. Another design pattern would be to have only two string output formats: one suitable for the toString method of the object and one suitable for transorming to other formats, such as xml. Another set of classes would handle the transformation to diffent formats. This would reduce the clutter in this class and be more flexible when changing string output formats across several classes. However such an appoach may be overkill.


toString

public java.lang.String toString()
over-ride the default Object class method.

Overrides:
toString in class java.lang.Object

debug

public java.lang.String debug()

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
A main method only exists in order to test this class but probably some kind of testing and debugging framework would be less cluttered

Throws:
java.lang.Exception


Hosted by www.Geocities.ws

1