Re: Perl matcher vs JDK4 matcher

Peter Donald <peter-4lf8KW9E9MLMqX/[email protected]> Sun, 13 Jul 2003 09:11:25 +1000
Newsgroups gmane.comp.java.spice.devel
Message-ID <[email protected]>
On Sat, 12 Jul 2003 11:25 pm, James Walker wrote:
> Peter Donald wrote:
> > On Sat, 12 Jul 2003 12:24 am, James Walker wrote:
> >>Any particular reason that salt is highly dependent on the Oro matcher
> >>classes?
> >>
> >>Just to make it usable under 1.3?
> >
> > Essentially. What I was planning on doing was adding a extremely
> > simplified Regex facade to support either oro or jdk1.4 into salt. This
> > facade would just support commonly required operations (ie regex replace,
> > match etc on strings) and wouldn't offer full support but would make it
> > possible to have salt (and dependent applications) only require oro for
> > jdk1.3
>
> Then we'd have to condigure each salt class - or at least the salt
> distribution - prior to usage which would be a bit of a pain - not that
> having to include oro isn't a pain..
>
> Suppose that could be a system property (or 3) - defaulting to oro or
> jdk1.4 classes.

The way I was thinking of doing it is having a singleton facade that all regex 
operations are delegating to. So most regex operations look something like

public static String replaceRegex( String pattern, String input )
{
  _facade.replaceRegex( pattern, input );
}

Then in static initializer of RegexUtil instantiate the facade by first 
checking if JDK14 is compatible and if not fall back to attempting to oro and 
if that fails then throw an exception. Something like

try
{
  clazz = Class.forName( "org.realityforge.salt.regex.JDK14RegexFacade" );
}
catch( ClassNotFoundException cnfe )
{
  try
  {
    clazz = Class.forName( "org.realityforge.salt.regex.ORORegexFacade" );
  }
  catch( ClassNotFoundException cnfe )
  {
    throw new Error( "Unable to init facade as pre-JDK1.4 and oro library not 
present" );
  }
}

-- 
Cheers,

Peter Donald
*---------------------------------------------*
| "The only way to discover the limits of the |
|  possible is to go beyond them into the     |
|            impossible." -Arthur C. Clarke   |
*---------------------------------------------*



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1