Package org.jbpm.ui.infopath

Source Code of org.jbpm.ui.infopath.StringLengthExpressionAdapter

package org.jbpm.ui.infopath;

import org.jbpm.ui.util.ValidationUtil;
import org.jbpm.ui.validation.ValidatorConfig;
import org.jbpm.ui.validation.ValidatorDefinition;

public class StringLengthExpressionAdapter implements ExpressionAdapter {

    public ValidatorConfig createConfig(String expr, String errorMessage) throws Exception {
        ValidatorDefinition definition = ValidationUtil.getValidatorDefinition("stringlength");
        ValidatorConfig config = definition.create(errorMessage);

        String argName;
        int index;
        if (expr.indexOf("<") > 0) {
            argName = "maxLength";
            index = expr.indexOf("<");
        } else if (expr.indexOf(">") > 0) {
            argName = "minLength";
            index = expr.indexOf(">");
        } else {
            throw new Exception("Unknown expr: " + expr);
        }
        String argValue = expr.substring(index + 2);
        config.getParams().put(argName, argValue);
        return config;
    }

}
TOP

Related Classes of org.jbpm.ui.infopath.StringLengthExpressionAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.