Package overit.geocall.util
Class FormatTokenizer
java.lang.Object
overit.geocall.util.FormatTokenizer
Auxiliary class to extract tokens from a string called format. The tokens are
searched through two delimiter characters. See the constructor
FormatTokenizer(format,c1,c2) for more information on how tokens are created.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFormatTokenizer(String format, char c1, char c2) The constructor that defines the string called format from which the tokens will be extracted, and the two characthers that delimit the token.
A token can be of two types:formatted:the part of the format that starts with the first input character and ends with the second input character. -
Method Summary
-
Field Details
-
_begin
protected int _begin -
_format
-
_c1
protected char _c1 -
_c2
protected char _c2
-
-
Constructor Details
-
FormatTokenizer
The constructor that defines the string called format from which the tokens will be extracted, and the two characthers that delimit the token.
A token can be of two types:formatted:the part of the format that starts with the first input character and ends with the second input character. The token contains the two delimiter characters;constant:the part of the format between two formatted tokens. This token doesn't contains the delimiter characters.
"{0{Someone has filled}{| has filled}{P||Jane Doe has filled}{L||Baby Doe has filled}} the bath tub{1{}{ of |}}"
contains a first formatted token ("{0{Someone has filled}{| has filled} {P||Jane Doe has filled}{L||Baby Doe has filled}}"), a first constant token (" the bath tub") and a second formatted token ("{1{}{ of |}}").- Parameters:
format- The string to elaborate containing the tokens.c1- The first delimiter character.c2- The second delimiter character.
-
-
Method Details
-
hasNext
public boolean hasNext()Check if there are still tokens to analyze.- Returns:
- The boolean to indicate if there are still tokens.
-
next
Locate and return the next token to analyze. See the constructorFormatTokenizer(format,c1,c2)to understand how a token is defined.- Returns:
- The string containing the next token.
-
isFormat
Return if the string passed as input is a formatted string. For formatted string we mean a string that starts with the first delimiter character and ends with the second delimiter character.- Parameters:
s- The string to check if it is formatted.- Returns:
- Return the boolean to understand if the string is formatted. Obviously
"true"means that the string is formatted,"false"means no.
-