org.apache.fulcrum.parser
Class DefaultParserService

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by 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 efault implementation of a ParserService.

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, PARAMETER_ENCODING_DEFAULT, PARAMETER_ENCODING_KEY, ROLE, URL_CASE_FOLDING_KEY, URL_CASE_FOLDING_LOWER, URL_CASE_FOLDING_LOWER_VALUE, URL_CASE_FOLDING_NONE, URL_CASE_FOLDING_NONE_VALUE, URL_CASE_FOLDING_UNSET, URL_CASE_FOLDING_UPPER, URL_CASE_FOLDING_UPPER_VALUE
 
Constructor Summary
DefaultParserService()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Avalon component lifecycle method
 String convert(String value)
          Trims the string data and applies the conversion specified in the property given by URL_CASE_FOLDING.
 String convertAndTrim(String value)
          Convert a String value according to the url-case-folding property.
 String convertAndTrim(String value, int 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.
 boolean getAutomaticUpload()
          Gets the automaticUpload value from the configuration
 String getParameterEncoding()
          Get the character encoding that will be used by this ValueParser.
 ValueParser getParser(Class ppClass)
          Get a ValueParser instance from the service.
 int getUrlFolding()
          Gets the folding value from the configuration
 List parseUpload(javax.servlet.http.HttpServletRequest request)
          Use the UploadService if available to parse the given request for uploaded files
 void putParser(ValueParser parser)
          Return a used Parser to the service.
 void service(org.apache.avalon.framework.service.ServiceManager manager)
          Avalon component lifecycle method
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultParserService

public DefaultParserService()
Method Detail

getParameterEncoding

public String getParameterEncoding()
Get the character encoding that will be used by this ValueParser.

Specified by:
getParameterEncoding in interface ParserService

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:
convert in interface ParserService
Parameters:
value - A String to be processed.
Returns:
A new String converted to lowercase and trimmed.

convertAndTrim

public String convertAndTrim(String value)
Convert a String value according to the url-case-folding property.

Specified by:
convertAndTrim in interface ParserService
Parameters:
value - the String to convert
Returns:
a new String.

convertAndTrim

public String convertAndTrim(String value,
                             int 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:
convertAndTrim in interface ParserService
Parameters:
value - A String to be processed.
fold - The parameter folding to be applied (see ParserService)
Returns:
A new String converted to lowercase and trimmed.

getUrlFolding

public int getUrlFolding()
Gets the folding value from the configuration

Specified by:
getUrlFolding in interface ParserService
Returns:
The current Folding Value

getAutomaticUpload

public boolean getAutomaticUpload()
Gets the automaticUpload value from the configuration

Specified by:
getAutomaticUpload in interface ParserService
Returns:
The current automaticUpload Value

parseUpload

public List parseUpload(javax.servlet.http.HttpServletRequest request)
                 throws org.apache.avalon.framework.service.ServiceException
Use the UploadService if available to parse the given request for uploaded files

Specified by:
parseUpload in interface ParserService
Returns:
A list of org.apache.commons.upload.FileItems
Throws:
org.apache.avalon.framework.service.ServiceException - if parsing fails or the UploadService is not available

getParser

public ValueParser getParser(Class ppClass)
                      throws InstantiationException
Get a ValueParser instance from the service. Use the given Class to create the object.

Specified by:
getParser in interface ParserService
Returns:
An object that implements ValueParser
Throws:
InstantiationException - if the instance could not be created

putParser

public void putParser(ValueParser parser)
Return a used Parser to the service. This allows for pooling and recycling

Specified by:
putParser in interface ParserService
Parameters:
parser -

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Avalon component lifecycle method

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

service

public void service(org.apache.avalon.framework.service.ServiceManager manager)
             throws org.apache.avalon.framework.service.ServiceException
Avalon component lifecycle method

Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException


Copyright © 2005-2009 The Apache Software Foundation. All Rights Reserved.