|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.formatter.PrefixSuffixFormatter<T>
public class PrefixSuffixFormatter<T>
Formats a value with optional prefix and suffix. This formatter uses a parent formatter to format the actual value and then adds prefix and suffix as needed to the start and end of the formatted value.
The parseString(String)
method will first check if
the string start or ends with the given prefix/suffix. If it does,
the prefix/suffix is removed before parsing is delegated to the
parent.
Field Summary | |
---|---|
static char |
NBSP
The character representing a non-breaking space. |
private Formatter<T> |
parent
|
private String |
prefix
|
private String |
suffix
|
Constructor Summary | |
---|---|
PrefixSuffixFormatter(String prefix,
Formatter<T> parent,
String suffix)
Create a new formatter. |
Method Summary | |
---|---|
String |
format(T value)
Format a value by converting it to a string. |
T |
parseString(String value)
Parse a string and return a value of the correct type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char NBSP
private final String prefix
private final Formatter<T> parent
private final String suffix
Constructor Detail |
---|
public PrefixSuffixFormatter(String prefix, Formatter<T> parent, String suffix)
prefix
- The prefix, or null to not use any prefixparent
- The parent formatter, if null a ToStringFormatter
is automatically createdsuffix
- The suffix, or null to not use any suffixMethod Detail |
---|
public String format(T value)
Formatter
format
in interface Formatter<T>
value
- The value to format
public T parseString(String value)
Formatter
parseString
in interface Formatter<T>
value
- The string to parse
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |