Static Public Member Functions

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)

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 void com.cosylab.util.WildcharMatcher.main ( String[]  args  )  [static]

Run test applet.

Parameters:
args command line parameters
static boolean com.cosylab.util.WildcharMatcher.match ( final String  pattern,
final String  str 
) [static]

DOCUMENT ME!

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

References com.cosylab.util.WildcharMatcher.parse().

static boolean com.cosylab.util.WildcharMatcher.parse ( final String  pattern,
final int  ofp,
final String  str,
final int  ofs 
) [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 com.cosylab.util.WildcharMatcher.testSet().

Referenced by com.cosylab.util.WildcharMatcher.match().

static boolean com.cosylab.util.WildcharMatcher.testSet ( final String  pattern,
int  offset,
final char  ch 
) [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!

Referenced by com.cosylab.util.WildcharMatcher.parse().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties