QueryStringELResolver.java
3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.el.ELContext
* javax.el.ELResolver
* javax.el.PropertyNotWritableException
* javax.servlet.jsp.JspContext
* javax.servlet.jsp.PageContext
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.scripting.jsp.util.TagUtil
*/
package com.adobe.granite.ui.components.impl;
import java.beans.FeatureDescriptor;
import java.util.ArrayList;
import java.util.Iterator;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.PropertyNotWritableException;
import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.PageContext;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.scripting.jsp.util.TagUtil;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class QueryStringELResolver
extends ELResolver {
public Object getValue(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException();
}
if (base != null) {
return null;
}
PageContext pageContext = (PageContext)context.getContext(JspContext.class);
if ("querystring".equals(property)) {
SlingHttpServletRequest req = TagUtil.getRequest((PageContext)pageContext);
context.setPropertyResolved(true);
return req.getQueryString();
}
return null;
}
public Class<?> getType(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException();
}
if (base == null && "querystring".equals(property)) {
context.setPropertyResolved(true);
}
return null;
}
public void setValue(ELContext context, Object base, Object property, Object val) {
if (context == null) {
throw new NullPointerException();
}
if (base == null && "querystring".equals(property)) {
throw new PropertyNotWritableException();
}
}
public boolean isReadOnly(ELContext context, Object base, Object property) {
if (context == null) {
throw new NullPointerException();
}
if (base == null && "querystring".equals(property)) {
context.setPropertyResolved(true);
return true;
}
return false;
}
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
ArrayList<FeatureDescriptor> list = new ArrayList<FeatureDescriptor>(1);
FeatureDescriptor descriptor = new FeatureDescriptor();
descriptor.setName("querystring");
descriptor.setDisplayName("querystring");
descriptor.setShortDescription("A variable exposing the query string of current request");
descriptor.setExpert(false);
descriptor.setHidden(false);
descriptor.setPreferred(true);
descriptor.setValue("type", String.class);
descriptor.setValue("resolvableAtDesignTime", Boolean.TRUE);
list.add(descriptor);
return list.iterator();
}
public Class<?> getCommonPropertyType(ELContext context, Object base) {
if (base == null) {
return String.class;
}
return null;
}
}