prefuse.data.parser
Class TimeParser

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

public class TimeParser
extends DateParser

DataParser instance that parses Date values as java.util.Time instances, representing a particular time (but no specific date). This class uses a backing DateFormat instance to perform parsing. The DateFormat instance to use can be passed in to the constructor, or by default the DateFormat returned by DateFormat.getTimeInstance(int) with an argument of DateFormat.SHORT is used.

Author:
jeffrey heer

Field Summary
 
Fields inherited from class prefuse.data.parser.DateParser
m_dfmt, m_pos
 
Constructor Summary
TimeParser()
          Create a new TimeParser.
TimeParser(java.text.DateFormat dateFormat)
          Create a new TimeParser.
 
Method Summary
 boolean canParse(java.lang.String val)
          Indicates if the given text string can be successfully parsed by this parser.
 java.lang.Class getType()
          Returns java.sql.Time.class.
 java.lang.Object parse(java.lang.String val)
          Parse the given text string to a data value.
 java.sql.Time parseTime(java.lang.String text)
          Parse a Time value from a text string.
 
Methods inherited from class prefuse.data.parser.DateParser
format, parseDate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeParser

public TimeParser()
Create a new TimeParser.


TimeParser

public TimeParser(java.text.DateFormat dateFormat)
Create a new TimeParser.

Parameters:
dateFormat - the DateFormat instance to use for parsing
Method Detail

getType

public java.lang.Class getType()
Returns java.sql.Time.class.

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

canParse

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

Specified by:
canParse in interface DataParser
Overrides:
canParse in class DateParser
Parameters:
val - 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 val)
                       throws DataParseException
Description copied from interface: DataParser
Parse the given text string to a data value.

Specified by:
parse in interface DataParser
Overrides:
parse in class DateParser
Parameters:
val - 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)

parseTime

public java.sql.Time parseTime(java.lang.String text)
                        throws DataParseException
Parse a Time value from a text string.

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


Copyright © 2007 Regents of the University of California