public class SwiftParseUtils extends Object
Constructor and Description |
---|
SwiftParseUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
getAlphaPrefix(String value)
Returns the alphabetic starting substring of the value.
|
static String |
getAlphaSuffix(String value)
Returns the alpha suffix of the value.
|
static List<String> |
getLines(String value)
Separate the given string in lines using readline
|
static String |
getNumericPrefix(String value)
Returns the numeric starting substring of the value.
|
static String |
getNumericSuffix(String value)
Returns the numeric suffix of the value.
|
static String |
getTokenFirst(String line,
String separator) |
static String |
getTokenFirst(String line,
String starting,
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 String |
getTokenForth(String line,
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 String |
getTokenForthLast(String line,
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 String |
getTokenSecond(String line,
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 String |
getTokenSecond(String line,
String starting,
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 String |
getTokenSecondLast(String line,
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 String |
getTokenSecondLast(String line,
String starting,
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 String |
getTokenThird(String line,
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 String |
getTokenThirdLast(String line,
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 String |
removePrefix(String value,
String prefix) |
static void |
setComponentsFromLines(Field f,
int startingComponentNumber,
int linesToSet,
int startingLine,
List<String> lines)
Populates a multiline field with content from an array of Strings.
|
static void |
setComponentsFromTokens(Field f,
int startingComponentNumber,
int componentsToSet,
int tokenSize,
String value)
Populates field with content from of a String splited into fixed length tokens.
|
static List<String> |
splitComponents(String line,
String starting,
String separator)
Split components of a line, with an optional starting string and a component separator.
|
public static List<String> splitComponents(String line, String starting, String separator)
StringUtils.splitByWholeSeparator(String, String)
line
- the string to parsestarting
- an optional starting stringseparator
- the components separatorpublic static String getTokenFirst(String line, String starting, String separator)
null
if the string without starting substring
is empty or null
.line
- starting
- separator
- null
public static String getTokenFirst(String line, String separator)
line
- separator
- getTokenFirst(String, String, String)
public static String removePrefix(String value, String prefix)
value
- prefix
- public static String getTokenSecond(String line, String separator)
null
if
second component is missing. Two adjacent separators are NOT treated as one.line
- separator
- public static String getTokenSecondLast(String line, 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 String getTokenSecond(String line, String starting, String separator)
null
if the string without starting substring
is empty or null
.line
- starting
- separator
- null
public static String getTokenSecondLast(String line, String starting, String separator)
null
if the string without starting substring
is empty or null
.
line
- starting
- separator
- null
public static String getTokenThird(String line, String separator)
null
if
third component is missing. Two adjacent separators are NOT treated as one.line
- separator
- public static String getTokenThirdLast(String line, 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 String getTokenForth(String line, String separator)
null
if
forth component is missing. Two adjacent separators are NOT treated as one.line
- separator
- public static String getTokenForthLast(String line, 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 String getAlphaPrefix(String value)
null
is returned.value
- public static String getNumericPrefix(String value)
null
is returned.value
- public static String getNumericSuffix(String value)
null
is returned.value
- public static String getAlphaSuffix(String value)
null
is returned.value
- public static List<String> getLines(String value)
value
- public static void setComponentsFromLines(Field f, int startingComponentNumber, int linesToSet, int startingLine, List<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, 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