Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

com::cosylab::util::WildcharMatcher Class Reference

List of all members.

Static Public Member Functions

boolean testSet (final String pattern, int offset, final char ch)
boolean parse (final String pattern, final int ofp, final String str, final int ofs)
boolean match (final String pattern, final String str)
void main (String[] args)

Static Private Member Functions

int getToken (final char ch)

Static Private Attributes

final boolean DEBUG = false
final int INITIAL = 0
final int FINAL = 2
final int ERROR = 99
final int TOKEN_CHAR = 0
final int TOKEN_END = 1
final int TOKEN_NOT = 2
final int TOKEN_MINUS = 3
final int[][] TRANSITIONS

Detailed Description

A Unix-like wildchar matcher. Supported wild-characters: '', '?'; sets: [a-z], '!' negation Examples: '[a-g]li?n' matches 'florian' '[!abc]e' matches 'smile' '[-z] matches 'a' Rules for sets: RegEx definition of the valid set is: [!]?(-.)?((.-.)|(.))(.-)? a-z : match any letter between 'a' and 'z' inclusively [-a : match everything up to and including 'a' (only valid at beginning) a-] : match everything from 'a' (only valid at the end) a : match exactly 'a' !a : not operator, match everything except 'a' (only allowed at beginning) : treat a literally (useful for specifying '!]-' in sets. Note that

... are not processed. Wildchar rules: : match any number (0..inf) number of occurences of any character ? : match exactly and only one occurence of any character ab : match exactly 'ab' [..]: same as , but character must match the set.

Author:
Ales Pucelj
Version:
$id$


Member Function Documentation

int com::cosylab::util::WildcharMatcher::getToken final char  ch  )  [inline, static, private]
 

void com::cosylab::util::WildcharMatcher::main String[]  args  )  [inline, static]
 

Run test applet.

Parameters:
args command line parameters

boolean com::cosylab::util::WildcharMatcher::match final String  pattern,
final String  str
[inline, static]
 

DOCUMENT ME!

Parameters:
pattern DOCUMENT ME!
str DOCUMENT ME!
Returns:
DOCUMENT ME!

boolean com::cosylab::util::WildcharMatcher::parse final String  pattern,
final int  ofp,
final String  str,
final int  ofs
[inline, static]
 

Recursive method for parsing the string. To avoid copying the strings, the method accepts offset indices into both parameters.

Parameters:
pattern Pattern used in parsing
ofp Offset into pattern string (ofp > 0)
str String to test
ofs Offset into test string (ofs > 0);
Returns:
boolean Do the strings match

boolean com::cosylab::util::WildcharMatcher::testSet final String  pattern,
int  offset,
final char  ch
[inline, static]
 

DFA for parsing set strings. DFA was obtained from JFlex using the rule : macro: CHAR = [^-\]\!] (everything except ], ! and - rule : [!]?(-{CHAR})?(({CHAR}-{CHAR})|({CHAR}))({CHAR}-)?\] Result of optimized NDFA is Character classes: class 0: [0-' ']['"'-',']['.'-'\']['^'-65535] class 1: [']'] class 2: ['!'] class 3: ['-'] Transition graph (for class goto state) State 0: 0 -> 1, 1 -> 2, 2 -> 3, 3 -> 4 State 1: 0 -> 1, 1 -> 2, 3 -> 5 State [FINAL] State 3: 0 -> 1, 1 -> 2, 3 -> 4 State 4: 0 -> 6 State 5: 0 -> 6, 1 -> 2 State 6: 0 -> 1, 1 -> 2

Parameters:
pattern DOCUMENT ME!
offset DOCUMENT ME!
ch DOCUMENT ME!
Returns:
DOCUMENT ME!


Member Data Documentation

final boolean com::cosylab::util::WildcharMatcher::DEBUG = false [static, private]
 

final int com::cosylab::util::WildcharMatcher::ERROR = 99 [static, private]
 

Value of error state

final int com::cosylab::util::WildcharMatcher::FINAL = 2 [static, private]
 

Value of final state

final int com::cosylab::util::WildcharMatcher::INITIAL = 0 [static, private]
 

Value of initial state

final int com::cosylab::util::WildcharMatcher::TOKEN_CHAR = 0 [static, private]
 

Any character (except control, unless escaped)

final int com::cosylab::util::WildcharMatcher::TOKEN_END = 1 [static, private]
 

Token for end of set: ]

final int com::cosylab::util::WildcharMatcher::TOKEN_MINUS = 3 [static, private]
 

Token for range specification: -

final int com::cosylab::util::WildcharMatcher::TOKEN_NOT = 2 [static, private]
 

Token for negation:

final int [][] com::cosylab::util::WildcharMatcher::TRANSITIONS [static, private]
 

Initial value:

{ { 1, FINAL, 3, 4 }, { 1, FINAL, ERROR, 5 }, { ERROR, ERROR, ERROR, ERROR }, { 1, FINAL, ERROR, 4 }, { 6, ERROR, ERROR, ERROR }, { 6, FINAL, ERROR, ERROR }, { 1, FINAL, ERROR, ERROR } }
Transition table holds the nextState used in set parsing. Rows define states, columns define tokens. transitions[1][3] = 5 means: if in state 1 next token is 3, goto state 5


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 03:13:18 2009 for ACS Java API by doxygen 1.3.8