|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.beanio.internal.parser.format.FieldPadding
public class FieldPadding
Provides field padding functionality. By default, padded fields are left justified and padded using a space.
The method init()
must be called after all properties are set.
If optional is set to true, the field text may be padded with spaces regardless of the configured filler when a value does not exist.
Once configured, a FieldPadding object is thread-safe.
Field Summary | |
---|---|
static char |
LEFT
Left justification |
static char |
RIGHT
Right justification |
Constructor Summary | |
---|---|
FieldPadding()
Constructs a new FieldPadding. |
Method Summary | |
---|---|
char |
getFiller()
Returns the character used to pad field text. |
char |
getJustify()
Returns the justification of the field text within its padding. |
int |
getLength()
Returns the padded length of the field. |
Class<?> |
getPropertyType()
Returns the property type of the field, or null if the field is not bound to a bean object. |
void |
init()
Initializes padding settings. |
boolean |
isOptional()
Returns whether the field is optional. |
String |
pad(String text)
Formats field text. |
void |
setFiller(char filler)
Sets the character used to pad field text. |
void |
setJustify(char justify)
Sets the justification of the field text within its padding. |
void |
setLength(int length)
Sets the padded length of the field. |
void |
setOptional(boolean required)
Sets whether the field is optional. |
protected void |
setPaddedNull(String paddedNull)
Sets the padded field text for a null value. |
void |
setPropertyType(Class<?> type)
Sets the property type of the field. |
String |
unpad(String fieldText)
Removes padding from the field text. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char RIGHT
public static final char LEFT
Constructor Detail |
---|
public FieldPadding()
Method Detail |
---|
public void init()
pad(String)
or unpad(String)
is called.
public String pad(String text)
text
- the field text to format
public String unpad(String fieldText)
fieldText
- the field text to remove padding
public char getFiller()
public void setFiller(char filler)
filler
- the filler characterpublic int getLength()
public void setLength(int length)
length
- the padded lengthpublic char getJustify()
LEFT
or RIGHT
public void setJustify(char justify)
justify
- either LEFT
or RIGHT
public boolean isOptional()
public void setOptional(boolean required)
required
- true if optional, false otherwisepublic Class<?> getPropertyType()
public void setPropertyType(Class<?> type)
type
- the property typeprotected void setPaddedNull(String paddedNull)
paddedNull
- the field text for a null value
|
BeanIO 2.0.4 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |