org.edg.data.util
Class RegExp2SQL

java.lang.Object
  |
  +--org.edg.data.util.RegExp2SQL

public final class RegExp2SQL
extends java.lang.Object

The utility class performing translation of subset of regular expressions into SQL reg/ expressions.

Version:
$Id: RegExp2SQL.java,v 1.5 2003/10/27 13:14:45 jamesc Exp $
Author:
Peter Kunszt, Radovan Chytracek

Method Summary
static boolean containsWildcards(java.lang.String rePattern)
           
static java.lang.String translate(java.lang.String rePattern)
          Translates a regular expression to SQL wildcard to be used inside LIKE SQL statements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

translate

public static final java.lang.String translate(java.lang.String rePattern)
Translates a regular expression to SQL wildcard to be used inside LIKE SQL statements. Accepts only subset of reg. expression matching capabilities of SQL. The allowed operators are:
 '_' - gets passed through
 '%' - gets passed through
 '?'  - gets translated into '_' in SQL
 '*'  - gets translated into '%' in SQL
 
We also escape these characters, i.e. "foo\\_" will be presenting in the database as SQL "foo\_".

Parameters:
rePattern - the regular expression pattern
Returns:
SQL style reg. expression if parsing was successful

containsWildcards

public static final boolean containsWildcards(java.lang.String rePattern)