Overview

This Service functions as a repository for Parser components.

It is written for use in Turbine but it can be used in any container compatible with Avalon's ECM container.

The component uses the following services from the Fulcrum Repository

Configuration

Role Configuration

<role
    name="org.apache.fulcrum.parser.ParserService"
    shorthand="parser"
    default-class="org.apache.fulcrum.parser.DefaultParserService"/>

Component Configuration

Item Datatype Cardinality Description
urlCaseFolding String [0|1] This setting controls how parameter names are to be folded during processing. Valid values are none (no folding), upper (all names upper case) and lower (all names lower case). The default is none.
parameterEncoding String [0|1] The parameter encoding to use when converting strings to bytes or vice versa. This encoding is used when no explicit encoding is specified. This must be a valid encoding string for the JVM in use. The default is iso-8859-1.
automaticUpload boolean [0|1] If set to true, parsing the multipart request for attachments will be performed automatically. Otherwise, the request may be parsed manually by calling parseUpload(HttpServletRequest). The default value is false. When set to true, the component must have the Fulcrum Upload Service available to parse the request.

Component Configuration Example

<parser>
    <urlCaseFolding>lower</urlCaseFolding>
    <parameterEncoding>utf-8</parameterEncoding>
    <automaticUpload>true</automaticUpload>
</parser>

Usage

You get a parser from the service like this:

ValueParser parser;

try
{
    // Get a ValueParser instance
    parser = parserService.getParser(BaseValueParser.class);

    parser.add(...);
    Double d = parser.getDoubleObject(...);
}
finally
{
    // Return the instance to the service
    if (parser != null)
    {
        parserService.putParser(parser);
    }
}

Parsers are pooled inside the service. You can use this service to manage any types of parsers, you just need to provide the class you want to manage. If the parser class implements LogEnabled it will get an (Avalon) logger injected. If the parser class implements ParserServiceSupport it will get an instance of this service injected.