prefuse.data.parser
Class BooleanParser

java.lang.Object
  extended by prefuse.data.parser.BooleanParser
All Implemented Interfaces:
DataParser

public class BooleanParser
extends java.lang.Object
implements DataParser

DataParser instance that parses boolean values. The string "true" is parsed to true values, "false" to false values. Both are case insensitive.

Author:
jeffrey heer

Field Summary
static java.lang.String FALSE
          Text string indicating a "false" value.
static java.lang.String TRUE
          Text string indicating a "true" value.
 
Constructor Summary
BooleanParser()
           
 
Method Summary
 boolean canParse(java.lang.String text)
          Indicates if the given text string can be successfully parsed by this parser.
 java.lang.String format(java.lang.Object value)
          Get a String representation for the given value.
 java.lang.Class getType()
          Returns boolean.class.
 java.lang.Object parse(java.lang.String text)
          Parse the given text string to a data value.
 boolean parseBoolean(java.lang.String text)
          Parse a boolean value from a text string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUE

public static final java.lang.String TRUE
Text string indicating a "true" value.

See Also:
Constant Field Values

FALSE

public static final java.lang.String FALSE
Text string indicating a "false" value.

See Also:
Constant Field Values
Constructor Detail

BooleanParser

public BooleanParser()
Method Detail

getType

public java.lang.Class getType()
Returns boolean.class.

Specified by:
getType in interface DataParser
Returns:
the parsed data type for this parser as a Java Class instance
See Also:
DataParser.getType()

format

public java.lang.String format(java.lang.Object value)
Description copied from interface: DataParser
Get a String representation for the given value.

Specified by:
format in interface DataParser
Parameters:
value - the object value to format
Returns:
a formatted String representing the input value
See Also:
DataParser.format(java.lang.Object)

canParse

public boolean canParse(java.lang.String text)
Description copied from interface: DataParser
Indicates if the given text string can be successfully parsed by this parser.

Specified by:
canParse in interface DataParser
Parameters:
text - the text string to check for parsability
Returns:
true if the string can be successfully parsed into this parser's data type, false otherwise
See Also:
DataParser.canParse(java.lang.String)

parse

public java.lang.Object parse(java.lang.String text)
                       throws DataParseException
Description copied from interface: DataParser
Parse the given text string to a data value.

Specified by:
parse in interface DataParser
Parameters:
text - the text string to parse
Returns:
the parsed data value, which will be an instance of the Class returned by the DataParser.getType() method
Throws:
DataParseException - if an error occurs during parsing
See Also:
DataParser.parse(java.lang.String)

parseBoolean

public boolean parseBoolean(java.lang.String text)
                     throws DataParseException
Parse a boolean value from a text string

Parameters:
text - the text string to parse
Returns:
the parsed boolean value
Throws:
DataParseException - if an error occurs during parsing


Copyright © 2007 Regents of the University of California