public class SwiftParseUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getAlphaPrefix(java.lang.String value)
Returns the alphabetic starting substring of the value.
|
static java.lang.String |
getAlphaPrefixTrimSlash(java.lang.String value)
Same as
getAlphaPrefix(String) but if the result consist only of slash characters, then null is returned. |
static java.lang.String |
getAlphaSuffix(java.lang.String value)
Returns the alpha suffix of the value.
|
static java.util.List<java.lang.String> |
getLines(java.lang.String value)
Separate the given string in lines, removing trailing empty lines.
|
static java.lang.String |
getNumericPrefix(java.lang.String value)
Returns the numeric starting substring of the value.
|
static java.lang.String |
getNumericSuffix(java.lang.String value)
Returns the numeric suffix of the value.
|
static java.lang.String |
getTokenFirst(java.lang.String line,
java.lang.String separator) |
static java.lang.String |
getTokenFirst(java.lang.String line,
java.lang.String starting,
java.lang.String separator)
Split components of a line with an optional starting string and a component separator
and returns the first token found or null if the string without starting substring
is empty or null.
This method does not validate the starting string presence, it just strips it if present. |
static java.lang.String |
getTokenForth(java.lang.String line,
java.lang.String separator)
Split components of a line using the parameter separator and returns the forth token found or null if
forth component is missing.
|
static java.lang.String |
getTokenForthLast(java.lang.String line,
java.lang.String separator)
Split components of a line using the parameter separator and returns the forth token found or null if
forth component is missing.
|
static java.lang.String |
getTokenSecond(java.lang.String line,
java.lang.String separator)
Split components of a line using the parameter separator and returns the second token found or null if
second component is missing.
|
static java.lang.String |
getTokenSecond(java.lang.String line,
java.lang.String starting,
java.lang.String separator)
Split components of a line with an optional starting string and a component separator
and returns the second token found or null if the string without starting substring
is empty or null.
This method does not validate the starting string presence, it just strips it if present. |
static java.lang.String |
getTokenSecondLast(java.lang.String line,
java.lang.String separator)
Split components of a line using the parameter separator and returns the second token found or null if
second component is missing.
|
static java.lang.String |
getTokenSecondLast(java.lang.String line,
java.lang.String starting,
java.lang.String separator)
Split components of a line with an optional starting string and a component separator
and returns the second token found or null if the string without starting substring
is empty or null.
|
static java.lang.String |
getTokenThird(java.lang.String line,
java.lang.String separator)
Split components of a line using the parameter separator and returns the third token found or null if
third component is missing.
|
static java.lang.String |
getTokenThirdLast(java.lang.String line,
java.lang.String separator)
Split components of a line using the parameter separator and returns the third token found or null if
third component is missing.
|
static boolean |
isAllAsciiDigits(java.lang.String value)
Checks if a string contains only ASCII digits
|
static java.lang.String |
removePrefix(java.lang.String value,
java.lang.String prefix) |
static void |
setComponentsFromLines(Field f,
int startingComponentNumber,
java.lang.Integer linesToSet,
int startingLine,
java.util.List<java.lang.String> lines)
Populates a multiline field with content from an array of Strings.
|
static void |
setComponentsFromTokens(Field f,
int startingComponentNumber,
int componentsToSet,
int tokenSize,
java.lang.String value)
Populates field with content from of a String splited into fixed length tokens.
|
static java.util.List<java.lang.String> |
splitComponents(java.lang.String line,
java.lang.String starting,
java.lang.String separator)
Split components of a line, with an optional starting string and a component separator.
|
public static boolean isAllAsciiDigits(java.lang.String value)
value
- the value to checkpublic static java.util.List<java.lang.String> splitComponents(java.lang.String line, java.lang.String starting, java.lang.String separator)
StringUtils.splitByWholeSeparator(String, String)
line
- the string to parsestarting
- an optional starting stringseparator
- the components separatorpublic static java.lang.String getTokenFirst(java.lang.String line, java.lang.String starting, java.lang.String separator)
public static java.lang.String getTokenFirst(java.lang.String line, java.lang.String separator)
getTokenFirst(String, String, String)
public static java.lang.String removePrefix(java.lang.String value, java.lang.String prefix)
public static java.lang.String getTokenSecond(java.lang.String line, java.lang.String separator)
public static java.lang.String getTokenSecondLast(java.lang.String line, java.lang.String separator)
public static java.lang.String getTokenSecond(java.lang.String line, java.lang.String starting, java.lang.String separator)
public static java.lang.String getTokenSecondLast(java.lang.String line, java.lang.String starting, java.lang.String separator)
public static java.lang.String getTokenThird(java.lang.String line, java.lang.String separator)
public static java.lang.String getTokenThirdLast(java.lang.String line, java.lang.String separator)
public static java.lang.String getTokenForth(java.lang.String line, java.lang.String separator)
public static java.lang.String getTokenForthLast(java.lang.String line, java.lang.String separator)
public static java.lang.String getAlphaPrefix(java.lang.String value)
public static java.lang.String getAlphaPrefixTrimSlash(java.lang.String value)
getAlphaPrefix(String)
but if the result consist only of slash characters, then null is returned.
This implementation variant is helpful when parsing fields that uses the slash as component separator, to avoid
spurious components consisting of just the separator, when a malformed field is parsed.public static java.lang.String getNumericPrefix(java.lang.String value)
public static java.lang.String getNumericSuffix(java.lang.String value)
public static java.lang.String getAlphaSuffix(java.lang.String value)
public static java.util.List<java.lang.String> getLines(java.lang.String value)
The implementation uses using BufferedReader.readLine()
so if the string ends with a LF, the trailing
"empty" line is not returned in the result.
public static void setComponentsFromLines(Field f, int startingComponentNumber, java.lang.Integer linesToSet, int startingLine, java.util.List<java.lang.String> lines)
f
- field to populate with components' valuesstartingComponentNumber
- first component number to be set, then it will increment on each line addedlinesToSet
- how many components must to be set, or null to set all available lines as componentsstartingLine
- lines list offset, zero basedlines
- list of lines from where to get components contentpublic static void setComponentsFromTokens(Field f, int startingComponentNumber, int componentsToSet, int tokenSize, java.lang.String value)
f
- field to populate with components' valuesstartingComponentNumber
- first component number to be set, then it will increment on each token addedcomponentsToSet
- how many components must to be settokenSize
- fixed size for each token grabbed from the String valuevalue
- from where to get components content