View Javadoc

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