net.sf.uadetector.internal.util
Enum RegularExpressionConverter.Flag

java.lang.Object
  extended by java.lang.Enum<RegularExpressionConverter.Flag>
      extended by net.sf.uadetector.internal.util.RegularExpressionConverter.Flag
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<RegularExpressionConverter.Flag>
Enclosing class:
RegularExpressionConverter

public static enum RegularExpressionConverter.Flag
extends java.lang.Enum<RegularExpressionConverter.Flag>


Enum Constant Summary
CANON_EQ
          Enables canonical equivalence.
CASE_INSENSITIVE
          Enables case-insensitive matching.
COMMENTS
          Permits whitespace and comments in pattern.
DOTALL
          Enables dotall mode.
LITERAL
          Enables literal parsing of the pattern.
MULTILINE
          Enables multiline mode.
UNICODE_CASE
          Enables Unicode-aware case folding.
UNIX_LINES
          Enables Unix lines mode.
 
Method Summary
static int convertToBitmask(java.util.Collection<RegularExpressionConverter.Flag> flags)
          Converts a set of flags as to a bitmask (sum of numerical values).
static java.lang.String convertToModifiers(java.util.Collection<RegularExpressionConverter.Flag> flags)
          Converts a set of flags as to a string representation.
static RegularExpressionConverter.Flag evaluateByCharacter(char flag)
          This method try to find a matching enum value by the given character representation.
static RegularExpressionConverter.Flag evaluateByNumber(int flag)
          This method try to find a matching enum value by the given numerical representation.
 char getCharacter()
          Returns this flag as character representation.
 int getNumber()
          Returns this flag as numerical representation.
static java.util.Set<RegularExpressionConverter.Flag> parse(int bitmask)
          Parses a sum of flags as numerical values (bitmask) and translates it to set of enum values.
static java.util.Set<RegularExpressionConverter.Flag> parse(java.lang.String modifiers)
          Translates PERL style modifiers to a set of Pattern compatible ones.
static RegularExpressionConverter.Flag valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static RegularExpressionConverter.Flag[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

CANON_EQ

public static final RegularExpressionConverter.Flag CANON_EQ
Enables canonical equivalence.


CASE_INSENSITIVE

public static final RegularExpressionConverter.Flag CASE_INSENSITIVE
Enables case-insensitive matching.


COMMENTS

public static final RegularExpressionConverter.Flag COMMENTS
Permits whitespace and comments in pattern.


DOTALL

public static final RegularExpressionConverter.Flag DOTALL
Enables dotall mode.


LITERAL

public static final RegularExpressionConverter.Flag LITERAL
Enables literal parsing of the pattern.


MULTILINE

public static final RegularExpressionConverter.Flag MULTILINE
Enables multiline mode.


UNICODE_CASE

public static final RegularExpressionConverter.Flag UNICODE_CASE
Enables Unicode-aware case folding.


UNIX_LINES

public static final RegularExpressionConverter.Flag UNIX_LINES
Enables Unix lines mode.

Method Detail

values

public static RegularExpressionConverter.Flag[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (RegularExpressionConverter.Flag c : RegularExpressionConverter.Flag.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static RegularExpressionConverter.Flag valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

convertToBitmask

public static int convertToBitmask(@Nonnull
                                   java.util.Collection<RegularExpressionConverter.Flag> flags)
Converts a set of flags as to a bitmask (sum of numerical values).

Parameters:
flags - a set of flags
Returns:
sum of numerical values of passed flags or 0

convertToModifiers

public static java.lang.String convertToModifiers(@Nonnull
                                                  java.util.Collection<RegularExpressionConverter.Flag> flags)
Converts a set of flags as to a string representation. The flags CASE_INSENSITIVE, DOTALL, MULTILINE and COMMENTS are identical to the PERL regular expression modifiers.

Parameters:
flags - a set of flags
Returns:
sum of numerical values of passed flags or 0

evaluateByCharacter

public static RegularExpressionConverter.Flag evaluateByCharacter(char flag)
This method try to find a matching enum value by the given character representation. The character will be evaluated against the stored character of a flag.

Parameters:
flag - representation of a flag as a character
Returns:
the matching enum value or null
Throws:
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the given number is smaller than zero

evaluateByNumber

public static RegularExpressionConverter.Flag evaluateByNumber(int flag)
This method try to find a matching enum value by the given numerical representation. The number will be evaluated against the stored number of a flag.

Parameters:
flag - representation of a flag as a character
Returns:
the matching enum value or null
Throws:
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the given number is smaller than zero

parse

@Nonnull
public static java.util.Set<RegularExpressionConverter.Flag> parse(@Nonnegative
                                                                           int bitmask)
Parses a sum of flags as numerical values (bitmask) and translates it to set of enum values.

Parameters:
bitmask - Sum of numerical values of flags
Returns:
a set of flags
Throws:
net.sf.qualitycheck.exception.IllegalNegativeArgumentException - if the given number is smaller than zero

parse

public static java.util.Set<RegularExpressionConverter.Flag> parse(@Nonnull
                                                                   java.lang.String modifiers)
Translates PERL style modifiers to a set of Pattern compatible ones.

Parameters:
modifiers - modifiers as string of a PERL style regular expression
Returns:
a set of modifier flags that may include CASE_INSENSITIVE, MULTILINE, DOTALL and COMMENTS

getCharacter

public char getCharacter()
Returns this flag as character representation.

Returns:
representation as a character

getNumber

public int getNumber()
Returns this flag as numerical representation.

Returns:
representation as a number


Copyright © 2011-2014. All Rights Reserved.