cdx.scorebot.util.translator
Class TranslatorIdentifierString
java.lang.Object
cdx.scorebot.util.translator.TypeTranslator<java.lang.String,java.lang.String>
cdx.scorebot.util.translator.TranslatorIdentifierString
- All Implemented Interfaces:
- java.io.Serializable
public class TranslatorIdentifierString
- extends TypeTranslator<java.lang.String,java.lang.String>
Stores a value as a String which meets the requirements as an identifier. When
asked to translate, it allows appropriate identifiers to pass through and throws
a TranslationFailedException otherwise. Spaces are converted to underscores.
- Author:
- David Underhill
- See Also:
- Serialized Form
Method Summary |
java.lang.String |
translate1(java.lang.String valueToTranslate)
returns the String (identifier) passed in |
java.lang.String |
translate2(java.lang.String valueToTranslate)
Checks to see if the specified valueToTranslate is valid identifier |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TranslatorIdentifierString
public TranslatorIdentifierString()
- Instantiates a translator
translate1
public java.lang.String translate1(java.lang.String valueToTranslate)
- returns the String (identifier) passed in
- Specified by:
translate1
in class TypeTranslator<java.lang.String,java.lang.String>
- Parameters:
valueToTranslate
- some identifier (assumed to valid)
- Returns:
- the identifier
translate2
public java.lang.String translate2(java.lang.String valueToTranslate)
throws TranslationFailedException
- Checks to see if the specified valueToTranslate is valid identifier
- Specified by:
translate2
in class TypeTranslator<java.lang.String,java.lang.String>
- Parameters:
valueToTranslate
- some String (should be an identifier)
- Returns:
- the identifier representation of the valueToTranslate (spaces will be
replaced with underscores).
- Throws:
TranslationFailedException
- thrown if the valueToTranslate is an invalid identifier