View Javadoc

1   package com.atlassian.plugin.servlet.filter;
2   
3   import java.util.Locale;
4   
5   /**
6    * An enumeration defining the places plugin filters can appear in an applications filter stack.  The locations are
7    * defined by what operations they immediate precede or follow.
8    * 
9    * @since 2.1.0
10   */
11  public enum FilterLocation
12  {
13      AFTER_ENCODING,
14      BEFORE_LOGIN,
15      BEFORE_DECORATION,
16      BEFORE_DISPATCH;
17  
18      /**
19       * Parses a filter location from a string.  Characters are converted to uppercase, and dashes into underscores.
20       *
21       * @param value The filter location as a string
22       * @return The The matching filter location.  Will never be null.
23       * @throws IllegalArgumentException If the filter string is null or can't be matched to a filter location enum
24       */
25      public static FilterLocation parse(String value) throws IllegalArgumentException
26      {
27          if (value != null)
28          {
29              return FilterLocation.valueOf(value.toUpperCase(Locale.ENGLISH).replace('-','_'));
30          }
31          else
32          {
33              throw new IllegalArgumentException("Invalid filter location: "+value);
34          }
35      }
36  }