4.5.7. configure

The configure method is called by the framework to provide the configuration data that has been set by the user (see Section 2.7.6, “Rule configuration”). The framework assures that this method is called at least once before the first invocation of the startBatch method. In most cases, this method is used to retrieve the rule arguments, that can be configured for each rule.
In our example, the check_length check shall report if the content exceeds a configurable number of characters. The configurable number of characters shall be provided as a rule argument. The configured rule arguments can be retrieved by calling the getArguments method of the org.docma.plugin.rules.HTMLRuleConfig instance that is passed as argument to the configure method. Therefore, in our example, the implementation could be as follows:
public void configure(HTMLRuleConfig conf)
    try {
        String a = conf.getArguments()[0];
        if (a.toLowerCase().startsWith("maxlength")) {
            maxLength = Integer.parseInt(a.substring(a.indexOf('=') + 1));
    } catch (Exception ex) {} // no argument or invalid number
    maxLength = Integer.MAX_VALUE;  // no or invalid argument
The configured argument has to be a string in the format maxlength=nnn, where nnn has to be a positive decimal number. The configured value is stored in the member field maxLength. This value will be used by the apply method which executes the check_length check (see Section 4.5.10, “apply”).