Package org.apache.fulcrum.parser
Class DefaultParserService
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.fulcrum.parser.DefaultParserService
-
- All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable,org.apache.avalon.framework.logger.LogEnabled,org.apache.avalon.framework.service.Serviceable,ParserService
public class DefaultParserService extends org.apache.avalon.framework.logger.AbstractLogEnabled implements ParserService, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.service.Serviceable
The DefaultParserService provides the default implementation of aParserService.- Version:
- $Id: BaseValueParser.java 542062 2007-05-28 00:29:43Z seade $
- Author:
- Thomas Vandahl
-
-
Field Summary
-
Fields inherited from interface org.apache.fulcrum.parser.ParserService
AUTOMATIC_DEFAULT, AUTOMATIC_KEY, DEFAULT_MAX_IDLE, DEFAULT_POOL_CAPACITY, FULCRUM_POOL_DEFAULT, FULCRUM_POOL_KEY, PARAMETER_ENCODING_DEFAULT, PARAMETER_ENCODING_KEY, POOL_KEY, ROLE, URL_CASE_FOLDING_KEY
-
-
Constructor Summary
Constructors Constructor Description DefaultParserService()DefaultParserService(org.apache.commons.pool2.impl.GenericObjectPoolConfig<?> config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(org.apache.avalon.framework.configuration.Configuration conf)Avalon component lifecycle methodStringconvert(String value)Trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING.StringconvertAndTrim(String value)Convert a String value according to the url-case-folding property.StringconvertAndTrim(String value, ValueParser.URLCaseFolding fold)A static version of the convert method, which trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING.booleangetAutomaticUpload()Gets the automaticUpload value from the configurationStringgetParameterEncoding()Get the character encoding that will be used by this ValueParser.<P extends ValueParser>
PgetParser(Class<P> ppClass)Get aValueParserinstance from the service.ValueParser.URLCaseFoldinggetUrlFolding()Gets the folding value from the configurationList<Part>parseUpload(HttpServletRequest request)Parse the given request for uploaded filesvoidputParser(ValueParser parser)Clears the parse and puts it back into the pool service.voidservice(org.apache.avalon.framework.service.ServiceManager manager)Avalon component lifecycle methodvoidsetParameterEncoding(String encoding)Set the character encoding that will be used by this ValueParser.
-
-
-
Constructor Detail
-
DefaultParserService
public DefaultParserService()
-
DefaultParserService
public DefaultParserService(org.apache.commons.pool2.impl.GenericObjectPoolConfig<?> config)
-
-
Method Detail
-
getParameterEncoding
public String getParameterEncoding()
Get the character encoding that will be used by this ValueParser.- Specified by:
getParameterEncodingin interfaceParserService- Returns:
- A String for the parameter encoding
-
setParameterEncoding
public void setParameterEncoding(String encoding)
Set the character encoding that will be used by this ValueParser.
-
convert
public String convert(String value)
Trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING. It returns a new string so that it does not destroy the value data.- Specified by:
convertin interfaceParserService- Parameters:
value- A String to be processed.- Returns:
- A new String converted to the case as specified by URL_CASE_FOLDING and trimmed.
-
convertAndTrim
public String convertAndTrim(String value)
Convert a String value according to the url-case-folding property.- Specified by:
convertAndTrimin interfaceParserService- Parameters:
value- the String to convert- Returns:
- a new String.
-
convertAndTrim
public String convertAndTrim(String value, ValueParser.URLCaseFolding fold)
A static version of the convert method, which trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING. It returns a new string so that it does not destroy the value data.- Specified by:
convertAndTrimin interfaceParserService- Parameters:
value- A String to be processed.fold- The parameter folding to be applied (seeParserService)- Returns:
- A new String converted to lowercase and trimmed.
-
getUrlFolding
public ValueParser.URLCaseFolding getUrlFolding()
Gets the folding value from the configuration- Specified by:
getUrlFoldingin interfaceParserService- Returns:
- The current Folding Value
-
getAutomaticUpload
public boolean getAutomaticUpload()
Gets the automaticUpload value from the configuration- Specified by:
getAutomaticUploadin interfaceParserService- Returns:
- The current automaticUpload Value
-
parseUpload
public List<Part> parseUpload(HttpServletRequest request) throws org.apache.avalon.framework.service.ServiceException
Parse the given request for uploaded files- Specified by:
parseUploadin interfaceParserService- Parameters:
request- the HttpServletRequest object- Returns:
- A list of
Parts - Throws:
org.apache.avalon.framework.service.ServiceException- if parsing fails
-
getParser
public <P extends ValueParser> P getParser(Class<P> ppClass) throws InstantiationException
Get aValueParserinstance from the service. Use the given Class to create the object.- Specified by:
getParserin interfaceParserService- Type Parameters:
P- The ValueParser we are using- Parameters:
ppClass- parameter parser class- Returns:
- An object that implements ValueParser
- Throws:
InstantiationException- if the instance could not be created
-
putParser
public void putParser(ValueParser parser)
Clears the parse and puts it back into the pool service. This allows for pooling and recycling As we are not yet using org.apache.fulcrum.pool.Recyclable, we call instedaValueParser.dispose().- Specified by:
putParserin interfaceParserService- Parameters:
parser- The value parser to use
-
configure
public void configure(org.apache.avalon.framework.configuration.Configuration conf) throws org.apache.avalon.framework.configuration.ConfigurationException
Avalon component lifecycle method- Specified by:
configurein interfaceorg.apache.avalon.framework.configuration.Configurable- Parameters:
conf- the configuration- Throws:
org.apache.avalon.framework.configuration.ConfigurationException- Generic exception
-
service
public void service(org.apache.avalon.framework.service.ServiceManager manager) throws org.apache.avalon.framework.service.ServiceException
Avalon component lifecycle method- Specified by:
servicein interfaceorg.apache.avalon.framework.service.Serviceable- Parameters:
manager- The service manager instance- Throws:
org.apache.avalon.framework.service.ServiceException- generic exception
-
-