Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javax.servlet.jsp.el;
import java.beans.FeatureDescriptor;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.PropertyNotWritableException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.PageContext;
/**
* Provides resolution in EL for the implicit variables of a JSP page.
*
* @since JSP 2.1
*/
public class ImplicitObjectELResolver extends ELResolver {
/**
* Creates an instance of the implicit object resolver for EL.
*/
public ImplicitObjectELResolver() {
super();
}
@Override
public Object getValue(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null && property != null) {
Scope scope = Scope.lookupMap.get(property.toString());
if (scope != null) {
return scope.getScopeValue(context, base, property);
}
}
return null;
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" }) // TCK signature test fails with generics
public Class getType(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null && property != null) {
if (Scope.lookupMap.containsKey(property.toString())) {
context.setPropertyResolved(base, property);
}
}
return null;
}
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
Objects.requireNonNull(context);
if (base == null && property != null) {
if (Scope.lookupMap.containsKey(property.toString())) {
context.setPropertyResolved(base, property);
throw new PropertyNotWritableException();
}
}
}
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
Objects.requireNonNull(context);
if (base == null && property != null) {
if (Scope.lookupMap.containsKey(property.toString())) {
context.setPropertyResolved(base, property);
return true;
}
}
return false;
}
@Override
public Iterator getFeatureDescriptors(ELContext context, Object base) {
List feats = new ArrayList<>(Scope.values().length);
FeatureDescriptor feat;
for (Scope scope : Scope.values()) {
feat = new FeatureDescriptor();
feat.setDisplayName(scope.implicitName);
feat.setExpert(false);
feat.setHidden(false);
feat.setName(scope.implicitName);
feat.setPreferred(true);
feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
feat.setValue(TYPE, String.class);
feats.add(feat);
}
return feats.iterator();
}
@Override
public Class getCommonPropertyType(ELContext context, Object base) {
if (base == null) {
return String.class;
}
return null;
}
private static class ScopeManager {
private static final String MNGR_KEY = ScopeManager.class.getName();
private final PageContext page;
private Map applicationScope;
private Map cookie;
private Map header;
private Map headerValues;
private Map initParam;
private Map pageScope;
private Map param;
private Map paramValues;
private Map requestScope;
private Map sessionScope;
ScopeManager(PageContext page) {
this.page = page;
}
public static ScopeManager get(PageContext page) {
ScopeManager mngr = (ScopeManager) page.getAttribute(MNGR_KEY);
if (mngr == null) {
mngr = new ScopeManager(page);
page.setAttribute(MNGR_KEY, mngr);
}
return mngr;
}
public Map getApplicationScope() {
if (this.applicationScope == null) {
this.applicationScope = new ScopeMap