net.coderazzi.filters.parser
Class Parser
java.lang.Object
net.coderazzi.filters.parser.Parser
- All Implemented Interfaces:
- IParser
public class Parser
- extends Object
- implements IParser
Basic implementation of a IParser
, supporting only simple operators
referring to the content of a single column.
The supporter operators include:
- Comparison operators. The comparison is done on the parsed object, not
on the string representation, unless no
Format
or Comparator
is defined for the given type. For example, specifying the
text ">= 4" implies, for a column with integer types, that a
direct comparison between integers will be performed. These operators
are:
- >=
- >
- <
- <=
- <>, !: all behave the same
- Basic wildcard operators. These operators work using the string
representation of the types (using, when possible, the defined
Format
instance). Only two wildcard characters are defined: * and ?
- ~: for example ~ *vadis* will filter in all expressions including
the substring vadis
- !~: negates the previous operator
- Regular expression operator. There is only one such operator: ~~,
accepting a java regular expression.
In addition, providing no operator will behave as the operator ~, unless
the text can be parsed as a (non string) object; in this case, it will behave
as operator =.
Method Summary |
String |
escape(String expression)
Escapes a given expression, such that, when parsed, the parser will make
no character/operator substitutions. |
RowFilter |
parseText(String expression)
Parses the text, returning a filter that can be applied to the table. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Parser
public Parser(Format format,
Comparator classComparator,
Comparator<String> stringComparator,
boolean ignoreCase,
int modelIndex)
parseText
public RowFilter parseText(String expression)
throws ParseException
- Description copied from interface:
IParser
- Parses the text, returning a filter that can be applied to the table.
- Specified by:
parseText
in interface IParser
- Parameters:
expression
- the text to parse
- Throws:
ParseException
escape
public String escape(String expression)
- Description copied from interface:
IParser
- Escapes a given expression, such that, when parsed, the parser will make
no character/operator substitutions.
- Specified by:
escape
in interface IParser
Copyright © 2011 coderazzi. All Rights Reserved.