net.sf.uadetector.internal.util
Class RegularExpressionConverter

java.lang.Object
  extended by net.sf.uadetector.internal.util.RegularExpressionConverter

public final class RegularExpressionConverter
extends java.lang.Object


Nested Class Summary
static class RegularExpressionConverter.Flag
           
 
Method Summary
static java.lang.String convertPatternToPerlRegex(java.util.regex.Pattern pattern)
          Converts a given Pattern into a PERL style regular expression.
static java.util.regex.Pattern convertPerlRegexToPattern(java.lang.String regex)
          Converts a PERL style regular expression into Java style.
static java.util.regex.Pattern convertPerlRegexToPattern(java.lang.String regex, boolean faultTolerant)
          Converts a PERL style regular expression into Java style.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

convertPatternToPerlRegex

public static java.lang.String convertPatternToPerlRegex(@Nonnull
                                                         java.util.regex.Pattern pattern)
Converts a given Pattern into a PERL style regular expression.

Parameters:
pattern - regular expression pattern
Returns:
PERL style regular expression as string

convertPerlRegexToPattern

public static java.util.regex.Pattern convertPerlRegexToPattern(@Nonnull
                                                                java.lang.String regex)
Converts a PERL style regular expression into Java style.

The leading and ending slash and the modifiers will be removed. The modifiers will be translated into equivalents flags of java.util.Pattern. If there are modifiers that are not valid an exception will be thrown.

Parameters:
regex - A PERL style regular expression
Returns:
Pattern

convertPerlRegexToPattern

public static java.util.regex.Pattern convertPerlRegexToPattern(@Nonnull
                                                                java.lang.String regex,
                                                                @Nonnull
                                                                boolean faultTolerant)
Converts a PERL style regular expression into Java style.

The leading and ending slash and the modifiers will be removed.

Parameters:
regex - A PERL style regular expression
faultTolerant - Fault-tolerant translating the flags
Returns:
Pattern


Copyright © 2011-2014. All Rights Reserved.