Package com.volantis.mcs.xml.validation

Examples of com.volantis.mcs.xml.validation.ErrorDetails


        }

        // Validate that the element has content that is non-whitespace
        Iterator contents = element.getContent().iterator();
        if (!contents.hasNext()) {
            ErrorDetails details = new ErrorDetails(element, new XPath(element),
                    null, FaultTypes.WHITESPACE, null, null);
            errorReporter.reportError(details);
        } else {
            do {
                Object content = contents.next();
                if (content == null || ((Text) content).getText().trim().
                        length() == 0) {
                    ErrorDetails details = new ErrorDetails(element, new XPath(element),
                            null, FaultTypes.WHITESPACE, null, null);
                    errorReporter.reportError(details);
                }
            } while (contents.hasNext());
        }
View Full Code Here


            if (decendents.size() > maxCount) {
                result = true;

                if (errorReporter != null) {
                    // @todo it would be nice to pass actual and max counts
                    ErrorDetails details = new ErrorDetails(element, new XPath(element),
                            null, errorKey, ancestorElementName, null);
                    errorReporter.reportError(details);
                }
            }
        }
View Full Code Here

                    errorReporter, min);
            BigDecimal maxDecimal = getBigDecimal(maxString, element,
                    errorReporter, max);
            if (minDecimal != null && maxDecimal != null &&
                    minDecimal.compareTo(maxDecimal) == 1) {
                ErrorDetails details = new ErrorDetails(element, new XPath(element),
                        null, FaultTypes.MIN_RANGE_MORE_THAN_MAX, null, null);
                errorReporter.reportError(details);
            }
        }
    }
View Full Code Here

            ErrorReporter errorReporter, Attribute attribute) {
        BigDecimal result = null;
        try {
            result = new BigDecimal(value);
        } catch (NumberFormatException e) {
            ErrorDetails details = new ErrorDetails(element, new XPath(attribute),
                    null, FaultTypes.NOT_A_NUMBER, value, null);
            errorReporter.reportError(details);
        }
        return result;
    }
View Full Code Here

            XPath currentPath = getCurrentXPath();
            try {
                for (int i = 0; i < pendingErrors.size(); i++) {
                    String errorMessage = (String) pendingErrors.get(i);

                    ErrorDetails details =
                            new ErrorDetails(element, currentPath,
                                    errorMessage, null, null, attributes);
                    errorReporter.reportError(details);
                }
            } finally {
                // clear the error list as they have all been reported.
View Full Code Here

        }

        // Now we just report the duplicates
        for (int i = 0; i < duplicates.length; i++) {
            if (duplicates[i] != null) {
                ErrorDetails details = new ErrorDetails(element, duplicates[i],
                        null, FaultTypes.DUPLICATE_ASSET, null, null);
                errorReporter.reportError(details);
            }
        }
    }
View Full Code Here

            // More than one element in the list means that we have
            // an element with a duplicate name.
            if (duplicates.size() > 1) {
                for (int i = 0; i < duplicates.size(); i++) {
                    Element element = (Element) duplicates.get(i);
                    ErrorDetails details = new ErrorDetails(element, new XPath(element),
                            null, FaultTypes.DUPLICATE_NAME, null, null);
                    errorReporter.reportError(details);
                }
            }
        }
View Full Code Here


            // Validate that the element has content that is non-whitespace
            Iterator contents = element.getContent().iterator();
            if (!contents.hasNext()) {
                ErrorDetails details = new ErrorDetails(element, new XPath(element),
                        null, FaultTypes.WHITESPACE, null, null);
                errorReporter.reportError(details);
            } else {
                Text text = (Text) contents.next();
                String value = text.getText();
                if (value.length() == 0) {
                    ErrorDetails details = new ErrorDetails(element, new XPath(element),
                            null, FaultTypes.WHITESPACE, null, null);
                    errorReporter.reportError(details);
                } else {
                    // Ensure that the value is a number that is comprized only
                    // of digits and is either 6 or 8 digits in length
                    boolean valid = value.length() == 6 || value.length() == 8;
                    if (valid) {
                        for (int i = 0; i < value.length() && valid; i++) {
                            valid = Character.isDigit(value.charAt(i));
                        }
                    }

                    if (!valid) {
                        ErrorDetails details = new ErrorDetails(
                                element, new XPath(element), null, INVALID_TAC_NUMBER,
                                null, null);
                        errorReporter.reportError(details);
                    }
                }
View Full Code Here

     *                      reported
     */
    protected void report(ErrorReporter errorReporter,
                          Element element) {
        if (errorReporter != null) {
            ErrorDetails details = new ErrorDetails(element, new XPath(element),
                    null, errorKey, ancestorElementName, null);
            errorReporter.reportError(details);
        }
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.xml.validation.ErrorDetails

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.