org.xins.common.text
Class SimplePatternParser

java.lang.Object
  extended byorg.xins.common.text.SimplePatternParser

public class SimplePatternParser
extends Object

Simple pattern parser.

Format

A simple pattern is a text string that may contain letters, digits, underscores, hyphens, dots and the wildcard characters '*' (asterisk) and '?' (question mark).

The location of an asterisk indicates any number of characters is allowed. The location of a question mark indicates exactly one character is expected.

To allow matching of simple patterns, a simple pattern is first compiled into a Perl 5 regular expression. Every asterisk is converted to ".*", while every question mark is converted to ".".

Examples

Examples of conversions from a simple pattern to a Perl 4 regular expression:

Simple patternPerl 5 regex equivalent
* .*
? .
_Get* _Get.*
_Get*i?n _Get.*i.n
*on .*on
_Get*,_Dis* _Get.*|_Dis.*

Since:
XINS 1.0.0
Version:
$Revision: 1.16 $ $Date: 2006/10/05 15:35:29 $
Author:
Ernst de Haan, Peter Troon

Constructor Summary
SimplePatternParser()
          Creates a new SimplePatternParser object.
 
Method Summary
 Perl5Pattern parseSimplePattern(String simplePattern)
          Converts the specified simple pattern to a Perl 5 regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePatternParser

public SimplePatternParser()
Creates a new SimplePatternParser object.

Method Detail

parseSimplePattern

public Perl5Pattern parseSimplePattern(String simplePattern)
                                throws IllegalArgumentException,
                                       ParseException
Converts the specified simple pattern to a Perl 5 regular expression.

Parameters:
simplePattern - the simple pattern, cannot be null.
Returns:
the Perl 5 regular expression, never null.
Throws:
IllegalArgumentException - if simplePattern == null.
ParseException - if provided simplePattern is invalid or could not be parsed.


See http://www.xins.org/.