View Javadoc

1   package net.sf.cantina.tags;
2   
3   import javax.servlet.jsp.PageContext;
4   
5   /***
6    * @author Stephane JAIS
7    */
8   public abstract class TagUtils
9   {
10    public static int getScope(String scope)
11    throws IllegalArgumentException
12    {
13      if (scope.equalsIgnoreCase("page"))
14        return PageContext.PAGE_SCOPE;
15      if (scope.equalsIgnoreCase("session"))
16        return PageContext.SESSION_SCOPE;
17      if (scope.equalsIgnoreCase("application"))
18        return PageContext.APPLICATION_SCOPE;
19      if (scope.equalsIgnoreCase("request"))
20        return PageContext.REQUEST_SCOPE;
21      throw new IllegalArgumentException(
22        "["+scope+"] not a valid scope. Must supply one of page/request/session/application");
23    }
24  }