net.sf.japaki.text
Class RegexFormat

java.lang.Object
  extended by java.text.Format
      extended by net.sf.japaki.text.AbstractFormat
          extended by net.sf.japaki.text.RegexFormat
All Implemented Interfaces:
Serializable, Cloneable

public class RegexFormat
extends AbstractFormat

A string format combined with a filter. It parses all strings matching a regular expression and ending with a delimiter.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.japaki.text.AbstractFormat
AbstractFormat.DefaultField
 
Nested classes/interfaces inherited from class java.text.Format
Format.Field
 
Constructor Summary
RegexFormat(String delimiter)
          Constructs a new RegexFormat.
 
Method Summary
static RegexFormat newInstance(Pattern delimiter, Pattern pattern)
          Constructs a new RegexFormat.
static RegexFormat newInstance(String delimiter, String pattern)
          Constructs a new RegexFormat.
 Object parseObject(String source, ParsePosition pos)
          Takes the head of the sourcestring up to the first occurence of the delimiter and tries to match it to the regular expression.
 
Methods inherited from class net.sf.japaki.text.AbstractFormat
appendAndSetIndexes, format, getField, setField
 
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

RegexFormat

public RegexFormat(String delimiter)
Constructs a new RegexFormat. Since there is no pattern, any string will pass parseObject.

Parameters:
delimiter - see above
Throws:
NullPointerException - if delimiter is null
Method Detail

newInstance

public static RegexFormat newInstance(Pattern delimiter,
                                      Pattern pattern)
Constructs a new RegexFormat.

Parameters:
delimiter - see above
pattern - see above
Returns:
the new format
Throws:
NullPointerException - if delimiter is null

newInstance

public static RegexFormat newInstance(String delimiter,
                                      String pattern)
Constructs a new RegexFormat.

Parameters:
delimiter - see above
pattern - see above
Returns:
the new format
Throws:
NullPointerException - if delimiter is null

parseObject

public Object parseObject(String source,
                          ParsePosition pos)
Takes the head of the sourcestring up to the first occurence of the delimiter and tries to match it to the regular expression.

Specified by:
parseObject in class Format
Parameters:
source - A String, part of which should be parsed
pos - A ParsePosition object with index and error index information.
Returns:
the head of the sourcestring without the delimiter
Throws:
NullPointerException - if source or pos is null.