com.acsinet_solutions.util.regexp
Class RegexpUtils

java.lang.Object
  extended by com.acsinet_solutions.util.regexp.RegexpUtils

public final class RegexpUtils
extends java.lang.Object

Regexp related utility methods that do not fall in any other class of the package.

Author:
Santiago Arriaga

Constructor Summary
RegexpUtils()
           
 
Method Summary
static Perl5Regexp getRegexp(java.lang.String re)
          Get the regexp string according to the given re String.
static Perl5Regexp getValidRegexp(java.lang.String re)
          Get the regexp string according to the given re String.
static java.lang.Integer tryGetInteger(Perl5Regexp regexp, java.lang.String str)
          Try to get an integer from the given regexp and input String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexpUtils

public RegexpUtils()
Method Detail

getValidRegexp

public static Perl5Regexp getValidRegexp(java.lang.String re)
Get the regexp string according to the given re String. This method uses an internal map to cache regular string requests, so common requests need not to be created several times. A Regexp is a long-lived object, and may serve many simultaneous requests, so this approach seem adequate.

This version throws an unchecked exception if an error occurs.

Parameters:
re - A valid regular expression String instance.
Throws:
java.lang.IllegalArgumentException - Thrown if the regular expression argument String is not a valid regular expression string.

getRegexp

public static Perl5Regexp getRegexp(java.lang.String re)
                             throws SyntaxException
Get the regexp string according to the given re String. This method uses an internal map to cache regular string requests, so common requests need not to be created several times. A Regexp is a long-lived object, and may serve many simultaneous requests, so this approach seem adequate.

This version throws a checked exception if an error occurs.

Parameters:
re - A valid regular expression String instance.
Throws:
SyntaxException - Thrown if the regular expression argument String is not a valid regular expression string.

tryGetInteger

public static final java.lang.Integer tryGetInteger(Perl5Regexp regexp,
                                                    java.lang.String str)
Try to get an integer from the given regexp and input String.

Parameters:
regexp - A valid Perl5Regexp which contains an integer first match
Returns:
null if the expression didn't match; a not-null Integer value otherwise