org.gwtwidgets.client.util.regex
Class Pattern

java.lang.Object
  extended by org.gwtwidgets.client.util.regex.Pattern

public class Pattern
extends java.lang.Object

Implementation of the java.util.regex.Pattern class with a wrapper aroung the Javascript RegExp object. As most of the methods delegate to the JavaScript RegExp object, certain differences in the declaration and behaviour of regular expressions must be expected.

Please note that neither the java.util.regex.Pattern#compile(String) method nor Matcher instances are supported. For the later, consider using match(String).

Author:
George Georgovassilis

Field Summary
static int CASE_INSENSITIVE
          Declares that characters are matched reglardless of case.
static int MULTILINE
          Declares that regular expressions should be matched across line borders.
 
Constructor Summary
Pattern(java.lang.String pattern)
          Class constructor
Pattern(java.lang.String pattern, int flags)
          Class constructor
 
Method Summary
 java.lang.String[] match(java.lang.String text)
          This method is borrowed from the JavaScript RegExp object.
 boolean matches(java.lang.String text)
          Determines wether a provided text matches the regular expression
static boolean matches(java.lang.String regex, java.lang.String input)
          Determines wether the specified regular expression is validated by the provided input.
 java.lang.String pattern()
          Returns the regular expression for this pattern
static java.lang.String quote(java.lang.String input)
          Escape a provided string so that it will be interpreted as a literal in regular expressions.
 java.lang.String[] split(java.lang.String input)
          Split an input string by the pattern's regular expression
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MULTILINE

public static final int MULTILINE
Declares that regular expressions should be matched across line borders.

See Also:
Constant Field Values

CASE_INSENSITIVE

public static final int CASE_INSENSITIVE
Declares that characters are matched reglardless of case.

See Also:
Constant Field Values
Constructor Detail

Pattern

public Pattern(java.lang.String pattern)
Class constructor

Parameters:
pattern - Regular expression

Pattern

public Pattern(java.lang.String pattern,
               int flags)
Class constructor

Parameters:
pattern - Regular expression
flags -
Method Detail

matches

public static boolean matches(java.lang.String regex,
                              java.lang.String input)
Determines wether the specified regular expression is validated by the provided input.

Parameters:
regex - Regular expression
input - String to validate
Returns:
true if matched.

quote

public static java.lang.String quote(java.lang.String input)
Escape a provided string so that it will be interpreted as a literal in regular expressions. The current implementation does escape each character even if not neccessary, generating verbose literals.

Parameters:
input -
Returns:

match

public java.lang.String[] match(java.lang.String text)
This method is borrowed from the JavaScript RegExp object. It parses a string and returns as an array any assignments to parenthesis groups in the pattern's regular expression

Parameters:
text -
Returns:
Array of strings following java's Pattern convention for groups: Group 0 is the entire input string and the remaining groups are the matched parenthesis. In case nothing was matched an empty array is returned.

matches

public boolean matches(java.lang.String text)
Determines wether a provided text matches the regular expression

Parameters:
text -
Returns:

pattern

public java.lang.String pattern()
Returns the regular expression for this pattern

Returns:

split

public java.lang.String[] split(java.lang.String input)
Split an input string by the pattern's regular expression

Parameters:
input -
Returns:
Array of strings

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.