|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcascading.scheme.util.DelimitedParser
public class DelimitedParser
Class DelimitedParser is a base class for parsing text delimited files.
It maybe sub-classed to change its behavior. The interfaceFieldTypeResolver
maybe used to clean and prepare field names
for data columns, and to infer type information from column names.
Field Summary | |
---|---|
protected Pattern |
cleanPattern
Field cleanPattern |
protected CoercibleType[] |
coercibles
Fields coercibles |
protected String |
delimiter
Field delimiter * |
protected boolean |
enforceStrict
Field enforceStrict |
protected Pattern |
escapePattern
Field escapePattern |
protected FieldTypeResolver |
fieldTypeResolver
fieldTypeResolver |
protected int |
numValues
Field numValues |
protected String |
quote
Field quote |
protected boolean |
safe
Field safe |
protected Fields |
sourceFields
Field sourceFields |
protected Pattern |
splitPattern
Field splitPattern |
protected boolean |
strict
Field strict |
protected Type[] |
types
Field types |
Constructor Summary | |
---|---|
DelimitedParser(String delimiter,
String quote,
Class[] types)
|
|
DelimitedParser(String delimiter,
String quote,
Class[] types,
boolean strict,
boolean safe)
|
|
DelimitedParser(String delimiter,
String quote,
Class[] types,
boolean strict,
boolean safe,
Fields sourceFields,
Fields sinkFields)
|
|
DelimitedParser(String delimiter,
String quote,
Class[] types,
boolean strict,
boolean safe,
Fields sourceFields,
Fields sinkFields,
FieldTypeResolver fieldTypeResolver)
|
|
DelimitedParser(String delimiter,
String quote,
Class[] types,
boolean strict,
boolean safe,
FieldTypeResolver fieldTypeResolver)
|
|
DelimitedParser(String delimiter,
String quote,
FieldTypeResolver fieldTypeResolver)
|
Method Summary | |
---|---|
protected Object[] |
cleanFields(Object[] result)
|
protected Object[] |
cleanParsedLine(Object[] split)
|
Object[] |
cleanSplit(Object[] split,
Pattern cleanPattern,
Pattern escapePattern,
String quote)
Method cleanSplit will return a quote free array of String values, the given split array
will be updated in place. |
protected Object[] |
coerceParsedLine(String line,
Object[] split)
|
Pattern |
createCleanPatternFor(String quote)
Method createCleanPatternFor creates a regex Pattern for removing quote characters from a String. |
Pattern |
createEscapePatternFor(String quote)
Method createEscapePatternFor creates a regex Pattern cleaning quote escapes from a String. |
String[] |
createSplit(String value,
Pattern splitPattern,
int numValues)
Method createSplit will split the given value with the given splitPattern . |
Pattern |
createSplitPatternFor(String delimiter,
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. |
String |
getDelimiter()
|
String |
getQuote()
|
protected Type[] |
inferTypes(Object[] result)
|
Appendable |
joinFirstLine(Iterable iterable,
Appendable buffer)
|
Appendable |
joinLine(Iterable iterable,
Appendable buffer)
|
protected Appendable |
joinNoQuote(Iterable tuple,
Appendable buffer)
|
protected Appendable |
joinWithQuote(Iterable tuple,
Appendable buffer)
|
protected Object[] |
onlyParseLine(String line)
|
Fields |
parseFirstLine(FlowProcess flowProcess,
Tap tap)
|
Object[] |
parseLine(String line)
|
protected Iterable |
prepareFields(Iterable fields)
|
void |
reset(Fields sourceFields,
Fields sinkFields)
|
void |
reset(String delimiter,
String quote,
Type[] types,
boolean strict,
boolean safe,
Fields sourceFields,
Fields sinkFields,
FieldTypeResolver fieldTypeResolver)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Fields sourceFields
protected Pattern splitPattern
protected Pattern cleanPattern
protected Pattern escapePattern
protected String delimiter
protected String quote
protected boolean strict
protected boolean enforceStrict
protected int numValues
protected Type[] types
protected CoercibleType[] coercibles
protected boolean safe
protected FieldTypeResolver fieldTypeResolver
Constructor Detail |
---|
public DelimitedParser(String delimiter, String quote, Class[] types)
public DelimitedParser(String delimiter, String quote, Class[] types, boolean strict, boolean safe)
public DelimitedParser(String delimiter, String quote, FieldTypeResolver fieldTypeResolver)
public DelimitedParser(String delimiter, String quote, Class[] types, boolean strict, boolean safe, FieldTypeResolver fieldTypeResolver)
public DelimitedParser(String delimiter, String quote, Class[] types, boolean strict, boolean safe, Fields sourceFields, Fields sinkFields)
public DelimitedParser(String delimiter, String quote, Class[] types, boolean strict, boolean safe, Fields sourceFields, Fields sinkFields, FieldTypeResolver fieldTypeResolver)
Method Detail |
---|
public void reset(Fields sourceFields, Fields sinkFields)
public void reset(String delimiter, String quote, Type[] types, boolean strict, boolean safe, Fields sourceFields, Fields sinkFields, FieldTypeResolver fieldTypeResolver)
public String getDelimiter()
public String getQuote()
public Pattern createEscapePatternFor(String quote)
Pattern
cleaning quote escapes from a String.
If quote
is null or empty, a null value will be returned;
quote
- of type String
public Pattern createCleanPatternFor(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 String
public Pattern createSplitPatternFor(String delimiter, 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 String
public String[] createSplit(String value, Pattern splitPattern, int numValues)
value
with the given splitPattern
.
value
- of type StringsplitPattern
- of type PatternnumValues
- of type int
public Object[] cleanSplit(Object[] split, Pattern cleanPattern, Pattern escapePattern, 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 String
public Fields parseFirstLine(FlowProcess flowProcess, Tap tap)
public Object[] parseLine(String line)
protected Object[] cleanParsedLine(Object[] split)
protected Object[] coerceParsedLine(String line, Object[] split)
protected Object[] onlyParseLine(String line)
public Appendable joinFirstLine(Iterable iterable, Appendable buffer)
public Appendable joinLine(Iterable iterable, Appendable buffer)
protected Appendable joinWithQuote(Iterable tuple, Appendable buffer) throws IOException
IOException
protected Appendable joinNoQuote(Iterable tuple, Appendable buffer) throws IOException
IOException
protected Type[] inferTypes(Object[] result)
protected Iterable prepareFields(Iterable fields)
protected Object[] cleanFields(Object[] result)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |