|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.flatpack.util.ParserUtils
public final class ParserUtils
Static utilities that are used to perform parsing in the DataSet class These can also be used for low level parsing, if not wishing to use the DataSet class.
Method Summary | |
---|---|
static java.util.Map |
buidColumnIndexMap(java.util.List columns,
Parser p)
Build a map of name/position based on a list of ColumnMetaData. |
static java.util.List |
buildMDFromSQLTable(java.sql.Connection con,
java.lang.String dataDefinition)
Returns a definition of pz column metadata from a given pz datastructure held in an SQL database |
static java.util.List |
buildMDFromSQLTable(java.sql.Connection con,
java.lang.String dataDefinition,
Parser parser)
Returns a definition of pz column metadata from a given pz datastructure held in an SQL database |
static java.util.Map |
calculateRecordLengths(MetaData columnMD)
|
static void |
closeReader(java.io.InputStream reader)
Closes the given reader |
static void |
closeReader(java.io.Reader reader)
Closes the given reader |
static java.io.InputStream |
createInputStream(java.io.File file)
Create an InputStream based on a File. |
static java.lang.String |
getCMDKeyForDelimitedFile(MetaData columnMD,
java.util.List lineElements)
|
static int |
getColumnIndex(java.lang.String key,
MetaData columnMD,
java.lang.String colName,
Parser p)
|
static java.util.List |
getColumnMDFromFile(java.io.File theFile,
java.lang.String delimiter,
java.lang.String qualifier)
Returns a list of ColumnMetaData objects. |
static java.util.List |
getColumnMetaData(java.lang.String key,
MetaData columnMD)
|
static int |
getDelimiterOffset(java.lang.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(java.lang.String line,
char delimiter,
char qualifier,
Parser p)
Returns a list of ColumnMetaData objects. |
static boolean |
isListElementsEmpty(java.util.List l)
Checks a list of |
static boolean |
isMultiLine(char[] chrArry,
char delimiter,
char qualifier)
Determines if the given line is the first part of a multiline record |
static java.util.Properties |
loadConvertProperties()
Retrieves the conversion table for use with the getObject() method in IDataSet |
static java.lang.String |
lTrim(java.lang.String value)
Removes empty space from the beginning of a string |
static java.lang.String |
lTrimKeepTabs(java.lang.String value)
Removes empty space from the beginning of a string, except for tabs |
static java.lang.String |
padding(int repeat,
char padChar)
Returns padding using the specified delimiter repeated to a given length. |
static java.lang.String |
removeChar(char theChar,
java.lang.String theString)
Removes a single string character from a given string |
static java.lang.String |
rTrim(java.lang.String value)
Removes empty space from the end of a string |
static java.lang.Object |
runPzConverter(java.util.Properties classXref,
java.lang.String value,
java.lang.Class typeToReturn)
Converts a String value to the appropriate Object via the correct net.sf.flatpack.converter.PZConverter implementation |
static java.util.List |
splitLine(java.lang.String line,
char delimiter,
char qualifier,
int initialSize)
Returns an ArrayList of items in a delimited string. |
static java.lang.String |
stripNonDoubleChars(java.lang.String value)
Removes chars from the String that could not be parsed into a Double value |
static java.lang.String |
stripNonLongChars(java.lang.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. |
static java.lang.String |
trimToNull(java.lang.String value)
Will return a null if the String is empty returns the trimmed string otherwise. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.util.List splitLine(java.lang.String line, char delimiter, char qualifier, int initialSize)
line
- -
String of data to be parseddelimiter
- -
Delimiter seperating each elementqualifier
- -
qualifier which is surrounding the textinitialSize
- -
intial capacity of the List size
public static int getDelimiterOffset(java.lang.String line, int start, char delimiter)
line
- start
- delimiter
-
public static java.lang.String lTrim(java.lang.String value)
value
- -
to be trimmed
public static java.lang.String lTrimKeepTabs(java.lang.String value)
value
- -
to be trimmed
public static java.lang.String rTrim(java.lang.String value)
value
- -
to be trimmed
public static java.lang.String trimToNull(java.lang.String value)
value
- to be trimmed
public static java.lang.String removeChar(char theChar, java.lang.String theString)
theChar
- -
string chartheString
- -
string to search
public static MetaData getPZMetaDataFromFile(java.lang.String line, char delimiter, char qualifier, Parser p)
line
- delimiter
- qualifier
- p
- PZParser used to specify additional option when working with the ColumnMetaData. Can be null
public static java.util.List getColumnMDFromFile(java.io.File theFile, java.lang.String delimiter, java.lang.String qualifier) throws java.io.IOException
theFile
- delimiter
- qualifier
-
java.io.FileNotFoundException
java.io.IOException
public static boolean isMultiLine(char[] chrArry, char delimiter, char qualifier)
chrArry
- -
char data of the linedelimiter
- -
delimiter being usedqualifier
- -
qualifier being used
public static java.util.Map calculateRecordLengths(MetaData columnMD)
public static java.lang.String getCMDKeyForDelimitedFile(MetaData columnMD, java.util.List lineElements)
public static java.util.List getColumnMetaData(java.lang.String key, MetaData columnMD)
public static int getColumnIndex(java.lang.String key, MetaData columnMD, java.lang.String colName, Parser p)
public static java.io.InputStream createInputStream(java.io.File file) throws java.io.FileNotFoundException
file
- The file.
java.io.FileNotFoundException
public static void closeReader(java.io.Reader reader)
reader
- public static void closeReader(java.io.InputStream reader)
reader
- public static java.lang.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 char
s
to be represented. If you are needing to support full I18N of your
applications consider using #repeat(String, int)
instead.
repeat
- number of times to repeat delimpadChar
- character to repeat
java.lang.IndexOutOfBoundsException
- if repeat < 0
#repeat(String, int)
public static java.util.Map buidColumnIndexMap(java.util.List 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 java.lang.String stripNonLongChars(java.lang.String value)
value
-
public static java.lang.String stripNonDoubleChars(java.lang.String value)
value
-
public static java.util.Properties loadConvertProperties() throws java.io.IOException
java.io.IOException
public static boolean isListElementsEmpty(java.util.List l)
l
- List of public static java.lang.Object runPzConverter(java.util.Properties classXref, java.lang.String value, java.lang.Class typeToReturn)
classXref
- Properties holding class cross referencevalue
- Value to be converted to the ObjecttypeToReturn
- Type of object to be returned
PZConvertExeption
public static java.util.List buildMDFromSQLTable(java.sql.Connection con, java.lang.String dataDefinition) throws java.sql.SQLException
con
- Database connection containing the Datafile and Datastructure
tablesdataDefinition
- Name of the data definition stored in the Datafile table
java.sql.SQLException
public static java.util.List buildMDFromSQLTable(java.sql.Connection con, java.lang.String dataDefinition, Parser parser) throws java.sql.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.
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |