Examples of BELParseResults


Examples of org.openbel.framework.common.bel.parser.BELParseResults

    private void convertBelToXbel(final File inputFile,
            final OutputStream output) {
        try {
            final String belText = FileUtils.readFileToString(inputFile, UTF_8);
            final BELParseResults result = BELParser.parse(belText);

            // Report any BEL parser warnings or errors if verbose mode is enabled
            if (verbose) {
                final List<BELParseWarningException> warnings =
                        result.getSyntaxWarnings();
                final List<BELParseErrorException> errors =
                        result.getSyntaxErrors();
                final String inputFilePath = inputFile.getAbsolutePath();

                if (hasItems(warnings)) {
                    final int numWarnings = warnings.size();
                    reportable.output(format("%d BEL parser warning%s:",
                            numWarnings, (numWarnings == 1 ? "" : "s")));
                    int i = 0;
                    for (BELParseWarningException warning : warnings) {
                        final ValidationError err = new ValidationError(
                                inputFilePath,
                                warning.getMessage(),
                                warning.getLine(),
                                warning.getCharacter());
                        reportable.output(format("%5d. %s", ++i,
                                err.getUserFacingMessage()));
                    }
                }
                if (hasItems(errors)) {
                    final int numErrors = errors.size();
                    reportable.output(format("%d BEL parser error%s:",
                            numErrors, (numErrors == 1 ? "" : "s")));
                    int i = 0;
                    for (BELParseErrorException error : errors) {
                        final ValidationError err = new ValidationError(
                                inputFilePath,
                                error.getMessage(),
                                error.getLine(),
                                error.getCharacter());
                        reportable.output(format("%5d. %s", ++i,
                                err.getUserFacingMessage()));
                    }
                }
            }

            final Document bel =
                    new BELDocumentConverter().convert(result.getDocument());

            final org.openbel.framework.common.xbel.converters.DocumentConverter converter =
                    new org.openbel.framework.common.xbel.converters.DocumentConverter();

            new XBELConverter().marshal(converter.convert(bel), output);
View Full Code Here

Examples of org.openbel.framework.common.bel.parser.BELParseResults

                document = converter.toCommon(file);
            } else if (isBELScript(file)) {
                List<ValidationError> validationErrors =
                        new ArrayList<ValidationError>();
                BELParseResults results = belValidator
                        .validateBELScript(file);

                // if validation errors exist then report and fail document
                if (hasItems(results.getSyntaxErrors())) {
                    for (BELParseErrorException syntaxError : results
                            .getSyntaxErrors()) {
                        validationErrors.add(new ValidationError(file
                                .getAbsolutePath(), syntaxError
                                .getMessage(),
                                syntaxError.getLine(), syntaxError
                                        .getCharacter()));
                    }
                    numErrors += validationErrors.size();

                    if (!quiet) {
                        reportValidationError(validationErrors);
                    }
                    if (summary) {
                        printSummary(fileArg, numWarnings, numErrors);
                    }
                    bail(ExitCode.VALIDATION_FAILURE);
                    return;
                }

                document = belConverter.toCommon(results.getDocument());
            } else {
                // unreachable; checked with isBelDocument
                fatal("Unsupported document type");
                return;
            }
View Full Code Here

Examples of org.openbel.framework.common.bel.parser.BELParseResults

     */
    @Override
    public Stage1Output stage1BELValidation(File f) {
        Stage1Output output = new Stage1Output();

        BELParseResults rslts = belValidator.validateBELScript(f);
        List<BELParseErrorException> sntxErrs = rslts.getSyntaxErrors();
        if (hasItems(sntxErrs)) {
            ValidationError ve;
            for (BELParseErrorException err : sntxErrs) {
                final String name = f.getAbsolutePath();
                final String msg = err.getMessage();
                final int line = err.getLine();
                final int col = err.getCharacter();
                ve = new ValidationError(name, msg, line, col);
                output.addValidationError(ve);
            }
            return output;
        }

        final Document d = belConverter.toCommon(rslts.getDocument());
        output.setDocument(d);

        List<AnnotationDefinition> definitions = d.getDefinitions();
        if (definitions == null) {
            return output;
View Full Code Here
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.