public class DefaultParameterParser extends BaseValueParser implements ParameterParser
NOTE: The name= portion of a name=value pair may be converted to lowercase or uppercase when the object is initialized and when new data is added. This behaviour is determined by the url.case.folding property in TurbineResources.properties. Adding a name/value pair may overwrite existing name=value pairs if the names match:
ParameterParser pp = data.getParameters(); pp.add("ERROR",1); pp.add("eRrOr",2); int result = pp.getInt("ERROR");In the above example, result is 2.
ValueParser.URLCaseFolding
parameters, parserService
DEFAULT_CHARACTER_ENCODING
Constructor and Description |
---|
DefaultParameterParser()
Create a new empty instance of ParameterParser.
|
DefaultParameterParser(String characterEncoding)
Create a new empty instance of ParameterParser.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String name,
Part value)
Add a Part object as a parameters.
|
void |
dispose()
Disposes the parser.
|
String |
getFileName(Part part)
Convenience fileName utility, which extracts the filename from header
|
Part |
getPart(String name)
Return a Part object for the given name.
|
Collection<Part> |
getParts()
Return an array of all Part objects.
|
Part[] |
getParts(String name)
Return an array of Part objects for the given name.
|
HttpServletRequest |
getRequest()
Gets the parsed servlet request.
|
byte[] |
getUploadData()
Gets the uploadData byte[]
|
protected void |
handleEncoding(HttpServletRequest request) |
void |
setRequest(HttpServletRequest request)
Sets the servlet request to the parser.
|
void |
setUploadData(byte[] uploadData)
Sets the uploadData byte[]
|
add, add, add, add, add, add, clear, containsKey, convert, convertAndTrim, convertAndTrim, enableLogging, get, getBigDecimal, getBigDecimal, getBigDecimals, getBoolean, getBoolean, getBooleanObject, getBooleanObject, getBooleanObjects, getBooleans, getByte, getByte, getByteObject, getByteObject, getBytes, getCharacterEncoding, getDate, getDate, getDate, getDateFormat, getDouble, getDouble, getDoubleObject, getDoubleObject, getDoubleObjects, getDoubles, getFloat, getFloat, getFloatObject, getFloatObject, getFloatObjects, getFloats, getInt, getInt, getIntObject, getIntObject, getIntObjects, getInts, getKeys, getLocale, getLogger, getLong, getLong, getLongObject, getLongObject, getLongObjects, getLongs, getNumberFormat, getObject, getObjects, getParam, getString, getString, getStrings, getStrings, getToStringParam, getUrlFolding, isDisposed, isValid, iterator, keySet, putParam, recycle, recycle, remove, setCharacterEncoding, setDateFormat, setLocale, setNumberFormat, setParserService, setProperties, setProperty, setString, setStrings, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, add, add, add, add, add, clear, containsKey, convert, convertAndTrim, convertAndTrim, get, getBigDecimal, getBigDecimal, getBigDecimals, getBoolean, getBoolean, getBooleanObject, getBooleanObject, getBooleanObjects, getBooleans, getByte, getByte, getByteObject, getByteObject, getBytes, getCharacterEncoding, getDate, getDate, getDate, getDateFormat, getDouble, getDouble, getDoubleObject, getDoubleObject, getDoubleObjects, getDoubles, getFloat, getFloat, getFloatObject, getFloatObject, getFloatObjects, getFloats, getInt, getInt, getIntObject, getIntObject, getIntObjects, getInts, getKeys, getLocale, getLong, getLong, getLongObject, getLongObject, getLongObjects, getLongs, getNumberFormat, getObject, getObjects, getString, getString, getStrings, getStrings, getUrlFolding, keySet, remove, setCharacterEncoding, setDateFormat, setLocale, setNumberFormat, setProperties, setString, setStrings, toString
forEach, iterator, spliterator
public DefaultParameterParser()
To add name/value pairs to this set of parameters, use the
add()
methods.
public DefaultParameterParser(String characterEncoding)
To add name/value pairs to this set of parameters, use the
add()
methods.
characterEncoding
- The character encoding of strings.public void dispose()
dispose
in interface ValueParser
dispose
in class BaseValueParser
public HttpServletRequest getRequest()
getRequest
in interface ParameterParser
public void setRequest(HttpServletRequest request)
Sets the request character encoding to the parser.
Sets the request encoding, if it is not set and ParserService.getParameterEncoding()
is set to a non-default value ParserService.PARAMETER_ENCODING_DEFAULT
(if ServletRequest.getCharacterEncoding()
returns null,
it has the default set to ISO-8859-1, cft. Servlet 2.4, 2.5, 3.0, 3.1 Specs).
This will only succeed, if no data was read yet, cft. spec.
To add name/value pairs to this set of parameters, use the
add()
methods.
setRequest
in interface ParameterParser
request
- An HttpServletRequest.protected void handleEncoding(HttpServletRequest request)
public void setUploadData(byte[] uploadData)
setUploadData
in interface ParameterParser
uploadData
- A byte[] with data.public byte[] getUploadData()
getUploadData
in interface ParameterParser
public void add(String name, Part value)
add
in interface ParameterParser
name
- A String with the name.value
- A Part with the value.public Part getPart(String name)
ParameterParser
getPart
in interface ParameterParser
name
- A String with the name.Return a Part object for the given name. If the name does
not exist or the object stored is not a Part, return null.
public Part[] getParts(String name)
ParameterParser
getParts
in interface ParameterParser
name
- A String with the name.Return an array of Part objects for the given name. If the
name does not exist or the object stored is not a Part
array, return null.
public Collection<Part> getParts()
ParameterParser
getParts
in interface ParameterParser
public String getFileName(Part part)
ParameterParser
getFileName
in interface ParameterParser
part
- The part which represents the uploaded fileCopyright © 2005–2019 The Apache Software Foundation. All rights reserved.