public static final class AsciiParser.RegexParser extends java.lang.Object implements AsciiParser.RecordParser
| Constructor and Description |
|---|
RegexParser(AsciiParser parser,
java.lang.String regex) |
| Modifier and Type | Method and Description |
|---|---|
int |
fieldCount()
indicate the number of fields this RecordParser is
expecting on each line.
|
int |
fieldCount(java.lang.String line)
return what this would be if spitting by whitespace.
|
java.lang.String[] |
fields(java.lang.String line)
show the fields found in the line.
|
static java.lang.String[] |
getNamedGroups(java.lang.String regex) |
java.lang.String |
readNextRecord(java.io.BufferedReader reader)
return the next record in a String, or null of no more records exist.
|
boolean |
splitRecord(java.lang.String line,
java.lang.String[] fields)
attempts to extract fields from the record, returning true if
the record could be split.
|
java.lang.String |
toString() |
boolean |
tryParseRecord(java.lang.String line,
int irec,
DataSetBuilder builder)
returns true if the line appears to be a record.
|
public RegexParser(AsciiParser parser, java.lang.String regex)
public static java.lang.String[] getNamedGroups(java.lang.String regex)
public int fieldCount()
AsciiParser.RecordParserfieldCount in interface AsciiParser.RecordParserpublic java.lang.String readNextRecord(java.io.BufferedReader reader)
throws java.io.IOException
AsciiParser.RecordParserreadNextRecord in interface AsciiParser.RecordParserjava.io.IOExceptionpublic final boolean tryParseRecord(java.lang.String line,
int irec,
DataSetBuilder builder)
AsciiParser.RecordParsertryParseRecord in interface AsciiParser.RecordParserline - the line from the file.irec - the record numberbuilder - the builder into which the data is inserted.public int fieldCount(java.lang.String line)
fieldCount in interface AsciiParser.RecordParserline - the line from the file, to attempt parsing.public java.lang.String[] fields(java.lang.String line)
line - public boolean splitRecord(java.lang.String line,
java.lang.String[] fields)
AsciiParser.RecordParsersplitRecord in interface AsciiParser.RecordParserline - the line from the file.fields - array to store the fields. fieldCount() should be used
to determine the length of the array.public java.lang.String toString()
toString in class java.lang.Object