001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.commons.monitoring.web.jsp; 019 020 import javax.servlet.jsp.PageContext; 021 import java.util.HashMap; 022 import java.util.Map; 023 024 public final class TagUtils { 025 /** 026 * Maps JSP scope names to PageContext constants 027 */ 028 private static final Map<String, Integer> scopes = new HashMap<String, Integer>(); 029 static { 030 scopes.put("page", PageContext.PAGE_SCOPE); 031 scopes.put("request", PageContext.REQUEST_SCOPE); 032 scopes.put("session", PageContext.SESSION_SCOPE); 033 scopes.put("application", PageContext.APPLICATION_SCOPE); 034 } 035 036 public static int getScope(final String scopeName) { 037 return scopes.get(scopeName.toLowerCase()); 038 } 039 040 private TagUtils() { 041 // no-op 042 } 043 }