net.sf.fikin.pojostate.format
Class BooleanFormat

java.lang.Object
  extended by java.text.Format
      extended by net.sf.fikin.pojostate.format.BooleanFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class BooleanFormat
extends java.text.Format

Default implementation of boolean format

It supports pattern configurable text representation for true and false. One has to pass following text to the constructor: "value-for-true;value-for-false".

Examples:

      Format f = new BooleanFormat( "true;false" );
      Format f = new BooleanFormat( "1;0" );
 
created on Jul 6, 2005

Since:
Version:
$Revision: 1.1 $
Author:
fiykov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
java.text.Format.Field
 
Constructor Summary
BooleanFormat()
          instantiate Boolean formatter with default strings "true" and "false"
BooleanFormat(java.lang.String pattern)
          instantiate new Boolean formatter with given pattern.
 
Method Summary
 java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
          format Boolean into predefined strings, one for true other for false.
 java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)
          not supported
 
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

BooleanFormat

public BooleanFormat()
instantiate Boolean formatter with default strings "true" and "false"


BooleanFormat

public BooleanFormat(java.lang.String pattern)
instantiate new Boolean formatter with given pattern.

Expected text is in the format "text for true:text for false".

Parameters:
pattern - in the format "text for true:text for false"
Method Detail

parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    java.text.ParsePosition pos)
not supported

Specified by:
parseObject in class java.text.Format
Parameters:
source -
pos -
Returns:
null

format

public java.lang.StringBuffer format(java.lang.Object obj,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
format Boolean into predefined strings, one for true other for false.

One can change the default "true" and "false" by instantiating the object with proper pattern text. See above documentation.

Specified by:
format in class java.text.Format
Parameters:
obj - has to be java.lang.Boolean
toAppendTo - to append the string representation of obj
pos - is irrelevant in this method
Returns:
updated toAppendTo


Copyright © 2005 Nikolay Fiykov. All Rights Reserved.