public class FieldReader extends Object
Scanner. all lines starting with COMMENT will be
ignored.
Features: - key/value properties. - any field-structure per line - calls your ICallback in a foreach() loopyou can combine these features to read complex data structures.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEL_CSV |
static String |
DEL_KEYVALUE |
static String |
DEL_PROP |
static String |
HEADER |
| Constructor and Description |
|---|
FieldReader() |
| Modifier and Type | Method and Description |
|---|---|
static <RESULT> List<RESULT> |
forEach(InputStream stream,
ICallback<RESULT> callback)
convenience delegating to
forEach(InputStream, String, String, ICallback) with standard block definitions. |
static <RESULT> List<RESULT> |
forEach(InputStream stream,
String blockExpression,
String keyValueDelimiter,
ICallback<RESULT> callback)
runs through the stream, searching for the given blocks and providing each block content as property map to the callback.
|
static Properties |
read(InputStream stream,
boolean doClose)
delegates to
#read(InputStream, String, String, Locale) |
static Properties |
read(InputStream stream,
String keyValueDelimiter,
String propDelimiter,
Locale locale,
boolean doClose)
reads key/value properties from any file using a
Scanner. |
static Properties |
read(String file)
delegates to
#read(InputStream) |
static Map<Object,List> |
readTable(InputStream stream,
boolean horizontal,
boolean header,
boolean rowIDs,
String rowPattern)
|
static Map<Object,List> |
readTable(InputStream stream,
Class... columnTypes)
delegates to
readTable(InputStream, String, Locale, boolean, boolean, boolean, Class...) for simple
tables without header and rowIDs. |
static Map<Object,List> |
readTable(InputStream stream,
String rowPattern)
delegates to
readTable(InputStream, boolean, boolean, boolean, String) for a simple table without header
and row-ids. |
static Map<Object,List> |
readTable(InputStream stream,
String fieldDelimiter,
Locale locale,
boolean horizontal,
boolean header,
boolean rowIDs,
Class... columnTypes)
reads values in columns and rows from any file using a
Scanner. |
static Map<Object,List> |
readTable(String file,
Class... columnTypes)
delegates to
readTable(InputStream, Class...) |
public static final String HEADER
public static final String DEL_KEYVALUE
public static final String DEL_PROP
public static final String DEL_CSV
public static Map<Object,List> readTable(String file, Class... columnTypes)
readTable(InputStream, Class...)public static Map<Object,List> readTable(InputStream stream, Class... columnTypes)
readTable(InputStream, String, Locale, boolean, boolean, boolean, Class...) for simple
tables without header and rowIDs.public static Map<Object,List> readTable(InputStream stream, String fieldDelimiter, Locale locale, boolean horizontal, boolean header, boolean rowIDs, Class... columnTypes)
Scanner.stream - input streamfieldDelimiter - delimiter between two values. normally DEL_CSV.locale - locale to format formats etc. normally the default locale Locale.getDefault().horizontal - if false, the map will be rotated to provide columns instead of rowsheader - if true, the first line will be read as header informationrowIDs - if true, all first column values will be read as row-id objects - otherwise a line counter will be
used.columnTypes - indicates the column value types. known Scanner types are: byte, boolean, short, int, long,
float, double, BigInteger, BigDecimal. the given locale defines the format of that types.HEADER. all
other keys are rowIDs or line indexes.public static Map<Object,List> readTable(InputStream stream, String rowPattern)
readTable(InputStream, boolean, boolean, boolean, String) for a simple table without header
and row-ids.public static Map<Object,List> readTable(InputStream stream, boolean horizontal, boolean header, boolean rowIDs, String rowPattern)
Scanner. giving a rows regular expression defines
the column formats for each row. see Scanner for examples. the row pattern should have grouping with
brackets like '(\w+) fish (\w+) fish (\w+)'.stream - input streamfieldDelimiter - delimiter between two values. normally DEL_CSV.locale - locale to format formats etc. normally the default locale Locale.getDefault().horizontal - if false, the map will be rotated to provide columns instead of rowsheader - if true, the first line will be read as header informationrowIDs - if true, all first column values will be read as row-id objects - otherwise a line counter will be
used.rowPattern - HEADER. all
other keys are rowIDs or line indexes.public static Properties read(String file)
#read(InputStream)public static Properties read(InputStream stream, boolean doClose)
#read(InputStream, String, String, Locale)public static Properties read(InputStream stream, String keyValueDelimiter, String propDelimiter, Locale locale, boolean doClose)
Scanner.stream - input streamkeyValueDelimiter - delimiter between key and value. normally DEL_KEYVALUE.propDelimiter - delimiter between two property entries. normally DEL_PROPlocale - locale to format formats etc. normally the default locale Locale.getDefault().public static <RESULT> List<RESULT> forEach(InputStream stream, ICallback<RESULT> callback)
forEach(InputStream, String, String, ICallback) with standard block definitions.public static <RESULT> List<RESULT> forEach(InputStream stream, String blockExpression, String keyValueDelimiter, ICallback<RESULT> callback)
stream - source streamblockExpression - defining the content of one block to read the properties fromkeyValueDelimiter - key-value delimitercallback - workerCopyright © 2012–2018. All rights reserved.