Package org.apache.cocoon.woody.datatype

Examples of org.apache.cocoon.woody.datatype.ValidationRule


    private boolean arrayType = false;

    public ValidationError validate(Object value, ExpressionContext expressionContext) {
        Iterator validationRulesIt = validationRules.iterator();
        while (validationRulesIt.hasNext()) {
            ValidationRule validationRule = (ValidationRule)validationRulesIt.next();
            ValidationError result = validationRule.validate(value, expressionContext);
            if (result != null)
                return result;
        }
        return null;
    }
View Full Code Here


    protected void buildValidationRules(Element datatypeElement, AbstractDatatype datatype, DatatypeManager datatypeManager) throws Exception {
        Element validationElement = DomHelper.getChildElement(datatypeElement, Constants.WD_NS, "validation");
        if (validationElement != null) {
            Element[] validationElements = DomHelper.getChildElements(validationElement, Constants.WD_NS);
            for (int i = 0; i < validationElements.length; i++) {
                ValidationRule rule = datatypeManager.createValidationRule(validationElements[i]);
                if (rule.supportsType(datatype.getTypeClass(), datatype.isArrayType())) {
                    datatype.addValidationRule(rule);
                } else {
                    throw new Exception("Validation rule \"" + validationElements[i].getLocalName() + "\" cannot be used with strings, error at " + DomHelper.getLocation(validationElements[i]));
                }
            }
View Full Code Here

    private Convertor convertor;

    public ValidationError validate(Object value, ExpressionContext expressionContext) {
        Iterator validationRulesIt = validationRules.iterator();
        while (validationRulesIt.hasNext()) {
            ValidationRule validationRule = (ValidationRule)validationRulesIt.next();
            ValidationError result = validationRule.validate(value, expressionContext);
            if (result != null)
                return result;
        }
        return null;
    }
View Full Code Here

        Element validationElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "validation", false);
        if (validationElement != null) {
            Element[] validationRuleElements = DomHelper.getChildElements(validationElement, Constants.WD_NS);
            for (int i = 0; i < validationRuleElements.length; i++) {
                Element validationRuleElement = validationRuleElements[i];
                ValidationRule validationRule = datatypeManager.createValidationRule(validationRuleElement);
                if (!validationRule.supportsType(String.class, false))
                    throw new Exception("The validation rule for the aggregatefield " + definition.getId() + " specified at " + DomHelper.getLocation(validationRuleElement) + " does not work with strings.");
                definition.addValidationRule(validationRule);
            }
        }
View Full Code Here

            }
            // validate against my own validation rules
            Iterator validationRuleIt = aggregateDefinition.getValidationRuleIterator();
            ExpressionContextImpl exprCtx = new ExpressionContextImpl(this, true);
            while (validationRuleIt.hasNext()) {
                ValidationRule validationRule = (ValidationRule)validationRuleIt.next();
                validationError = validationRule.validate(enteredValue, exprCtx);
                if (validationError != null)
                    return false;
            }
        }
        return validationError == null ? super.validate(formContext) : false;
View Full Code Here

    private Convertor convertor;

    public ValidationError validate(Object value, ExpressionContext expressionContext) {
        Iterator validationRulesIt = validationRules.iterator();
        while (validationRulesIt.hasNext()) {
            ValidationRule validationRule = (ValidationRule)validationRulesIt.next();
            ValidationError result = validationRule.validate(value, expressionContext);
            if (result != null)
                return result;
        }
        return null;
    }
View Full Code Here

    protected void buildValidationRules(Element datatypeElement, AbstractDatatype datatype, DatatypeManager datatypeManager) throws Exception {
        Element validationElement = DomHelper.getChildElement(datatypeElement, Constants.WD_NS, "validation");
        if (validationElement != null) {
            Element[] validationElements = DomHelper.getChildElements(validationElement, Constants.WD_NS);
            for (int i = 0; i < validationElements.length; i++) {
                ValidationRule rule = datatypeManager.createValidationRule(validationElements[i]);
                if (!rule.supportsType(datatype.getTypeClass(), datatype.isArrayType())) {
                    throw new Exception("Validation rule \"" + validationElements[i].getLocalName() + "\" cannot be used with strings, error at " + DomHelper.getLocation(validationElements[i]));
                }
                datatype.addValidationRule(rule);
            }
        }
View Full Code Here

        Element validationElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "validation", false);
        if (validationElement != null) {
            Element[] validationRuleElements = DomHelper.getChildElements(validationElement, Constants.WD_NS);
            for (int i = 0; i < validationRuleElements.length; i++) {
                Element validationRuleElement = validationRuleElements[i];
                ValidationRule validationRule = datatypeManager.createValidationRule(validationRuleElement);
                if (!validationRule.supportsType(String.class, false))
                    throw new Exception("The validation rule for the aggregatefield " + definition.getId() + " specified at " + DomHelper.getLocation(validationRuleElement) + " does not work with strings.");
                definition.addValidationRule(validationRule);
            }
        }
View Full Code Here

            }
            // validate against my own validation rules
            Iterator validationRuleIt = definition.getValidationRuleIterator();
            ExpressionContextImpl exprCtx = new ExpressionContextImpl(this, true);
            while (validationRuleIt.hasNext()) {
                ValidationRule validationRule = (ValidationRule)validationRuleIt.next();
                validationError = validationRule.validate(enteredValue, exprCtx);
                if (validationError != null)
                    return false;
            }
        }
        return validationError == null;
View Full Code Here

        Element validationElement = DomHelper.getChildElement(widgetElement, Constants.WD_NS, "validation", false);
        if (validationElement != null) {
            Element[] validationRuleElements = DomHelper.getChildElements(validationElement, Constants.WD_NS);
            for (int i = 0; i < validationRuleElements.length; i++) {
                Element validationRuleElement = validationRuleElements[i];
                ValidationRule validationRule = datatypeManager.createValidationRule(validationRuleElement);
                if (!validationRule.supportsType(String.class, false))
                    throw new Exception("The validation rule for the aggregatefield " + definition.getId() + " specified at " + DomHelper.getLocation(validationRuleElement) + " does not work with strings.");
                definition.addValidationRule(validationRule);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.woody.datatype.ValidationRule

Copyright © 2018 www.massapicom. 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.