public class RequestImpl extends javax.servlet.http.HttpServletRequestWrapper implements StaplerRequest
StaplerRequest implementation.| Modifier and Type | Field and Description |
|---|---|
List<org.kohsuke.stapler.AncestorImpl> |
ancestors
Ancesotr nodes traversed so far.
|
Stapler |
stapler |
TokenList |
tokens
Tokenized URLs and consumed tokens.
|
| Constructor and Description |
|---|
RequestImpl(Stapler stapler,
javax.servlet.http.HttpServletRequest request,
List<org.kohsuke.stapler.AncestorImpl> ancestors,
TokenList tokens) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
bindJSON(Class<T> type,
net.sf.json.JSONObject src)
Data-bind from a
JSONObject to the given target type,
by using introspection or constructor parameters injection. |
void |
bindJSON(Object bean,
net.sf.json.JSONObject src)
Data-binds from
JSONObject to the given object. |
Object |
bindJSON(Type type,
Class erasure,
Object json)
|
<T> List<T> |
bindJSONToList(Class<T> type,
Object src)
Data-bind from either
JSONObject or JSONArray to a list,
by using StaplerRequest.bindJSON(Class, JSONObject) as the lower-level mechanism. |
<T> T |
bindParameters(Class<T> type,
String prefix)
Instantiates a new object by injecting constructor parameters from the form parameters.
|
<T> T |
bindParameters(Class<T> type,
String prefix,
int index)
Works like
StaplerRequest.bindParameters(Class, String) but uses n-th value
of all the parameters. |
void |
bindParameters(Object bean)
Binds form parameters to a bean by using introspection.
|
void |
bindParameters(Object bean,
String prefix)
Binds form parameters to a bean by using introspection.
|
<T> List<T> |
bindParametersToList(Class<T> type,
String prefix)
Binds collection form parameters to beans by using introspection or
constructor parameters injection.
|
boolean |
checkIfModified(Calendar timestampOfResource,
StaplerResponse rsp) |
boolean |
checkIfModified(Date timestampOfResource,
StaplerResponse rsp) |
boolean |
checkIfModified(long lastModified,
StaplerResponse rsp)
Checks "If-Modified-Since" header and returns false
if the resource needs to be served.
|
boolean |
checkIfModified(long lastModified,
StaplerResponse rsp,
long expiration) |
String |
createJavaScriptProxy(Object toBeExported)
Exports the given Java object as a JavaScript proxy and returns a JavaScript expression to create
a proxy on the client side.
|
Ancestor |
findAncestor(Class type)
Finds the nearest ancestor that has the object of the given type, or null if not found.
|
Ancestor |
findAncestor(Object anc)
Finds the nearest ancestor whose
Ancestor.getObject() matches the given object. |
<T> T |
findAncestorObject(Class<T> type)
Short for
findAncestor(type).getObject(), with proper handling for null de-reference. |
List<Ancestor> |
getAncestors()
Returns a list of ancestor objects that lead to the "it" object.
|
BindInterceptor |
getBindInterceptor()
Gets the
BindInterceptor set for this request. |
BoundObjectTable |
getBoundObjectTable()
Short cut for obtaining
BoundObjectTable associated with this webapp. |
org.apache.commons.fileupload.FileItem |
getFileItem(String name)
Obtains a commons-fileupload object that represents an uploaded file.
|
String |
getOriginalRequestURI()
Gets the
request URI
of the original request, so that you can access the value even from
JSP. |
String |
getOriginalRestOfPath()
Returns the same thing as
StaplerRequest.getRestOfPath() but in the pre-decoded form,
so all "%HH"s as present in the request URL is intact. |
String |
getReferer()
Gets the referer header (like "http://foobar.com/zot") or null.
|
String |
getRequestURIWithQueryString()
HttpServletRequest.getRequestURI() plus additional query string part, if it exists. |
StringBuffer |
getRequestURLWithQueryString()
HttpServletRequest.getRequestURL() plus additional query string part, if it exists. |
String |
getRestOfPath()
Returns the additional URL portion that wasn't used by the stapler,
excluding the query string.
|
String |
getRootPath()
Gets the part of the request URL from protocol up to the context path.
|
javax.servlet.ServletContext |
getServletContext()
Returns the
ServletContext object given to the stapler
dispatcher servlet. |
Stapler |
getStapler()
Gets the
Stapler instance that this belongs to. |
net.sf.json.JSONObject |
getSubmittedForm()
Gets the content of the structured form submission.
|
javax.servlet.RequestDispatcher |
getView(Class clazz,
String viewName)
Convenience method to call
StaplerRequest.getView(Klass, String) with Class. |
javax.servlet.RequestDispatcher |
getView(Klass<?> clazz,
Object it,
String viewName) |
javax.servlet.RequestDispatcher |
getView(Klass<?> clazz,
String viewName)
Gets the
RequestDispatcher that represents a specific view
for the given class. |
javax.servlet.RequestDispatcher |
getView(Object it,
String viewName)
Gets the
RequestDispatcher that represents a specific view
for the given object. |
WebApp |
getWebApp()
Short for
getStapler().getWebApp() |
boolean |
hasParameter(String name)
Short for
getParameter(name)!=null |
boolean |
isJavaScriptProxyCall()
Returns true if this request represents a server method call to a JavaScript proxy object.
|
BindInterceptor |
setBindInterceptpr(BindInterceptor bindListener) |
BindInterceptor |
setBindListener(BindInterceptor bindListener) |
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRolegetAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequestclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRolegetAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncodingpublic final TokenList tokens
Stapler as we parse through the URL.public final List<org.kohsuke.stapler.AncestorImpl> ancestors
Stapler as we parse through the URL.public final Stapler stapler
public boolean isJavaScriptProxyCall()
StaplerRequestisJavaScriptProxyCall in interface StaplerRequestpublic BoundObjectTable getBoundObjectTable()
StaplerRequestBoundObjectTable associated with this webapp.getBoundObjectTable in interface StaplerRequestpublic String createJavaScriptProxy(Object toBeExported)
StaplerRequestgetBoundObjectTable().bind(toBeExported).getProxyScript()createJavaScriptProxy in interface StaplerRequestpublic Stapler getStapler()
StaplerRequestStapler instance that this belongs to.getStapler in interface StaplerRequestpublic WebApp getWebApp()
StaplerRequestgetStapler().getWebApp()getWebApp in interface StaplerRequestpublic String getRestOfPath()
StaplerRequestFor example, if the requested URL is "foo/bar/zot/abc?def=ghi" and "foo/bar" portion matched bar.jsp, this method returns "/zot/abc".
If this method is invoked from getters or StaplerProxy.getTarget()
during the object traversal, this method returns the path portion
that is not yet processed.
getRestOfPath in interface StaplerRequestpublic String getOriginalRestOfPath()
StaplerRequestStaplerRequest.getRestOfPath() but in the pre-decoded form,
so all "%HH"s as present in the request URL is intact.getOriginalRestOfPath in interface StaplerRequestpublic javax.servlet.ServletContext getServletContext()
StaplerRequestServletContext object given to the stapler
dispatcher servlet.getServletContext in interface StaplerRequestpublic String getRequestURIWithQueryString()
StaplerRequestHttpServletRequest.getRequestURI() plus additional query string part, if it exists.getRequestURIWithQueryString in interface StaplerRequestpublic StringBuffer getRequestURLWithQueryString()
StaplerRequestHttpServletRequest.getRequestURL() plus additional query string part, if it exists.getRequestURLWithQueryString in interface StaplerRequestpublic javax.servlet.RequestDispatcher getView(Object it, String viewName) throws IOException
StaplerRequestRequestDispatcher that represents a specific view
for the given object.
This support both JSP and Jelly.getView in interface StaplerRequestviewName - If this name is relative name like "foo.jsp" or "bar/zot.jelly",
then the corresponding "side file" is searched by this name.
For Jelly, this also accepts absolute path name that starts with '/', such as "/foo/bar/zot.jelly". In this case, it.getClass().getClassLoader() is searched for this script.
IOExceptionpublic javax.servlet.RequestDispatcher getView(Class clazz, String viewName) throws IOException
StaplerRequestStaplerRequest.getView(Klass, String) with Class.getView in interface StaplerRequestIOExceptionpublic javax.servlet.RequestDispatcher getView(Klass<?> clazz, String viewName) throws IOException
StaplerRequestRequestDispatcher that represents a specific view
for the given class.
Unlike StaplerRequest.getView(Object, String), calling this request dispatcher
doesn't set the "it" variable, so
getView(it.getClass(),viewName) and getView(it,viewName)
aren't the same thing.
getView in interface StaplerRequestIOExceptionpublic javax.servlet.RequestDispatcher getView(Klass<?> clazz, Object it, String viewName) throws IOException
IOExceptionpublic String getRootPath()
StaplerRequestgetRootPath in interface StaplerRequestpublic String getReferer()
StaplerRequestgetReferer in interface StaplerRequestpublic List<Ancestor> getAncestors()
StaplerRequestAncestor objects sorted in the
order from root to the "it" object.
For example, if the URL was "foo/bar/zot" and the "it" object
was determined as root.getFoo().getBar("zot"),
then this list will contain the following 3 objects in this order:
getAncestors in interface StaplerRequestAncestors. Can be empty, but always non-null.public Ancestor findAncestor(Class type)
StaplerRequestfindAncestor in interface StaplerRequestpublic <T> T findAncestorObject(Class<T> type)
StaplerRequestfindAncestor(type).getObject(), with proper handling for null de-reference.
This version is also type safe.findAncestorObject in interface StaplerRequestpublic Ancestor findAncestor(Object anc)
StaplerRequestAncestor.getObject() matches the given object.findAncestor in interface StaplerRequestpublic boolean hasParameter(String name)
StaplerRequestgetParameter(name)!=nullhasParameter in interface StaplerRequestpublic String getOriginalRequestURI()
StaplerRequestrequest URI
of the original request, so that you can access the value even from
JSP.getOriginalRequestURI in interface StaplerRequestpublic boolean checkIfModified(long lastModified,
StaplerResponse rsp)
StaplerRequestThis method can behave in three ways.
HttpServletResponse.SC_NOT_MODIFIED as the response code
and returns true.
This method sends out the "Expires" header to force browser to re-validate all the time.
checkIfModified in interface StaplerRequestlastModified - The time stamp of the resource.rsp - This object is updated accordingly to simplify processing.HttpServletResponse.SC_NOT_MODIFIED.public boolean checkIfModified(long lastModified,
StaplerResponse rsp,
long expiration)
checkIfModified in interface StaplerRequestexpiration - The number of milliseconds until the resource will "expire".
Until it expires the browser will be allowed to cache it
and serve it without checking back with the server.
After it expires, the client will send conditional GET to
check if the resource is actually modified or not.
If 0, it will immediately expire.StaplerRequest.checkIfModified(long, StaplerResponse)public boolean checkIfModified(Date timestampOfResource, StaplerResponse rsp)
checkIfModified in interface StaplerRequestStaplerRequest.checkIfModified(long, StaplerResponse)public boolean checkIfModified(Calendar timestampOfResource, StaplerResponse rsp)
checkIfModified in interface StaplerRequestStaplerRequest.checkIfModified(long, StaplerResponse)public BindInterceptor getBindInterceptor()
StaplerRequestBindInterceptor set for this request.getBindInterceptor in interface StaplerRequestWebApp.bindInterceptorspublic BindInterceptor setBindListener(BindInterceptor bindListener)
setBindListener in interface StaplerRequestpublic BindInterceptor setBindInterceptpr(BindInterceptor bindListener)
setBindInterceptpr in interface StaplerRequestpublic void bindParameters(Object bean)
StaplerRequest
Values are converted into the right type. See ConvertUtils.convert(String, Class).
bindParameters in interface StaplerRequestbean - The object which will be filled out.BeanUtils.setProperty(Object, String, Object)public void bindParameters(Object bean, String prefix)
StaplerRequestStaplerRequest.bindParameters(Object), but it performs a
pre-processing on property names. Namely, only property names that start
with the given prefix will be used for binding, and only the portion of the
property name after the prefix is used.
So for example, if the prefix is "foo.", then property name "foo.bar" with value
"zot" will invoke bean.setBar("zot").bindParameters in interface StaplerRequestpublic <T> List<T> bindParametersToList(Class<T> type, String prefix)
StaplerRequest
This method works like StaplerRequest.bindParameters(Object,String) and
StaplerRequest.bindParameters(Class, String), but it assumes
that form parameters have multiple-values, and use individual values to
fill in multiple beans.
For example, if getParameterValues("foo")=={"abc","def"} and getParameterValues("bar")=={"5","3"}, then this method will return two objects (the first with "abc" and "5", the second with "def" and "3".)
bindParametersToList in interface StaplerRequesttype - Type of the bean to be created. This class must have the default no-arg
constructor.prefix - See StaplerRequest.bindParameters(Object, String) for details.public <T> T bindParameters(Class<T> type, String prefix)
StaplerRequestThe given class must have a constructor annotated with '@stapler-constructor', and must be processed by the maven-stapler-plugin, so that the parameter names of the constructor is available at runtime.
The prefix is used to control the form parameter name. For example,
if the prefix is "foo." and if the constructor is define as
Foo(String a, String b), then the constructor will be invoked
as new Foo(getParameter("foo.a"),getParameter("foo.b")).
bindParameters in interface StaplerRequestpublic <T> T bindParameters(Class<T> type, String prefix, int index)
StaplerRequestStaplerRequest.bindParameters(Class, String) but uses n-th value
of all the parameters.
This is useful for creating multiple instances from repeated form fields.
bindParameters in interface StaplerRequestpublic <T> T bindJSON(Class<T> type, net.sf.json.JSONObject src)
StaplerRequestJSONObject to the given target type,
by using introspection or constructor parameters injection.
For example, if you have a constructor that looks like the following:
class Foo {
@DataBoundConstructor
public Foo(Integer x, String y, boolean z, Bar bar) { ... }
}
class Bar {
@DataBoundConstructor
public Bar(int x, int y) {}
}
... and if JSONObject looks like
{ y:"text", z:true, bar:{x:1,y:2}}
then, this method returns
new Foo(null,"text",true,new Bar(1,2))
In the above example, a new instance of Bar was created, but you can also create a subtype of Bar by having the 'stapler-class' property in JSON like this:
class BarEx extends Bar {
@DataBoundConstructor
public BarEx(int a, int b, int c) {}
}
{ y:"text", z:true, bar: { stapler-class:"p.k.g.BarEx", a:1, b:2, c:3 } }
The type that shows up in the constructor (Bar in this case) can be an interface or an abstract class.
bindJSON in interface StaplerRequestpublic Object bindJSON(Type type, Class erasure, Object json)
StaplerRequestJSONObject, JSONArray,
String, Integer, and so on) to the expected type given as an argument.bindJSON in interface StaplerRequesttype - The generic type of the 'erasure' parameter.erasure - The expected type to convert the JSON argument to.json - One of the JSON value type.public void bindJSON(Object bean, net.sf.json.JSONObject src)
StaplerRequestJSONObject to the given object.
This method is bit like StaplerRequest.bindJSON(Class, JSONObject), except that this method
populates an existing object, instead of creating a new instance.
This method is also bit like StaplerRequest.bindParameters(Object, String), in that it
populates an existing object from a form submission, except that this method
obtains data from JSONObject thus more structured, whereas StaplerRequest.bindParameters(Object, String)
uses the map structure of the form submission.
bindJSON in interface StaplerRequestpublic <T> List<T> bindJSONToList(Class<T> type, Object src)
StaplerRequestJSONObject or JSONArray to a list,
by using StaplerRequest.bindJSON(Class, JSONObject) as the lower-level mechanism.
If the source is JSONObject, the returned list will contain
a single item. If it is JSONArray, each item will be bound.
If it is null, then the list will be empty.
bindJSONToList in interface StaplerRequestpublic net.sf.json.JSONObject getSubmittedForm()
throws javax.servlet.ServletException
StaplerRequestgetSubmittedForm in interface StaplerRequestjavax.servlet.ServletExceptionpublic org.apache.commons.fileupload.FileItem getFileItem(String name) throws javax.servlet.ServletException, IOException
StaplerRequestgetFileItem in interface StaplerRequestjavax.servlet.ServletExceptionIOExceptionCopyright © 2014. All rights reserved.