|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jtr.transliterate.CharacterReplacer
Main class for performing the transliteration operation.
Usage:
String
constructors, which will compile the patterns automatically, or the
CharacterList
constructors, which take pre-compiled patterns
as their arguments.setFlags(int)
if required. The flags available are equivalent
to the Perl flags available for the transliterate operator. The flags are
additive, meaning that more than one can be specified at a time. The flags
themselves are defined in the CharacterParser
class.doReplacement(java.lang.String)
with the String or character array to
be transliterated. The return value is a new string consisting of the
transliterated source.getMatches()
method.Notes:
CharacterReplacer objects should not be considered thread-safe. In particular:
setFlags(int)
method call while another
thread is perfoming a doReplacement(java.lang.String)
call, the results are
undefined.getMatches()
functionality is required, a
doReplacement(java.lang.String)
call should not be executed by more than one
thread.If thread safety is required, consider using the clone()
method
to create new instances.
Constructor Summary | |
CharacterReplacer(CharacterList cSourceChars)
Creates new CharacterReplacer using a pre-compiled CharacterList . |
|
CharacterReplacer(CharacterList cSourceChars,
CharacterList cDestChars)
Creates new CharacterReplacer using pre-compiled CharacterList s. |
|
CharacterReplacer(java.lang.String aSourceChars)
Compiles a transliteration from a String object. |
|
CharacterReplacer(java.lang.String aSourceChars,
java.lang.String aDestChars)
Compiles a transliteration from String objects. |
Method Summary | |
java.lang.Object |
clone()
Return a clone of the current CharacterReplacer . |
java.lang.String |
doReplacement(char[] aSourceString)
Performs a transliteration on the given character array. |
java.lang.String |
doReplacement(java.lang.String aSourceString)
Performs a transliteration operation on the given String . |
int |
getMatches()
Gets the number of matches found by the most recent doReplacement(java.lang.String)
method call. |
void |
setFlags(int nFlags)
Sets or clears flags that are used during the transliteration process. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CharacterReplacer(CharacterList cSourceChars)
CharacterList
.cSourceChars
- the match pattern to be compiledjava.lang.IllegalArgumentException
- cSourceChars is emptyNullPointerException
- cSourceChars is nullpublic CharacterReplacer(CharacterList cSourceChars, CharacterList cDestChars)
CharacterList
s.cSourceChars
- the match pattern to be compiledcDestChars
- the replacement pattern to be compiledjava.lang.IllegalArgumentException
- cSourceChars is emptyNullPointerException
- cSourceChars or cDestChars is nullpublic CharacterReplacer(java.lang.String aSourceChars) throws CharacterParseException
String
object.aSourceChars
- the match pattern to be compiledCharacterParseException
- something went wrong parsing the sourcejava.lang.IllegalArgumentException
- aSourceChars is emptyNullPointerException
- aSourceChars is null
public CharacterReplacer(java.lang.String aSourceChars, java.lang.String aDestChars) throws CharacterParseException
String
objects.aSourceChars
- the match pattern to be compiledaDestChars
- the replacement pattern to be compiledCharacterParseException
- something went wrong parsing either the
source or destinationjava.lang.IllegalArgumentException
- aSourceChars is emptyNullPointerException
- aSourceChars or aDestChars is null
Method Detail |
public java.lang.String doReplacement(java.lang.String aSourceString)
String
.
As a side-effect, once this method has been called, the number of
substitutions performed can be determined by the getMatches()
method.aSourceString
- the string to be transliteratedNullPointerException
- aSourceString is null
public java.lang.String doReplacement(char[] aSourceString)
getMatches()
method.aSourceString
- an array of characters to be transliteratedString
consisting of the transliterated inputNullPointerException
- aSourceString is null
public void setFlags(int nFlags)
Sets or clears flags that are used during the transliteration process. Three flags are defined for transliterations:
These flags are defined in the CharacterParser
class.
public int getMatches()
doReplacement(java.lang.String)
method call. This number includes any characters matched, regardless of
whether the resulting replacement character was the same as the
search character.public java.lang.Object clone()
CharacterReplacer
. This is
particularly useful for situations where thread safety is important.clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |