net.sf.jmatchparser.util.csv.fieldreader
Class ParseFormat<T>

java.lang.Object
  extended by net.sf.jmatchparser.util.csv.fieldreader.ParseFormat<T>
Type Parameters:
T - Type of the parsed object

public abstract class ParseFormat<T>
extends Object

A format for parsing a String to an object of a possibly different type.


Field Summary
static ParseFormat<String> IDENTITY
          Parse format that returns the original string.
 
Constructor Summary
ParseFormat()
           
 
Method Summary
static
<TT extends Enum<TT>>
ParseFormat<TT>
forEnum(Class<TT> enumType)
          Parse format that parses Enum names to their values.
static ParseFormat<Date> fromDateFormat(DateFormat format)
          Parse format that uses a DateFormat for parsing.
static ParseFormat<Object> fromFormat(Format format)
          Parse format that uses a Format for parsing.
static ParseFormat<Number> fromNumberFormat(NumberFormat format)
          Parse format that uses a NumberFormat for parsing.
static
<TT> ParseFormat<TT>
fromReplacement(Pattern regex, String replacement, ParseFormat<TT> nextFormat)
          Parse format that performs a regex replacement before parsing with another format.
abstract  T parse(String source)
          Parse the given source completely.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENTITY

public static final ParseFormat<String> IDENTITY
Parse format that returns the original string.

Constructor Detail

ParseFormat

public ParseFormat()
Method Detail

parse

public abstract T parse(String source)
                 throws ParseException
Parse the given source completely. An exception is thrown if not the complete source has been parsed.

Parameters:
source - Source string
Returns:
Parsed object
Throws:
ParseException

fromFormat

public static ParseFormat<Object> fromFormat(Format format)
Parse format that uses a Format for parsing.


fromDateFormat

public static ParseFormat<Date> fromDateFormat(DateFormat format)
Parse format that uses a DateFormat for parsing.


fromNumberFormat

public static ParseFormat<Number> fromNumberFormat(NumberFormat format)
Parse format that uses a NumberFormat for parsing.


fromReplacement

public static <TT> ParseFormat<TT> fromReplacement(Pattern regex,
                                                   String replacement,
                                                   ParseFormat<TT> nextFormat)
Parse format that performs a regex replacement before parsing with another format.


forEnum

public static <TT extends Enum<TT>> ParseFormat<TT> forEnum(Class<TT> enumType)
Parse format that parses Enum names to their values.



Copyright © 2011. All Rights Reserved.