Package org.apache.sling.api.request
Interface RequestParameter
-
@ProviderType public interface RequestParameter
TheRequestParameter
class represents a single parameter sent with the client request. Instances of this class are returned by theSlingHttpServletRequest.getRequestParameter(String)
,SlingHttpServletRequest.getRequestParameters(String)
andSlingHttpServletRequest.getRequestParameterMap()
method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte[]
get()
Returns the contents of the parameter as an array of bytes.@Nullable java.lang.String
getContentType()
Returns the content type passed by the browser ornull
if not defined.@Nullable java.lang.String
getFileName()
Returns the original filename in the client's filesystem, as provided by the browser (or other client software).@Nullable java.io.InputStream
getInputStream()
Returns an InputStream that can be used to retrieve the contents of the file.@NotNull java.lang.String
getName()
long
getSize()
Returns the size in bytes of the parameter.@NotNull java.lang.String
getString()
Returns the contents of the parameter as a String, using the default character encoding.@NotNull java.lang.String
getString(@NotNull java.lang.String encoding)
Returns the contents of the parameter as a String, using the specified encoding.boolean
isFormField()
Determines whether or not this instance represents a simple form field or an uploaded file.
-
-
-
Method Detail
-
getName
@NotNull @NotNull java.lang.String getName()
- Returns:
- the name of this
RequestParameter
- Since:
- 2.4 (Sling API Bundle 2.6)
-
isFormField
boolean isFormField()
Determines whether or not this instance represents a simple form field or an uploaded file.- Returns:
true
if the instance represents a simple form field;false
if it represents an uploaded file.
-
getContentType
@Nullable @Nullable java.lang.String getContentType()
Returns the content type passed by the browser ornull
if not defined.- Returns:
- The content type passed by the browser or
null
if not defined.
-
getSize
long getSize()
Returns the size in bytes of the parameter.- Returns:
- The size in bytes of the parameter.
-
get
byte[] get()
Returns the contents of the parameter as an array of bytes.- Returns:
- The contents of the parameter as an array of bytes.
-
getInputStream
@Nullable @Nullable java.io.InputStream getInputStream() throws java.io.IOException
Returns an InputStream that can be used to retrieve the contents of the file.Each call to this method returns a new
InputStream
to the request parameter data. Make sure to close the stream to prevent leaking resources.- Returns:
- An InputStream that can be used to retrieve the contents of the file.
- Throws:
java.io.IOException
- if an error occurs.
-
getFileName
@Nullable @Nullable java.lang.String getFileName()
Returns the original filename in the client's filesystem, as provided by the browser (or other client software). In most cases, this will be the base file name, without path information. However, some clients, such as the Opera browser, do include path information.- Returns:
- The original filename in the client's filesystem.
-
getString
@NotNull @NotNull java.lang.String getString()
Returns the contents of the parameter as a String, using the default character encoding. This method usesget()
to retrieve the contents of the item.- Returns:
- The contents of the parameter, as a string.
-
getString
@NotNull @NotNull java.lang.String getString(@NotNull @NotNull java.lang.String encoding) throws java.io.UnsupportedEncodingException
Returns the contents of the parameter as a String, using the specified encoding. This method uses linkget()
to retrieve the contents of the item.- Parameters:
encoding
- The character encoding to use.- Returns:
- The contents of the parameter, as a string.
- Throws:
java.io.UnsupportedEncodingException
- if the requested character encoding is not available.
-
-