[ 
https://issues.apache.org/jira/browse/TIKA-1508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15187816#comment-15187816
 ] 

Tim Allison commented on TIKA-1508:
-----------------------------------

sketch of ParamValue...

{code}
public class ParamValue {

    enum Type {
        BOOLEAN,
        INTEGER,
        LONG,
        FLOAT,
        DOUBLE,
        STRING
    }

    final Type type;
    final String val;
    
    public ParamValue(int intVal) {
        this.type = Type.INTEGER;
        this.val = Integer.toString(intVal); 
    }
    
    //...
    
    public ParamValue(Type type, String value) {
        this.type = type;
        this.val = value;
    }

    public boolean getBoolean() {
        if (! type.equals(Type.BOOLEAN)) {
            throw new IllegalArgumentException("can't cast a "+type+ " to a 
boolean");
        }
        if ("true".equals(val)) {
            return true;
        } else if ("false".equals(val)) {
            return false;
        }
        throw new IllegalArgumentException("Couldn't parse "+ val + " as a 
boolean; must be 'true' or 'false'");
    }
{code}

> Add uniformity to parser parameter configuration
> ------------------------------------------------
>
>                 Key: TIKA-1508
>                 URL: https://issues.apache.org/jira/browse/TIKA-1508
>             Project: Tika
>          Issue Type: Improvement
>            Reporter: Tim Allison
>             Fix For: 1.13
>
>
> We can currently configure parsers by the following means:
> 1) programmatically by direct calls to the parsers or their config objects
> 2) sending in a config object through the ParseContext
> 3) modifying .properties files for specific parsers (e.g. PDFParser)
> Rather than scattering the landscape with .properties files for each parser, 
> it would be great if we could specify parser parameters in the main config 
> file, something along the lines of this:
> {noformat}
>     <parser class="org.apache.tika.parser.audio.AudioParser">
>       <params>
>         <int name="someparam1">2</int>
>         <str name="someOtherParam2">something or other</str>
>       </params>
>       <mime>audio/basic</mime>
>       <mime>audio/x-aiff</mime>
>       <mime>audio/x-wav</mime>
>     </parser>
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to