|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
org.jcoderz.commons.logging.WhitespaceFormat
public final class WhitespaceFormat
This Formatter formats the whitespace of a string, The space char
' ' is left untouched, all other whitespace chars are
replaced and compressed by exactly one space char in a row. It extends the
Format type in a unsymmetric way: A formatted String cannot be parsed in a
way that the result is equal to the source string.
If allocated with a sub format, first the sub format is used for formatting,
the rewsult will be formatted by this.
In addition to the Format implementation it offers static access methods
for the format functionality.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.Format |
|---|
Format.Field |
| Constructor Summary | |
|---|---|
WhitespaceFormat()
Creates a new instance of this with no sub format. |
|
WhitespaceFormat(Format subFormat)
Creates a new instance of this with the supplied sub format. |
|
| Method Summary | |
|---|---|
static CharBuffer |
format(CharBuffer message)
Replaced and reduces whitespace in the supplied character buffer. |
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
If a sub format is set, it uses this to format the object and compresses the whitespace within the result. |
static String |
format(String message)
Replaces and reduces whitespace in the supplied message. |
Object |
parseObject(String source,
ParsePosition pos)
If a sub format is set, it delegates parsing to the sub format. |
| Methods inherited from class java.text.Format |
|---|
clone, format, formatToCharacterIterator, parseObject |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WhitespaceFormat()
public WhitespaceFormat(Format subFormat)
subFormat - The sub format to use for first step formatting of an
object. This will be used for parsing an object as well. Might be null.| Method Detail |
|---|
public static String format(String message)
' ' as white space. Any such
character in the source string is left untouched, all other whitespace
characters are replaced by ' ', but with only one in a
row, so, for example, a sequence of 2 line separators will be replaced
by one ' '.
message - The message in which to find and replace white space.
public static CharBuffer format(CharBuffer message)
message - The message buffer in which to find and replace white
space.
message if it does not contain whitespace to replace.format(String)
public Object parseObject(String source,
ParsePosition pos)
PRESERVED_CHAR.
parseObject in class FormatFormat.parseObject(java.lang.String, java.text.ParsePosition)
public StringBuffer format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
format in class Formatobj - The object to format.toAppendTo - The string buffer where to append to the formatted
object.pos - The field position for formatting.
Format.format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||