com.prowidesoftware.swift.model.field
Class SwiftParseUtils

java.lang.Object
  extended by com.prowidesoftware.swift.model.field.SwiftParseUtils

public class SwiftParseUtils
extends java.lang.Object

This class provides methods to parse field components.

Since:
6.0
Version:
$Id: SwiftParseUtils.java,v 1.1.1.1 2013/04/10 17:04:50 mgriffa Exp $
Author:
www.prowidesoftware.com

Constructor Summary
SwiftParseUtils()
           
 
Method Summary
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 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 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwiftParseUtils

public SwiftParseUtils()
Method Detail

splitComponents

public 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. Adjacent separators are treated as one separator. This method does not validate the starting string presence, it just strips it if present. this methods uses StringUtils.splitByWholeSeparator(String, String)

Parameters:
line - the string to parse
starting - an optional starting string
separator - the components separator
Returns:
a list of String with the found components or an empty list if none is found

getTokenFirst

public 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.

Parameters:
line -
starting -
separator -
Returns:
the first token found or null

getTokenFirst

public static java.lang.String getTokenFirst(java.lang.String line,
                                             java.lang.String separator)
Parameters:
line -
separator -
Returns:
found token
See Also:
getTokenFirst(String, String, String)

removePrefix

public static java.lang.String removePrefix(java.lang.String value,
                                            java.lang.String prefix)
Parameters:
value -
prefix -
Returns:
s

getTokenSecond

public 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. Two adjacent separators are NOT treated as one.
Examples with slash as separator:

Parameters:
line -
separator -
Returns:
s

getTokenSecondLast

public 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. 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.
Examples with slash as separator:

Parameters:
line -
separator -
Returns:
s

getTokenThird

public 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. Two adjacent separators are NOT treated as one.
Examples with slash as separator:

Parameters:
line -
separator -
Returns:
s

getTokenThirdLast

public 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. 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.
Examples with slash as separator:

Parameters:
line -
separator -
Returns:
s

getTokenForth

public 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. Two adjacent separators are NOT treated as one.
Examples with slash as separator:

Parameters:
line -
separator -
Returns:
s

getTokenForthLast

public 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. 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.
Examples with slash as separator:

Parameters:
line -
separator -
Returns:
s

getAlphaPrefix

public static java.lang.String getAlphaPrefix(java.lang.String value)
Returns the alphabetic starting substring of the value. The split is made when the first numeric character is found. For example:
ABCD2345,33 will be return ABCD
If the value does not contain any alphabetic character null is returned.

Parameters:
value -
Returns:
s

getNumericPrefix

public static java.lang.String getNumericPrefix(java.lang.String value)
Returns the numeric starting substring of the value. The split is made when the first alpha character (not number or comma) is found. For example:
2345,33ABCD will be return 2345,33
If the value does not contain any numeric or comma character null is returned.

Parameters:
value -
Returns:
s

getNumericSuffix

public static java.lang.String getNumericSuffix(java.lang.String value)
Returns the numeric suffix of the value. The split is made when the first numeric character is found. For example:
ABCD2345,33 will be return 2345,33
If the value does not contain any numeric character null is returned.

Parameters:
value -
Returns:
s

getAlphaSuffix

public static java.lang.String getAlphaSuffix(java.lang.String value)
Returns the alpha suffix of the value. The split is made when the first alpha (not numetic or comma) character is found. For example:
2345,33ABCD will be return ABCD
If the value does not contain any alpha character null is returned.

Parameters:
value -
Returns:
s

getLines

public static java.util.List<java.lang.String> getLines(java.lang.String value)
Separate the given string in lines using readline

Parameters:
value -
Returns:
list of found lines

setComponentsFromLines

public 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.

Parameters:
f - field to populate with components' values
startingComponentNumber - first component number to be set, then it will increment on each line added
linesToSet - how many components must to be set
startingLine - lines list offset, zero based
lines - list of lines from where to get components content