|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.io.FieldContainer
de.fu_berlin.ties.io.DelimSepValues
public class DelimSepValues
A field container that stores and processed its contents as values separated
by a pipe character: '|' (a different delimiter string can be specified by
changing the "dsv.field.separator" property). Entries are separated by
newlines (or by whitespace if the "dsv.entry.separator.ws" is set to
true
).
The very first non-comment line contains the field names, separated by
pipes. Each further non-comment lines contains the values of a entry
(FieldMap
). The first non-comment line must
contain as least as most pipes as each further line, so the field names
are known for all fields of all field maps. Empty fields can be used to
separate sections.
The '#' character can be used to introduce comment lines. Comments and lines that are empty or contain only whitespace are ignored when reading data.
Pipe characters and newlines within fields and '#' at the begin of the first field of an entry are escaped with a backslash. The recommended character set for storing delimiter-separated values is UTF-8.
Floats and doubles are formatted (rounded) via
Util.format(double)
.
Field Summary | |
---|---|
static char |
COMMENT_START
The character introducing a comment: '#'. |
static char |
ESCAPE
The escape character: '\' (a backslash). |
static String |
FILE_EXT
The recommended file extension for this format: "dsv" (delimiter-separated values). |
Constructor Summary | |
---|---|
DelimSepValues()
Creates a new empty instance, using the standard configuration. |
|
DelimSepValues(Element element)
Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface. |
|
DelimSepValues(Element element,
TiesConfiguration config)
Creates a new instance from an XML element, fulfilling the recommandation of the XMLStorable interface. |
|
DelimSepValues(String fieldSep,
String entrySep,
String[] fixedHeaderNames)
Creates a new empty instance. |
|
DelimSepValues(TiesConfiguration config)
Creates a new empty instance. |
Method Summary | |
---|---|
void |
read(CharSequence input)
Reads data as delimiter-separated values. |
void |
read(CharSequence input,
String[] keys)
Reads data as delimiter-separated values, using a specified array of field names. |
void |
store(Writer writer)
Serializes contents as delimiter-separated values. |
Methods inherited from class de.fu_berlin.ties.io.FieldContainer |
---|
add, add, add, add, add, addKey, backgroundMap, createFieldContainer, createObjects, entryIterator, keyCount, keyIterator, read, read, recommendedExtension, size, store, storeContainerInFile, storeInFile, toElement, toElement, toElement, toElement, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String FILE_EXT
public static final char COMMENT_START
public static final char ESCAPE
Constructor Detail |
---|
public DelimSepValues()
public DelimSepValues(TiesConfiguration config)
config
- used to configure this instancepublic DelimSepValues(String fieldSep, String entrySep, String[] fixedHeaderNames)
fieldSep
- the field separator to useentrySep
- the entry separator to usefixedHeaderNames
- an optional fixed list of keys to use; if
null
, keys are read from/written to the first line of a
DSV filepublic DelimSepValues(Element element)
XMLStorable
interface. Uses the
standard configuration
to configure this
instance.
element
- the XML element containing the serialized representationpublic DelimSepValues(Element element, TiesConfiguration config)
XMLStorable
interface.
element
- the XML element containing the serialized representationconfig
- used to configure this instanceMethod Detail |
---|
public void read(CharSequence input)
read
in class FieldContainer
input
- the input data to processpublic void read(CharSequence input, String[] keys)
input
- the input data to processkeys
- the array of field names; or null
if the field
names should be determined from the first line of the inputpublic void store(Writer writer) throws IOException
store
in class FieldContainer
writer
- the writer to write to; flushed but not closed by this
method
IOException
- if an I/O error occurs while writing to the stream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |