RegularExpressionPatternCompileMode.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */


  20. package org.openspcoop2.utils.regexp;


  21. import java.util.regex.Pattern;

  22. /** Enumeration contenente le modalita' di compilazione delle espressioni regolari
  23.  *
  24.  * @author Andrea Poli (apoli@link.it)
  25.  * @author $Author$
  26.  * @version $Rev$, $Date$
  27.  */

  28. public enum RegularExpressionPatternCompileMode {

  29.     /**
  30.      * Enables canonical equivalence.
  31.      *
  32.      * When this flag is specified then two characters will be considered to match if, and only if,
  33.      * their full canonical decompositions match.
  34.      * The expression "a\u030A", for example, will match the string "?" when this flag is specified.
  35.      * By default, matching does not take canonical equivalence into account.
  36.      *
  37.      * There is no embedded flag character for enabling canonical equivalence.  
  38.      *
  39.      * Specifying this flag may impose a performance penalty.
  40.      **/
  41.     CANON_EQ(Pattern.CANON_EQ),
  42.    
  43.     /**
  44.      * Enables case-insensitive matching.
  45.      *
  46.      * By default, case-insensitive matching assumes that only characters in the US-ASCII charset are being matched.
  47.      * Unicode-aware case-insensitive matching can be enabled by specifying the UNICODE_CASE flag in conjunction (or)
  48.      * with this flag.
  49.      *
  50.      * Case-insensitive matching can also be enabled via the embedded flag expression (?i).
  51.      *
  52.      * Specifying this flag may impose a slight performance penalty.
  53.      **/
  54.     CASE_INSENSITIVE(Pattern.CASE_INSENSITIVE),
  55.    
  56.     /**
  57.      * Permits whitespace and comments in pattern.
  58.      *
  59.      * In this mode, whitespace is ignored, and embedded comments starting with # are ignored until the end of a line.
  60.      *
  61.      * Comments mode can also be enabled via the embedded flag expression (?x).
  62.      **/
  63.     COMMENTS(Pattern.COMMENTS),
  64.    
  65.     /**
  66.      * Enables dotall mode.
  67.      *
  68.      * In dotall mode, the expression . matches any character, including a line terminator.
  69.      * By default this expression does not match line terminators.
  70.      *
  71.      * Dotall mode can also be enabled via the embedded flag expression (?s).
  72.      * (The s is a mnemonic for "single-line" mode, which is what this is called in Perl.)
  73.      **/
  74.     DOTALL(Pattern.DOTALL),
  75.    
  76.     /**
  77.      * Enables literal parsing of the pattern.
  78.      *
  79.      * When this flag is specified then the input string that specifies the pattern is treated as a sequence of literal characters.
  80.      * Metacharacters or escape sequences in the input sequence will be given no special meaning.
  81.      *
  82.      * The flags CASE_INSENSITIVE and UNICODE_CASE retain their impact on matching when used in conjunction with this flag.
  83.      * The other flags become superfluous.
  84.      *
  85.      * There is no embedded flag character for enabling literal parsing.
  86.      **/
  87.     LITERAL(Pattern.LITERAL),
  88.    
  89.     /**
  90.      * Enables multiline mode.
  91.      *
  92.      * In multiline mode the expressions ^ and $ match just after or just before, respectively,
  93.      * a line terminator or the end of the input sequence.
  94.      * By default these expressions only match at the beginning and the end of the entire input sequence.
  95.      *
  96.      * Multiline mode can also be enabled via the embedded flag expression (?m).
  97.      **/
  98.     MULTILINE(Pattern.MULTILINE),
  99.    
  100.     /**
  101.      * Enables Unicode-aware case folding.
  102.      *
  103.      * When this flag is specified then case-insensitive matching, when enabled by the CASE_INSENSITIVE flag,
  104.      * is done in a manner consistent with the Unicode Standard.
  105.      * By default, case-insensitive matching assumes that only characters in the US-ASCII charset are being matched.
  106.      *
  107.      * Unicode-aware case folding can also be enabled via the embedded flag expression (?u).
  108.      *
  109.      * Specifying this flag may impose a performance penalty.
  110.      **/
  111.     UNICODE_CASE(Pattern.UNICODE_CASE),
  112.    
  113.     /**
  114.      * Enables Unix lines mode.
  115.      *
  116.      * In this mode, only the '\n' line terminator is recognized in the behavior of ., ^, and $.
  117.      *
  118.      * Unix lines mode can also be enabled via the embedded flag expression (?d).
  119.      **/
  120.     UNIX_LINES(Pattern.UNIX_LINES);
  121.    
  122.     private int value;

  123.     RegularExpressionPatternCompileMode(int value)
  124.     {
  125.         this.value = value;
  126.     }

  127.     public int getPatternCompileMode()
  128.     {
  129.         return this.value;
  130.     }
  131.    
  132.     @Override
  133.     public String toString(){
  134.         return this.name();
  135.     }
  136.    
  137.    
  138. }