com.plumtree.openfoundation.util
Class XPRegex

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPRegex

public class XPRegex
extends java.lang.Object

Represents A Regular Expression object. The pattern string represented by this regular expression object should be conforming to the Perl5 regular expression syntax, because the underlying Java class only allow for such pattern strings.


Field Summary
static int DEFAULT_OPTION
          Perl5 regular expression default case.
static int IGNORE_CASE
          Perl5 regular expression ignore case.
 
Constructor Summary
XPRegex(java.lang.String pattern)
          Initializes and compiles an instance of the XPRegex class for the specified regular expression.
XPRegex(java.lang.String pattern, int flags)
          Initializes and compiles an instance of the XPRegex class for the specified regular expression.
 
Method Summary
 boolean IsMatch(java.lang.String input)
          Indicates whether the regular expression finds a match in the input string.
static boolean IsMatch(java.lang.String input, java.lang.String pattern)
          Indicates whether the regular expression finds a match in the input string.
 XPMatch Match(java.lang.String input)
          Searches an input string for an occurrence of a regular expression and returns the first Match found.
static XPMatch Match(java.lang.String input, java.lang.String pattern)
          Searches an input string for an occurrence of a regular expression and returns the first Match found.
 XPMatch[] Matches(java.lang.String input)
          Searches an input string for all occurrences of a regular expression and returns all the successful matches.
static XPMatch[] Matches(java.lang.String input, java.lang.String pattern)
          Searches an input string for all occurrences of a regular expression and returns all the successful matches.
 java.lang.String toString()
          Returns the regular expression pattern that was passed into the XPRegex constructor.
 java.lang.String ToString()
          Returns the regular expression pattern that was passed into the XPRegex constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IGNORE_CASE

public static final int IGNORE_CASE
Perl5 regular expression ignore case.

See Also:
Constant Field Values

DEFAULT_OPTION

public static final int DEFAULT_OPTION
Perl5 regular expression default case.

See Also:
Constant Field Values
Constructor Detail

XPRegex

public XPRegex(java.lang.String pattern,
               int flags)
Initializes and compiles an instance of the XPRegex class for the specified regular expression.

Parameters:
pattern - The regular expression pattern to match. The string should be conforming to the Perl5 regular expression syntax
flags - A boolean specifies if the regular expression should be matched case-insensitively
Throws:
XPIllegalArgumentException - If pattern does not conform to Perl5 regular expression syntax

XPRegex

public XPRegex(java.lang.String pattern)
Initializes and compiles an instance of the XPRegex class for the specified regular expression.

Parameters:
pattern - The regular expression pattern to match. The string should be conforming to the Perl5 regular expression syntax
Throws:
XPIllegalArgumentException - If pattern does not conform to Perl5 regular expression syntax
Method Detail

IsMatch

public boolean IsMatch(java.lang.String input)
Indicates whether the regular expression finds a match in the input string.

Parameters:
input - The input string to test for a match.
Returns:
True if the regular expression finds a match in the input string, false otherwise.

IsMatch

public static boolean IsMatch(java.lang.String input,
                              java.lang.String pattern)
Indicates whether the regular expression finds a match in the input string.

Parameters:
input - The input string to test for a match.
pattern - The regular expression pattern to match. The string should be conforming to the Perl5 regular expression syntax
Returns:
True if the regular expression finds a match in the input string, false otherwise.
Throws:
XPIllegalArgumentException - If pattern does not conform to the Perl5 regular expression syntax

Match

public XPMatch Match(java.lang.String input)
Searches an input string for an occurrence of a regular expression and returns the first Match found. It returns the first match found, even if there are multiple matches in the string.

Parameters:
input - The input string to test for a match.
Returns:
An XPMatch instance containing the first match found in the input string for this regular expression. If no match was found, returns an empty XPMatch instance which will return false upon calling Success()

Match

public static XPMatch Match(java.lang.String input,
                            java.lang.String pattern)
Searches an input string for an occurrence of a regular expression and returns the first Match found. It returns the first match found, even if there are multiple matches in the string.

Parameters:
input - The input string to test for a match.
pattern - The regular expression pattern to match. The string should be conforming to the Perl5 regular expression syntax.
Returns:
An XPMatch instance containing the first match found in the input string for this regular expression. If no match was found, returns an empty XPMatch instance which will return false upon calling Success()
Throws:
XPIllegalArgumentException - If pattern does not conform to Perl5 regular expression syntax

Matches

public XPMatch[] Matches(java.lang.String input)
Searches an input string for all occurrences of a regular expression and returns all the successful matches.

Parameters:
input - The input string to test for a match.
Returns:
successful match values array

Matches

public static XPMatch[] Matches(java.lang.String input,
                                java.lang.String pattern)
Searches an input string for all occurrences of a regular expression and returns all the successful matches.

Parameters:
input - The input string to test for a match.
pattern - The regular expression pattern to match. The string should be conforming to the Perl5 regular expression syntax.
Returns:
successful match value array.

ToString

public java.lang.String ToString()
Returns the regular expression pattern that was passed into the XPRegex constructor.

Returns:
the regular expression pattern that was passed into the XPRegex constructor.

toString

public java.lang.String toString()
Returns the regular expression pattern that was passed into the XPRegex constructor.

Returns:
the regular expression pattern that was passed into the XPRegex constructor.


Copyright 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.