public class SwiftParseUtils
extends java.lang.Object
Constructor and Description |
---|
SwiftParseUtils() |
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 |
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 using readline
|
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 java.lang.String |
removePrefix(java.lang.String value,
java.lang.String prefix) |
static void |
setComponentsFromLines(Field f,
int startingComponentNumber,
int 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 java.lang.String getAlphaPrefix(java.lang.String value)
null
is returned.value
- public static java.lang.String getAlphaSuffix(java.lang.String value)
null
is returned.value
- public static java.util.List<java.lang.String> getLines(java.lang.String value)
value
- public static java.lang.String getNumericPrefix(java.lang.String value)
null
is returned.value
- public static java.lang.String getNumericSuffix(java.lang.String value)
null
is returned.value
- public static java.lang.String getTokenFirst(java.lang.String line, java.lang.String separator)
line
- separator
- getTokenFirst(String, String, String)
public static java.lang.String getTokenFirst(java.lang.String line, java.lang.String starting, java.lang.String separator)
null
if the string without starting substring
is empty or null
.line
- starting
- separator
- null
public static java.lang.String getTokenForth(java.lang.String line, java.lang.String separator)
null
if
forth component is missing. Two adjacent separators are NOT treated as one.line
- separator
- public static java.lang.String getTokenForthLast(java.lang.String line, java.lang.String separator)
null
if
forth component is missing. Two adjacent separators are NOT treated as one. The forth component is assumed as the
last one so its content may have additional separators if present.line
- separator
- public static java.lang.String getTokenSecond(java.lang.String line, java.lang.String separator)
null
if
second component is missing. Two adjacent separators are NOT treated as one.line
- separator
- public static java.lang.String getTokenSecond(java.lang.String line, java.lang.String starting, java.lang.String separator)
null
if the string without starting substring
is empty or null
.line
- starting
- separator
- null
public static java.lang.String getTokenSecondLast(java.lang.String line, java.lang.String separator)
null
if
second component is missing. Two adjacent separators are NOT treated as one. The second component is assumed as the
last one so its content may have additional separators if present.line
- separator
- public static java.lang.String getTokenSecondLast(java.lang.String line, java.lang.String starting, java.lang.String separator)
null
if the string without starting substring
is empty or null
.
line
- starting
- separator
- null
public static java.lang.String getTokenThird(java.lang.String line, java.lang.String separator)
null
if
third component is missing. Two adjacent separators are NOT treated as one.line
- separator
- public static java.lang.String getTokenThirdLast(java.lang.String line, java.lang.String separator)
null
if
third component is missing. Two adjacent separators are NOT treated as one. The third component is assumed as the
last one so its content may have additional separators if present.line
- separator
- public static java.lang.String removePrefix(java.lang.String value, java.lang.String prefix)
value
- prefix
- public static void setComponentsFromLines(Field f, int startingComponentNumber, int 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 setstartingLine
- 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 contentpublic 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 separator