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

List of all members.

Static Public Member Functions

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

Static Private Member Functions

static int getToken (final char ch)

Static Private Attributes

static final boolean DEBUG = false
static final int INITIAL = 0
static final int FINAL = 2
static final int ERROR = 99
static final int TOKEN_CHAR = 0
static final int TOKEN_END = 1
static final int TOKEN_NOT = 2
static final int TOKEN_MINUS = 3
static 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

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

References TOKEN_CHAR, TOKEN_END, TOKEN_MINUS, and TOKEN_NOT.

Referenced by testSet().

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

Run test applet.

Parameters:
args command line parameters
static 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!

References parse().

static 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

References DEBUG, and testSet().

Referenced by match().

static 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!

References DEBUG, ERROR, FINAL, getToken(), INITIAL, TOKEN_CHAR, TOKEN_END, TOKEN_NOT, and TRANSITIONS.

Referenced by parse().


Member Data Documentation

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

Referenced by parse(), and testSet().

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

Value of error state

Referenced by testSet().

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

Value of final state

Referenced by testSet().

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

Value of initial state

Referenced by testSet().

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

Any character (except control, unless escaped)

Referenced by getToken(), and testSet().

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

Token for end of set: ]

Referenced by getToken(), and testSet().

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

Token for range specification: -

Referenced by getToken().

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

Token for negation:

Referenced by getToken(), and testSet().

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

Referenced by testSet().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2