|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.jmatchparser.util.csv.FixedWidthColumn
public class FixedWidthColumn
A column of a fixed-width CSV file.
Nested Class Summary | |
---|---|
static class |
FixedWidthColumn.Alignment
Enumeration of possible column alignments. |
Constructor Summary | |
---|---|
FixedWidthColumn(int width)
Create a left-aligned fixed-width column of the given width. |
|
FixedWidthColumn(int width,
FixedWidthColumn.Alignment alignment)
Create a fixed-width column of the given width and alignment. |
|
FixedWidthColumn(int width,
FixedWidthColumn.Alignment alignment,
char pad)
Create a fixed-width column of the given width and alignment, which uses the given character to pad the value on both sides if needed. |
|
FixedWidthColumn(int width,
FixedWidthColumn.Alignment alignment,
char padLeft,
char padRight)
Create a fixed-width column of the given width and alignment, which uses two different characters to pad the value on left or right side if needed. |
|
FixedWidthColumn(int width,
FixedWidthColumn.Alignment alignment,
char padLeft,
char padRight,
String... exceptionStrings)
Create a fixed-width column of the given width and alignment, which uses two different characters to pad the value on left or right side if needed and the given exception strings. |
Method Summary | |
---|---|
String |
formatValue(String value,
boolean truncate,
boolean allowOverflow)
Format a value to store it into a fixed-width CSV file. |
int |
getWidth()
Get the width of this column. |
static FixedWidthColumn |
parse(String colSpec)
Parse a column from a column specification string. |
String |
parseValue(String value)
Parse a value from a fixed-width CSV file, i. e. remove padding and check for exception strings. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FixedWidthColumn(int width)
width
- The widthpublic FixedWidthColumn(int width, FixedWidthColumn.Alignment alignment)
width
- The widthalignment
- The alignmentpublic FixedWidthColumn(int width, FixedWidthColumn.Alignment alignment, char pad)
width
- The widthalignment
- The alignmentpad
- The padding characterpublic FixedWidthColumn(int width, FixedWidthColumn.Alignment alignment, char padLeft, char padRight)
width
- The widthalignment
- The alignmentpadLeft
- The left padding characterpadRight
- The right padding characterpublic FixedWidthColumn(int width, FixedWidthColumn.Alignment alignment, char padLeft, char padRight, String... exceptionStrings)
FixedWidthColumn(int, Alignment, char, char)
constructor.
Values that contain one of the given exception strings are considered
invalid.
width
- The widthalignment
- The alignmentpadLeft
- The left padding characterpadRight
- The right padding characterexceptionStrings
- The exception strings (may not contain null or empty strings!)Method Detail |
---|
public static FixedWidthColumn parse(String colSpec)
The specification starts with the column width as a decimal number, followed by an optional LRTB for the alignment, followed by an optional slash followed by one or two padding characters. If two padding characters are given, another slash delimits exception strings (each one delimited by yet another slash). An empty exception list (but with the leading slash) is treated as no exceptions.
A missing parameter is treated as the default as used by the
FixedWidthColumn(int)
constructor.
colSpec
- column specification
public String parseValue(String value)
value
- Value to parse
public String formatValue(String value, boolean truncate, boolean allowOverflow) throws IOException
value
- Value to formattruncate
- Whether to silently truncate overlong valuesallowOverflow
- Whether to allow overflow for long values
IOException
public int getWidth()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |