public class DelimitedParser extends java.lang.Object implements java.io.Serializable
FieldTypeResolver
maybe used to clean and prepare field names
for data columns, and to infer type information from column names.Modifier and Type | Field and Description |
---|---|
protected java.util.regex.Pattern |
cleanPattern
Field cleanPattern
|
protected CoercibleType[] |
coercibles
Fields coercibles
|
protected java.lang.String |
delimiter
Field delimiter *
|
protected boolean |
enforceStrict
Field enforceStrict
|
protected java.util.regex.Pattern |
escapePattern
Field escapePattern
|
protected FieldTypeResolver |
fieldTypeResolver
fieldTypeResolver
|
protected int |
numValues
Field numValues
|
protected java.lang.String |
quote
Field quote
|
protected boolean |
safe
Field safe
|
protected Fields |
sourceFields
Field sourceFields
|
protected java.util.regex.Pattern |
splitPattern
Field splitPattern
|
protected boolean |
strict
Field strict
|
protected java.lang.reflect.Type[] |
types
Field types
|
Constructor and Description |
---|
DelimitedParser(java.lang.String delimiter,
java.lang.String quote,
java.lang.Class[] types) |
DelimitedParser(java.lang.String delimiter,
java.lang.String quote,
java.lang.Class[] types,
boolean strict,
boolean safe) |
DelimitedParser(java.lang.String delimiter,
java.lang.String quote,
java.lang.Class[] types,
boolean strict,
boolean safe,
Fields sourceFields,
Fields sinkFields) |
DelimitedParser(java.lang.String delimiter,
java.lang.String quote,
java.lang.Class[] types,
boolean strict,
boolean safe,
Fields sourceFields,
Fields sinkFields,
FieldTypeResolver fieldTypeResolver) |
DelimitedParser(java.lang.String delimiter,
java.lang.String quote,
java.lang.Class[] types,
boolean strict,
boolean safe,
FieldTypeResolver fieldTypeResolver) |
DelimitedParser(java.lang.String delimiter,
java.lang.String quote,
FieldTypeResolver fieldTypeResolver) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object[] |
cleanFields(java.lang.Object[] result) |
protected java.lang.Object[] |
cleanParsedLine(java.lang.Object[] split) |
java.lang.Object[] |
cleanSplit(java.lang.Object[] split,
java.util.regex.Pattern cleanPattern,
java.util.regex.Pattern escapePattern,
java.lang.String quote)
Method cleanSplit will return a quote free array of String values, the given
split array
will be updated in place. |
protected java.lang.Object[] |
coerceParsedLine(java.lang.String line,
java.lang.Object[] split) |
java.util.regex.Pattern |
createCleanPatternFor(java.lang.String quote)
Method createCleanPatternFor creates a regex
Pattern for removing quote characters from a String. |
java.util.regex.Pattern |
createEscapePatternFor(java.lang.String quote)
Method createEscapePatternFor creates a regex
Pattern cleaning quote escapes from a String. |
java.lang.String[] |
createSplit(java.lang.String value,
java.util.regex.Pattern splitPattern,
int numValues)
Method createSplit will split the given
value with the given splitPattern . |
java.util.regex.Pattern |
createSplitPatternFor(java.lang.String delimiter,
java.lang.String quote)
Method createSplitPatternFor creates a regex
Pattern for splitting a line of text into its component
parts using the given delimiter and quote Strings. |
java.lang.String |
getDelimiter() |
java.lang.String |
getQuote() |
protected java.lang.reflect.Type[] |
inferTypes(java.lang.Object[] result) |
java.lang.Appendable |
joinFirstLine(java.lang.Iterable iterable,
java.lang.Appendable buffer) |
java.lang.Appendable |
joinLine(java.lang.Iterable iterable,
java.lang.Appendable buffer) |
protected java.lang.Appendable |
joinNoQuote(java.lang.Iterable tuple,
java.lang.Appendable buffer) |
protected java.lang.Appendable |
joinWithQuote(java.lang.Iterable tuple,
java.lang.Appendable buffer) |
protected java.lang.Object[] |
onlyParseLine(java.lang.String line) |
Fields |
parseFirstLine(FlowProcess flowProcess,
Tap tap) |
java.lang.Object[] |
parseLine(java.lang.String line) |
protected java.lang.Iterable |
prepareFields(java.lang.Iterable fields) |
void |
reset(Fields sourceFields,
Fields sinkFields) |
void |
reset(java.lang.String delimiter,
java.lang.String quote,
java.lang.reflect.Type[] types,
boolean strict,
boolean safe,
Fields sourceFields,
Fields sinkFields,
FieldTypeResolver fieldTypeResolver) |
protected Fields sourceFields
protected java.util.regex.Pattern splitPattern
protected java.util.regex.Pattern cleanPattern
protected java.util.regex.Pattern escapePattern
protected java.lang.String delimiter
protected java.lang.String quote
protected boolean strict
protected boolean enforceStrict
protected int numValues
protected java.lang.reflect.Type[] types
protected CoercibleType[] coercibles
protected boolean safe
protected FieldTypeResolver fieldTypeResolver
public DelimitedParser(java.lang.String delimiter, java.lang.String quote, java.lang.Class[] types)
public DelimitedParser(java.lang.String delimiter, java.lang.String quote, java.lang.Class[] types, boolean strict, boolean safe)
public DelimitedParser(java.lang.String delimiter, java.lang.String quote, FieldTypeResolver fieldTypeResolver)
public DelimitedParser(java.lang.String delimiter, java.lang.String quote, java.lang.Class[] types, boolean strict, boolean safe, FieldTypeResolver fieldTypeResolver)
public DelimitedParser(java.lang.String delimiter, java.lang.String quote, java.lang.Class[] types, boolean strict, boolean safe, Fields sourceFields, Fields sinkFields)
public DelimitedParser(java.lang.String delimiter, java.lang.String quote, java.lang.Class[] types, boolean strict, boolean safe, Fields sourceFields, Fields sinkFields, FieldTypeResolver fieldTypeResolver)
public void reset(java.lang.String delimiter, java.lang.String quote, java.lang.reflect.Type[] types, boolean strict, boolean safe, Fields sourceFields, Fields sinkFields, FieldTypeResolver fieldTypeResolver)
public java.lang.String getDelimiter()
public java.lang.String getQuote()
public java.util.regex.Pattern createEscapePatternFor(java.lang.String quote)
Pattern
cleaning quote escapes from a String.
If quote
is null or empty, a null value will be returned;quote
- of type Stringpublic java.util.regex.Pattern createCleanPatternFor(java.lang.String quote)
Pattern
for removing quote characters from a String.
If quote
is null or empty, a null value will be returned;quote
- of type Stringpublic java.util.regex.Pattern createSplitPatternFor(java.lang.String delimiter, java.lang.String quote)
Pattern
for splitting a line of text into its component
parts using the given delimiter and quote Strings. quote
may be null.delimiter
- of type Stringquote
- of type Stringpublic java.lang.String[] createSplit(java.lang.String value, java.util.regex.Pattern splitPattern, int numValues)
value
with the given splitPattern
.value
- of type StringsplitPattern
- of type PatternnumValues
- of type intpublic java.lang.Object[] cleanSplit(java.lang.Object[] split, java.util.regex.Pattern cleanPattern, java.util.regex.Pattern escapePattern, java.lang.String quote)
split
array
will be updated in place.
If cleanPattern
is null, quote cleaning will not be performed, but all empty String values
will be replaces with a null
value.split
- of type Object[]cleanPattern
- of type PatternescapePattern
- of type Patternquote
- of type Stringpublic Fields parseFirstLine(FlowProcess flowProcess, Tap tap)
public java.lang.Object[] parseLine(java.lang.String line)
protected java.lang.Object[] cleanParsedLine(java.lang.Object[] split)
protected java.lang.Object[] coerceParsedLine(java.lang.String line, java.lang.Object[] split)
protected java.lang.Object[] onlyParseLine(java.lang.String line)
public java.lang.Appendable joinFirstLine(java.lang.Iterable iterable, java.lang.Appendable buffer)
public java.lang.Appendable joinLine(java.lang.Iterable iterable, java.lang.Appendable buffer)
protected java.lang.Appendable joinWithQuote(java.lang.Iterable tuple, java.lang.Appendable buffer) throws java.io.IOException
java.io.IOException
protected java.lang.Appendable joinNoQuote(java.lang.Iterable tuple, java.lang.Appendable buffer) throws java.io.IOException
java.io.IOException
protected java.lang.reflect.Type[] inferTypes(java.lang.Object[] result)
protected java.lang.Iterable prepareFields(java.lang.Iterable fields)
protected java.lang.Object[] cleanFields(java.lang.Object[] result)
Copyright © 2007-2015 Xplenty, Inc. All Rights Reserved.