org.milyn.cdr
Class TokenizedStringParameterDecoder

java.lang.Object
  extended by org.milyn.cdr.ParameterDecoder
      extended by org.milyn.cdr.TokenizedStringParameterDecoder
All Implemented Interfaces:
ContentHandler

public class TokenizedStringParameterDecoder
extends ParameterDecoder

ParameterDecoder used to tokenize a parameter values into a List or HashSet.

Tokenizes parameter values into a List (param-type="string-list") or HashSet (param-type="string-hashset") using StringTokenizer.

Two default configurations of this decoder are pre-installed for all profiles. They're named "string-list" and "string-hashset".

Example Usage

The following example illustrates use of the pre-installed "string-hashset" decoder:

Configuration:

 <resource-config target-profile="html4" selector="XXX">
      <resource>com.acme.XXXContentDeliveryUnit</resource>
      <param name="blockLevelElements" type="string-hashset">
          p,h1,h2,h3,h4,h5,h6,div,ul,ol,dl,menu,dir,pre,hr,blockquote,address,center,noframes,isindex,fieldset,table
      </param>
 </resource-config>

Usage:
... and "com.acme.XXXContentDeliveryUnit" accesses this parameter value as follows:

 Parameter param = resourceConfig.getParameter("blockLevelElements");
 HashSet blockLevelElements = (HashSet)param.getValue(ContentDeliveryConfig); 
 

Note, we will make this filter easier in the next release. You'll be able to call a method such as "getDecodedParameter" on the SmooksResourceConfiguration, returning a decoded parameter Object. See SmooksResourceConfiguration.

Author:
tfennelly

Constructor Summary
TokenizedStringParameterDecoder()
           
 
Method Summary
 Object decodeValue(String value)
          Decodes the value based on the smooks-resource configuration passed in the constructor.
 void setConfiguration(SmooksResourceConfiguration resourceConfig)
          Public constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenizedStringParameterDecoder

public TokenizedStringParameterDecoder()
Method Detail

setConfiguration

public void setConfiguration(SmooksResourceConfiguration resourceConfig)
Public constructor.

Parameters:
resourceConfig - Configuration.

decodeValue

public Object decodeValue(String value)
                   throws ParameterDecodeException
Decodes the value based on the smooks-resource configuration passed in the constructor.

Specified by:
decodeValue in class ParameterDecoder
Parameters:
value - The value to be decoded.
Returns:
The decode value Object.
Throws:
ParameterDecodeException - Unable to decode parameter value.


Copyright © 2008. All Rights Reserved.