No. Java String objects are immutable; they cannot be changed.
Here is the transform method for the transducer. Since there is only one state (and no reject state) the method is particularly easy.
The toUpperCase(char) method
of the Character class
takes a char as an argument and returns
an uppercase version of that char.
public String transform(String str)
{
char current; // the current character
char caps;
int index = 0 ; // index of the current character
String outString = ""; // the output string the FST produces
// (initialized to an empty string)
if ( str == null ) return null; // check for legal argument
while ( index < str.length() )
{
current = str.charAt( index++ ) ;
if ( current >= 'a' && current <= 'z' )
{
caps = Character.toUpperCase( current );
outString += caps ;
}
else
outString += current ;
}
return outString;
}
What does toUpperCase(char) return if the char
is something other than a lower case character?