public class StringExtractor
extends java.lang.Object
StringTokenizer
, but in addition it can detect Strings and not cut on them, it can
also ignore escaped character.
Hello
world
!
This is a phrase
Modifier and Type | Field and Description |
---|---|
private char[] |
escapeCharacters
Escape characters
|
private int |
index
Current read index
|
private int |
length
String to parse length
|
private java.util.ArrayList<Pair<java.lang.Character,java.lang.Character>> |
openCloseIgnore
Open/close pairs, to consider like "normal" character something between an open and a close character
|
private boolean |
returnSeparators
Indicates if separators are return
|
private char[] |
separators
Separators characters
|
private char[] |
string
String to parse
|
private char[] |
stringLimiters
String delimiters
|
Constructor and Description |
---|
StringExtractor(java.lang.String string)
Create a new instance of StringExtractor with default separators (see
UtilText.DEFAULT_SEPARATORS ), string
delimiters (see UtilText.DEFAULT_STRING_LIMITERS ) and escape characters (see
UtilText.DEFAULT_ESCAPE_CHARACTERS ). |
StringExtractor(java.lang.String string,
boolean returnSeparators)
Create a new instance of StringExtractor with default separators (see
UtilText.DEFAULT_SEPARATORS ), string
delimiters (see UtilText.DEFAULT_STRING_LIMITERS ) and escape characters (see
UtilText.DEFAULT_ESCAPE_CHARACTERS ) |
StringExtractor(java.lang.String string,
java.lang.String separators,
java.lang.String stringLimiters,
java.lang.String escapeCharacters)
Create a new instance of StringExtractor with no return separators
|
StringExtractor(java.lang.String string,
java.lang.String separators,
java.lang.String stringLimiters,
java.lang.String escapeCharacters,
boolean returnSeparators)
Create a new instance of StringExtractor
|
Modifier and Type | Method and Description |
---|---|
void |
addOpenCloseIgnore(char open,
char close)
Add a open close pairs, to consider like "normal" character something between an open and a close character
|
java.lang.String |
next()
Next extracted string.
|
private final char[] escapeCharacters
private int index
private final int length
private final java.util.ArrayList<Pair<java.lang.Character,java.lang.Character>> openCloseIgnore
private final boolean returnSeparators
private final char[] separators
private final char[] string
private final char[] stringLimiters
public StringExtractor(java.lang.String string)
UtilText.DEFAULT_SEPARATORS
), string
delimiters (see UtilText.DEFAULT_STRING_LIMITERS
) and escape characters (see
UtilText.DEFAULT_ESCAPE_CHARACTERS
). And no return of separatorsstring
- String to parsepublic StringExtractor(java.lang.String string, boolean returnSeparators)
UtilText.DEFAULT_SEPARATORS
), string
delimiters (see UtilText.DEFAULT_STRING_LIMITERS
) and escape characters (see
UtilText.DEFAULT_ESCAPE_CHARACTERS
)string
- String to parsereturnSeparators
- Indicates if return separatorspublic StringExtractor(java.lang.String string, java.lang.String separators, java.lang.String stringLimiters, java.lang.String escapeCharacters)
string
- String to parseseparators
- Separators liststringLimiters
- String delimitersescapeCharacters
- Escape characterspublic StringExtractor(java.lang.String string, java.lang.String separators, java.lang.String stringLimiters, java.lang.String escapeCharacters, boolean returnSeparators)
string
- String to parseseparators
- Separators liststringLimiters
- String delimitersescapeCharacters
- Escape charactersreturnSeparators
- Indicates if return separatorspublic void addOpenCloseIgnore(char open, char close)
open
- Open characterclose
- Close characterpublic java.lang.String next()
null
if no more string to extractnull
if no more to extract