|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jtr.transliterate.Perl5Parser
A utility class for providing Perl 5 syntactic sugar on top of the
CharacterParser
class. This parses Perl-style transliteration strings
into a form suitable for CharacterParser
. For instance, the
string "tr/a-zA-Z/0-9a-zA-Z/cd"
is parsed into two strings
"a-zA-Z"
, "0-9a-zA-Z"
, and the flags
COMPLEMENT_MASK | DELETE_UNREPLACEABLES_MASK
.
Method Summary | |
static void |
main(java.lang.String[] args)
A simple test case for this class. |
static CharacterReplacer |
makeReplacer(java.lang.String source)
Parses the given string in Perl syntax and returns a populated CharacterReplacer object that can be used to perform the
specified transliteration. |
static int |
parsePerlString(java.lang.String source,
java.lang.StringBuffer input,
java.lang.StringBuffer output)
Parses the given Perl-style transliteration string into two parts: |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static CharacterReplacer makeReplacer(java.lang.String source) throws CharacterParseException
Parses the given string in Perl syntax and returns a populated
CharacterReplacer
object that can be used to perform the
specified transliteration.
This is a simple factory method that calls the parsePerlString
method below, creates a new CharacterReplacer
object and populates it with the results.
source
- the String to be parsed and compiledCharacterParseException
- something went wrong during parsingNullPointerException
- source is null
public static int parsePerlString(java.lang.String source, java.lang.StringBuffer input, java.lang.StringBuffer output) throws CharacterParseException
Parses the given Perl-style transliteration string into two parts:
These strings can then be fed into the constructors for
CharacterReplacer
. It also returns any flags encountered at the
end of the string into a form suitable for CharacterReplacer.
source
- the string to be parsedinput
- (out) the characters to be transliteratedoutput
- (out) the replacement charactersCharacterParseException
- there was a problem parsing the source
StringNullPointerException
- source is null
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- ignoredjava.lang.Exception
- if an exception is encountered, throw it to the caller
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |