Package org.apache.bval

Examples of org.apache.bval.DynamicMetaBean


     * @param context
     *            The validation context, its current bean must be an array.
     */
    static protected <VL extends ValidationListener> void validateArrayInContext(ValidationContext<VL> context, ValidateCallback s) {
        int index = 0;
        DynamicMetaBean dyn = getDynamicMetaBean(context);
        for (Object each : ((Object[]) context.getBean())) {
            context.setCurrentIndex(index++);
            if (each == null) {
                continue; // Null values are not validated
            }
            if (dyn != null) {
                context.setBean(each, dyn.resolveMetaBean(each));
            } else {
                context.setBean(each);
            }
            s.validate();
        }
View Full Code Here


        final boolean positional = context.getBean() instanceof List<?>;
        int index = 0;
        context.setCurrentIndex(null);

        // jsr303 spec: Each object provided by the iterator is validated.
        final DynamicMetaBean dyn = getDynamicMetaBean(context);
        for (Object each : (Iterable<?>) context.getBean()) {
            if (positional) {
                context.setCurrentIndex(index++);
            }
            if (each == null) {
                continue; // Null values are not validated
            }
            if (dyn != null) {
                context.setBean(each, dyn.resolveMetaBean(each));
            } else {
                context.setBean(each);
            }
            s.validate();
        }
View Full Code Here

     *            {@link Map}.
     */
    static protected <VL extends ValidationListener> void validateMapInContext(ValidationContext<VL> context, ValidateCallback s) {
        // jsr303 spec: For Map, the value of each Map.Entry is validated (key is not validated).
        Map<?, ?> currentBean = (Map<?, ?>) context.getBean();
        final DynamicMetaBean dyn = getDynamicMetaBean(context);
        for (Object key : currentBean.keySet()) {
            context.setCurrentKey(key);
            Object value = currentBean.get(key);
            if (value == null) {
                continue; // Null values are not validated
            }
            if (dyn != null) {
                context.setBean(value, dyn.resolveMetaBean(value));
            } else {
                context.setBean(value);
            }
            s.validate();
        }
View Full Code Here

     * @param context
     *            The validation context, its current bean must be an array.
     */
    static protected <VL extends ValidationListener> void validateArrayInContext(ValidationContext<VL> context, ValidateCallback s) {
        int index = 0;
        DynamicMetaBean dyn = getDynamicMetaBean(context);
        Object[] array = (Object[]) context.getBean();
        MetaBean metaBean = context.getMetaBean();
        context.setCurrentIndex(null);
        try {
            for (Object each : array) {
                context.setCurrentIndex(index++);
                if (each == null) {
                    continue; // Null values are not validated
                }
                if (dyn != null) {
                    context.setBean(each, dyn.resolveMetaBean(each));
                } else {
                    context.setBean(each);
                }
                s.validate();
            }
View Full Code Here

        MetaBean metaBean = context.getMetaBean();
        context.setCurrentIndex(null);

        try {
            // jsr303 spec: Each object provided by the iterator is validated.
            final DynamicMetaBean dyn = getDynamicMetaBean(context);
            for (Object each : iterable) {
                if (positional) {
                    context.setCurrentIndex(index++);
                }
                if (each == null) {
                    continue; // Null values are not validated
                }
                if (dyn != null) {
                    context.setBean(each, dyn.resolveMetaBean(each));
                } else {
                    context.setBean(each);
                }
                s.validate();
            }
View Full Code Here

    static protected <VL extends ValidationListener> void validateMapInContext(ValidationContext<VL> context, ValidateCallback s) {
        // jsr303 spec: For Map, the value of each Map.Entry is validated (key
        // is not validated).
        Map<?, ?> currentBean = (Map<?, ?>) context.getBean();
        MetaBean metaBean = context.getMetaBean();
        final DynamicMetaBean dyn = getDynamicMetaBean(context);
        context.setCurrentKey(null);
        try {
            for (Map.Entry<?, ?> entry : currentBean.entrySet()) {
                Object value = entry.getValue();
                if (value == null) {
                    continue;
                }
                context.setCurrentKey(entry.getKey());
                if (dyn == null) {
                    context.setBean(value);
                } else {
                    context.setBean(value, dyn.resolveMetaBean(value));
                }
                s.validate();
            }
        } finally {
            context.moveUp(currentBean, metaBean);
View Full Code Here

        assert (object == null) ^ (value == VALIDATE_PROPERTY);
        checkPropertyName(propertyName);
        checkGroups(groups);

        try {
            final MetaBean initialMetaBean = new DynamicMetaBean(getMetaBeanFinder());
            initialMetaBean.setBeanClass(beanType);
            GroupValidationContext<T> context = createContext(initialMetaBean, object, beanType, groups);
            ValidationContextTraversal contextTraversal = createValidationContextTraversal(context);
            PathNavigation.navigate(propertyName, contextTraversal);

            MetaProperty prop = context.getMetaProperty();
View Full Code Here

     * @param context
     *            The validation context, its current bean must be an array.
     */
    static protected <VL extends ValidationListener> void validateArrayInContext(ValidationContext<VL> context, ValidateCallback s) {
        int index = 0;
        DynamicMetaBean dyn = getDynamicMetaBean(context);
        Object[] array = (Object[]) context.getBean();
        MetaBean metaBean = context.getMetaBean();
        context.setCurrentIndex(null);

        try {
            for (Object each : array) {
                context.setCurrentIndex(index++);
                if (each == null) {
                    continue; // Null values are not validated
                }
                if (dyn != null) {
                    context.setBean(each, dyn.resolveMetaBean(each));
                } else {
                    context.setBean(each);
                }
                s.validate();
            }
View Full Code Here

        MetaBean metaBean = context.getMetaBean();
        context.setCurrentIndex(null);

        try {
            // jsr303 spec: Each object provided by the iterator is validated.
            final DynamicMetaBean dyn = getDynamicMetaBean(context);
            for (Object each : iterable) {
                if (positional) {
                    context.setCurrentIndex(index++);
                }
                if (each == null) {
                    continue; // Null values are not validated
                }
                if (dyn != null) {
                    context.setBean(each, dyn.resolveMetaBean(each));
                } else {
                    context.setBean(each);
                }
                s.validate();
            }
View Full Code Here

    static protected <VL extends ValidationListener> void validateMapInContext(ValidationContext<VL> context, ValidateCallback s) {
        // jsr303 spec: For Map, the value of each Map.Entry is validated (key
        // is not validated).
        Map<?, ?> currentBean = (Map<?, ?>) context.getBean();
        MetaBean metaBean = context.getMetaBean();
        final DynamicMetaBean dyn = getDynamicMetaBean(context);
        context.setCurrentKey(null);
        try {
            for (Map.Entry<?, ?> entry : currentBean.entrySet()) {
                Object value = entry.getValue();
                if (value == null) {
                    continue;
                }
                context.setCurrentKey(entry.getKey());
                if (dyn == null) {
                    context.setBean(value);
                } else {
                    context.setBean(value, dyn.resolveMetaBean(value));
                }
                s.validate();
            }
        } finally {
            context.moveUp(currentBean, metaBean);
View Full Code Here

TOP

Related Classes of org.apache.bval.DynamicMetaBean

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.