com.google.visualization.datasource.base
Class BooleanFormat

java.lang.Object
  extended by java.text.Format
      extended by com.ibm.icu.text.UFormat
          extended by com.google.visualization.datasource.base.BooleanFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class BooleanFormat
extends com.ibm.icu.text.UFormat

A UFormat that performs formatting and parsing for boolean values. The string representation of boolean values is determined by two strings passed to the constructor of this class; a string for TRUE and a string for FALSE. Examples for text strings representing a BooleanValue that can be used in construction are: 1) true, false 2) TRUE, FALSE 2) t, f 3) yes, no 4) YES, NO 5) check, uncheck 6) Green, Red

Author:
Hillel M.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
java.text.Format.Field
 
Constructor Summary
BooleanFormat()
          Creates a BooleanFormat with default true/false formatting.
BooleanFormat(java.lang.String pattern)
          Constructs a boolean format from a pattern.
BooleanFormat(java.lang.String trueString, java.lang.String falseString)
          Creates a BooleanFormat.
 
Method Summary
 java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer appendTo, java.text.FieldPosition pos)
          Formats a Boolean and appends the result to a StringBuffer.
 java.lang.Boolean parse(java.lang.String text)
          Parses text from the beginning of the given string to produce a boolean.
 java.lang.Boolean parseObject(java.lang.String source, java.text.ParsePosition pos)
          Parses a string into a Boolean.
 
Methods inherited from class com.ibm.icu.text.UFormat
getLocale
 
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()
Creates a BooleanFormat with default true/false formatting.


BooleanFormat

public BooleanFormat(java.lang.String trueString,
                     java.lang.String falseString)
Creates a BooleanFormat.

Parameters:
trueString - A string representing true.
falseString - A string representing false.

BooleanFormat

public BooleanFormat(java.lang.String pattern)
Constructs a boolean format from a pattern. The pattern must contain two strings separated by colon, for example: "true:false".

Parameters:
pattern - The pattern from which to construct.
Method Detail

format

public java.lang.StringBuffer format(java.lang.Object obj,
                                     java.lang.StringBuffer appendTo,
                                     java.text.FieldPosition pos)
Formats a Boolean and appends the result to a StringBuffer.

Specified by:
format in class java.text.Format
Parameters:
obj - The object to format.
appendTo - The StringBuffer to which the formatted string will be appended.
pos - A FieldPosition param (not used in this class).
Returns:
A StringBuffer with the formatted string for this object.

parseObject

public java.lang.Boolean parseObject(java.lang.String source,
                                     java.text.ParsePosition pos)
Parses a string into a Boolean. A string can be either a trueString or a falseString (non-case sensitive).

Specified by:
parseObject in class java.text.Format
Parameters:
source - The string from which to parse.
pos - Marks the end of the parsing, or 0 if the parsing failed.
Returns:
A Boolean for the parsed string.

parse

public java.lang.Boolean parse(java.lang.String text)
                        throws java.text.ParseException
Parses text from the beginning of the given string to produce a boolean. The method may not use the entire text of the given string.

Parameters:
text - A String that should be parsed from it's start.
Returns:
A Boolean parsed from the string.
Throws:
java.text.ParseException - If the string cannot be parsed.


Copyright © 2009 Google. All Rights Reserved.