|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jmatchparser.util.csv.fieldreader.FieldSource
public abstract class FieldSource
A description of the "source" from where data should be filled into the field, as seen from the perspective of the "provider" that provides the CSV files.
| Nested Class Summary | |
|---|---|
static class |
FieldSource.EmptyAction
How to treat a field source that returns an empty string. |
| Constructor Summary | |
|---|---|
FieldSource()
|
|
| Method Summary | |
|---|---|
static FieldSource |
concat(FieldSource... sources)
Create a new field source that returns a value concatenated from several other FieldSources. |
static FieldSource |
fromColumn(String columnName)
Create a new field source that returns a value from a CSV column. |
static FieldSource |
fromConstant(String constant)
Create a new field source that always returns the same constant value. |
abstract String |
getField()
Return an artificial name for this field, used for debugging and in error messages. |
abstract String |
getValue(Map<String,String> columns)
Return the value of this field source. |
boolean |
isMandatoryIfNew()
Return whether this field has to be filled for new records |
static FieldSource |
parse(String columns,
FieldSource.EmptyAction emptyAction,
String mask,
String mappings)
Parse a field source from several parameters. |
static FieldSource |
withChecks(FieldSource source,
FieldSource.EmptyAction emptyAction,
Pattern mask)
Create a field source that performs checks on the output of another field source and returns the result verbatim. |
static FieldSource |
withChecks(FieldSource source,
FieldSource.EmptyAction emptyAction,
String mask)
Create a field source that performs checks on the output of another field source and returns the result verbatim. |
static FieldSource |
withFormat(FieldSource source,
ParseFormat<String> format)
Create a field source that applies a ParseFormat on another field
source. |
static FieldSource |
withMapping(FieldSource source,
Pattern regex,
String replacement)
Create a field source that performs a regex replacement on another field source. |
static FieldSource |
withMapping(FieldSource source,
String regex,
String replacement)
Create a field source that performs a regex replacement on another field source. |
static FieldSource |
withMappings(FieldSource source,
String mappings)
Create a field source that performs a series of regex replacements on another field source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FieldSource()
| Method Detail |
|---|
public abstract String getValue(Map<String,String> columns)
throws FieldReaderException
columns - Hashtable of fields read from the CSV file
null if the field should be treated as
absent
FieldReaderExceptionpublic abstract String getField()
public boolean isMandatoryIfNew()
public static FieldSource fromConstant(String constant)
constant - The constant valuepublic static FieldSource fromColumn(String columnName)
columnName - Name or index of the columnpublic static FieldSource concat(FieldSource... sources)
FieldSources.
sources - Other field sources to be concatenated
public static FieldSource withMappings(FieldSource source,
String mappings)
source - Field sourcemappings - A list delimited by ;; of regex replacement pairs,
where :: separates regex and replacement, or
null for no mappings
public static FieldSource withMapping(FieldSource source,
String regex,
String replacement)
source - Field sourceregex - regular expressionreplacement - replacement string
public static FieldSource withMapping(FieldSource source,
Pattern regex,
String replacement)
source - Field sourceregex - regular expressionreplacement - replacement string
public static FieldSource withFormat(FieldSource source,
ParseFormat<String> format)
ParseFormat on another field
source.
source - Field sourceformat - ParseFormat
public static FieldSource withChecks(FieldSource source,
FieldSource.EmptyAction emptyAction,
String mask)
source - field sourceemptyAction - Action to perform when the field source returns an empty
stringmask - regex pattern the field source result has to match, or
null
public static FieldSource withChecks(FieldSource source,
FieldSource.EmptyAction emptyAction,
Pattern mask)
source - field sourceemptyAction - Action to perform when the field source returns an empty
stringmask - regex pattern the field source result has to match, or
null
public static FieldSource parse(String columns,
FieldSource.EmptyAction emptyAction,
String mask,
String mappings)
columns - Columns spec, either one or multiple column names separated by
one of |,;: (the separator will be added to the
result), or a literal string where column names are included
in curly bracesemptyAction - Action to perform when the field source returns an empty
stringmask - regex pattern the field source result has to matchmappings - A list delimited by ;; of regex replacement pairs,
where :: separates regex and replacement.withChecks(FieldSource, EmptyAction, Pattern),
withMappings(FieldSource, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||