net.sf.japaki.text
Class RegexFormat
java.lang.Object
java.text.Format
net.sf.japaki.text.AbstractFormat
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
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
newInstance
public static RegexFormat newInstance(Pattern delimiter,
Pattern pattern)
- Constructs a new RegexFormat.
- Parameters:
delimiter
- see abovepattern
- 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 abovepattern
- 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 parsedpos
- 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
.