public final class ParserUtils extends Object
| Modifier and Type | Method and Description | 
|---|---|
static Map<String,Integer> | 
buidColumnIndexMap(List<ColumnMetaData> columns,
                  Parser p)
Build a map of name/position based on a list of ColumnMetaData. 
 | 
static List<ColumnMetaData> | 
buildMDFromSQLTable(Connection con,
                   String dataDefinition,
                   Parser parser)
Returns a definition of pz column metadata from a given
 pz datastructure held in an SQL database 
 | 
static Map<String,Integer> | 
calculateRecordLengths(MetaData columnMD)  | 
static String | 
getCMDKeyForDelimitedFile(MetaData columnMD,
                         List<String> lineElements)  | 
static int | 
getColumnIndex(String key,
              MetaData columnMD,
              String colName,
              boolean columNameCaseSensitive)  | 
static List<ColumnMetaData> | 
getColumnMetaData(String key,
                 MetaData columnMD)  | 
static int | 
getDelimiterOffset(String line,
                  int start,
                  char delimiter)
reads from the specified point in the line and returns how many chars to
 the specified delimiter 
 | 
static MetaData | 
getPZMetaDataFromFile(String line,
                     char delimiter,
                     char qualifier,
                     Parser p,
                     boolean addSuffixToDuplicateColumnNames)
Returns a list of ColumnMetaData objects. 
 | 
static boolean | 
isListElementsEmpty(List<String> l)
Checks a list of <String> elements to see if every element
 in the list is empty. 
 | 
static boolean | 
isMultiLine(char[] chrArry,
           char delimiter,
           char qualifier)
Determines if the given line is the first part of a multiline record. 
 | 
static Properties | 
loadConvertProperties()
Retrieves the conversion table for use with the getObject()
 method in IDataSet 
 | 
static String | 
lTrim(String value)
Removes empty space from the beginning of a string 
 | 
static String | 
lTrimKeepTabs(String value)
Removes empty space from the beginning of a string, except for tabs 
 | 
static String | 
padding(int repeat,
       char padChar)
 Returns padding using the specified delimiter repeated to a given length. 
 | 
static String | 
replace(String text,
       String searchString,
       String replacement,
       int max)
Using a much faster String Replace from Apache! 
 | 
static String | 
rTrim(String value)
Removes empty space from the end of a string 
 | 
static Object | 
runPzConverter(Properties classXref,
              String value,
              Class<?> typeToReturn)
Converts a String value to the appropriate Object via
 the correct net.sf.flatpack.converter.PZConverter implementation 
 | 
static List<String> | 
splitLine(String line,
         char delimiter,
         char qualifier,
         int initialSize,
         boolean preserveLeadingWhitespace,
         boolean preserveTrailingWhitespace)
Returns an ArrayList of items in a delimited string. 
 | 
static String | 
stripNonDoubleChars(String value)
Removes chars from the String that could not
 be parsed into a Double value 
 | 
static String | 
stripNonLongChars(String value)
Removes chars from the String that could not
 be parsed into a Long value
      PZStringUtils.stripNonLongChars("1000.25") = "1000"
 Method will truncate everything to the right of the decimal
 place when encountered. 
 | 
public static List<String> splitLine(String line, char delimiter, char qualifier, int initialSize, boolean preserveLeadingWhitespace, boolean preserveTrailingWhitespace)
line - -
            String of data to be parseddelimiter - -
            Delimiter separating each elementqualifier - -
            qualifier which is surrounding the textinitialSize - -
            initial capacity of the List sizepreserveLeadingWhitespace - Keep any leading spacespreserveTrailingWhitespace - Keep any trailing spacespublic static String replace(String text, String searchString, String replacement, int max)
public static int getDelimiterOffset(String line, int start, char delimiter)
line - start - delimiter - public static String lTrim(String value)
value - -
            to be trimmedpublic static String lTrimKeepTabs(String value)
value - -
            to be trimmedpublic static String rTrim(String value)
value - -
            to be trimmedpublic static MetaData getPZMetaDataFromFile(String line, char delimiter, char qualifier, Parser p, boolean addSuffixToDuplicateColumnNames)
line - delimiter - qualifier - p - PZParser used to specify additional option when working with the ColumnMetaData. Can be nulladdSuffixToDuplicateColumnNames - public static boolean isMultiLine(char[] chrArry,
                                  char delimiter,
                                  char qualifier)
chrArry - -
            char data of the linedelimiter - -
            delimiter being usedqualifier - -
            qualifier being usedpublic static String getCMDKeyForDelimitedFile(MetaData columnMD, List<String> lineElements)
public static List<ColumnMetaData> getColumnMetaData(String key, MetaData columnMD)
public static int getColumnIndex(String key, MetaData columnMD, String colName, boolean columNameCaseSensitive)
public static String padding(int repeat, char padChar)
Returns padding using the specified delimiter repeated to a given length.
                PZStringUtils.padding(0, 'e')  = ""
                PZStringUtils.padding(3, 'e')  = "eee"
                PZStringUtils.padding(-2, 'e') = IndexOutOfBoundsException
 
 
 Note: this method doesn't not support padding with Unicode
 Supplementary Characters as they require a pair of chars
 to be represented.
 
repeat - number of times to repeat delimpadChar - character to repeatIndexOutOfBoundsExceptionpublic static Map<String,Integer> buidColumnIndexMap(List<ColumnMetaData> columns, Parser p)
columns - p - Reference to Parser which can provide additional options on how the
         map should be build.  This can be NULL.public static String stripNonLongChars(String value)
value - public static String stripNonDoubleChars(String value)
value - public static Properties loadConvertProperties() throws IOException
IOExceptionpublic static boolean isListElementsEmpty(List<String> l)
l - List of <String>public static Object runPzConverter(Properties classXref, String value, Class<?> typeToReturn)
classXref - Properties holding class cross referencevalue - Value to be converted to the ObjecttypeToReturn - Type of object to be returnedFPConvertExceptionpublic static List<ColumnMetaData> buildMDFromSQLTable(Connection con, String dataDefinition, Parser parser) throws SQLException
con - Database connection containing the Datafile and Datastructure
          tablesdataDefinition - Name of the data definition stored in the Datafile tableparser - Instance of the parser being used for the file.  It will be checked to get the table names
                        for the DATASTRUCTURE table and DATAFILE table.SQLExceptionCopyright © 2006–2021 Appendium - Portfolio Financing Platform. All rights reserved.