E
- a DataObjectpublic class FlatFileLoader<E extends DataObject<E> & UniqueidentifiedInterface<E>>
extends java.lang.Object
Constructor and Description |
---|
FlatFileLoader(DataObjectDefinition<E> objectdefinition,
ChoiceValue<ApplocaleChoiceDefinition> selectedlocale,
ChoiceValue<PreferedfileencodingChoiceDefinition> preferedencoding)
Creates a FlatFileLoader without supplement
|
FlatFileLoader(DataObjectDefinition<E> objectdefinition,
ChoiceValue<ApplocaleChoiceDefinition> selectedlocale,
ChoiceValue<PreferedfileencodingChoiceDefinition> preferedencoding,
FlatFileLoaderSupplement<E> supplement)
Creates a FlatFileLoader with a loader supplement
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
buildExceptionMessage(java.lang.Throwable t)
Returns the error message
|
java.lang.String |
dropOneLineAsText(java.lang.Object[] data) |
CSVParser |
generateCSVParser(SFile file,
java.nio.charset.Charset charsettouse)
generates a CSVParser for the file with the correct charset corresponding to
the locale
|
ExcelReader |
generateExcelParser(SFile file,
java.lang.String preferedtab)
generates an excel parser for the file
|
static java.time.format.DateTimeFormatter |
generateFormat(java.lang.String inputformat,
java.lang.String context)
generates a DateTimeFormatter from a string input format
|
static boolean |
hasdata(java.lang.Object[] parsedcsvline)
This method returns true if the line has some data.
|
static <X> boolean |
isTheSame(X object1,
X object2)
A helper method comparing without explosion two objects, taking into account
the possibility that objects are null
|
static boolean |
isWorkbookFormat(SFile file)
checks if the file is a supported workbook format
|
FlatFileLoaderReport |
load(SFile file)
performs the 3 pass loading algorithm
|
static java.util.Date |
parseDate(java.lang.Object object,
java.lang.String context,
boolean timeedit,
java.time.format.DateTimeFormatter format)
parses an object as a date
|
static java.math.BigDecimal |
parseDecimal(java.lang.Object object,
int precision,
int scale,
java.lang.String context,
DecimalDataObjectFieldFlatFileLoaderColumn.DecimalParser decimalparser)
parses a big decimal if possible, else throws an exception
|
static java.lang.Integer |
parseInteger(java.lang.Object object,
java.lang.String context)
parses an object as Integer
|
static java.lang.String |
parseObject(java.lang.Object object,
java.lang.String context)
parses an object as a string
|
static java.lang.String |
parseStringStrict(java.lang.Object object,
java.lang.String context) |
public FlatFileLoader(DataObjectDefinition<E> objectdefinition, ChoiceValue<ApplocaleChoiceDefinition> selectedlocale, ChoiceValue<PreferedfileencodingChoiceDefinition> preferedencoding)
objectdefinition
- definition of the objectselectedlocale
- locale for CSV Loadingpreferedencoding
- preferred encoding for CSV Loadingpublic FlatFileLoader(DataObjectDefinition<E> objectdefinition, ChoiceValue<ApplocaleChoiceDefinition> selectedlocale, ChoiceValue<PreferedfileencodingChoiceDefinition> preferedencoding, FlatFileLoaderSupplement<E> supplement)
objectdefinition
- definition of the objectselectedlocale
- locale for CSV Loadingpreferedencoding
- prefered encoding for CSV Loadingsupplement
- supplement to the loaderpublic static boolean hasdata(java.lang.Object[] parsedcsvline)
parsedcsvline
- public static java.lang.String buildExceptionMessage(java.lang.Throwable t)
t
- a throwablepublic static boolean isWorkbookFormat(SFile file)
file
- binary filepublic CSVParser generateCSVParser(SFile file, java.nio.charset.Charset charsettouse)
file
- the file to generate the parser forcharsettouse
- charset to use for the input streampublic ExcelReader generateExcelParser(SFile file, java.lang.String preferedtab)
file
- binary filepreferedtab
- name of the prefered tab to usepublic FlatFileLoaderReport load(SFile file)
file
- the file to use (loaded in memory)public static <X> boolean isTheSame(X object1, X object2)
object1
- first object (can be null)object2
- second object (can be null)public static java.lang.String parseObject(java.lang.Object object, java.lang.String context)
object
- the objectcontext
- context for the parsing, used to give context in the potential
exceptionpublic static java.lang.String parseStringStrict(java.lang.Object object, java.lang.String context)
object
- object to parse (should be a String, else exception)context
- context for the exception being potentially thrownpublic static java.util.Date parseDate(java.lang.Object object, java.lang.String context, boolean timeedit, java.time.format.DateTimeFormatter format)
object
- the object to parsecontext
- context for potential exception being throwntimeedit
- true if time is stored in the dateformat
- format to parse the date if stringpublic static java.lang.Integer parseInteger(java.lang.Object object, java.lang.String context)
object
- an object (can be string or double)context
- context for exception throwingpublic static java.math.BigDecimal parseDecimal(java.lang.Object object, int precision, int scale, java.lang.String context, DecimalDataObjectFieldFlatFileLoaderColumn.DecimalParser decimalparser)
object
- the object to parseprecision
- precision in the sense of BigDecimalscale
- scale in the sense of Big Decimalcontext
- context for exception throwingdecimalparser
- a parser for the big decimalpublic static java.time.format.DateTimeFormatter generateFormat(java.lang.String inputformat, java.lang.String context) throws java.lang.RuntimeException
inputformat
- the input format to parse (if null, default format
'YYYY.MM.dd' is used)context
- context for exception handlingjava.lang.RuntimeException
public java.lang.String dropOneLineAsText(java.lang.Object[] data) throws java.lang.RuntimeException
data
- java.lang.RuntimeException