Package org.modeshape.common.text

Examples of org.modeshape.common.text.ParsingException


                            }
                        }
                        if (!foundClosingQuote) {
                            String msg = CommonI18n.noMatchingDoubleQuoteFound.text(startingPosition.getLine(),
                                                                                    startingPosition.getColumn());
                            throw new ParsingException(startingPosition, msg);
                        }
                        endIndex = input.index() + 1; // beyond last character read
                        tokens.addToken(startingPosition, startIndex, endIndex, DOUBLE_QUOTED_STRING);
                        break;
                    case '\u2019': // '’':
                    case '\'':
                        char quoteChar = c;
                        startIndex = input.index();
                        startingPosition = input.position(startIndex);
                        foundClosingQuote = false;
                        while (input.hasNext()) {
                            c = input.next();
                            if (c == '\\' && input.isNext(quoteChar)) {
                                c = input.next(); // consume the ' character since it is escaped
                            } else if (c == quoteChar) {
                                foundClosingQuote = true;
                                break;
                            }
                        }
                        if (!foundClosingQuote) {
                            String msg = CommonI18n.noMatchingSingleQuoteFound.text(startingPosition.getLine(),
                                                                                    startingPosition.getColumn());
                            throw new ParsingException(startingPosition, msg);
                        }
                        endIndex = input.index() + 1; // beyond last character read
                        tokens.addToken(startingPosition, startIndex, endIndex, SINGLE_QUOTED_STRING);
                        break;
                    case '/':
View Full Code Here


        CheckArg.isNotEmpty(parserId, "parserId");

        DdlParser parser = getParser(parserId);

        if (parser == null) {
            throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(parserId));
        }

        // create DDL root node
        AstNode astRoot = createDdlStatementsContainer(parserId);
View Full Code Here

        { // add first parser
            final DdlParser parser = getParser(firstParserId);

            if (parser == null) {
                throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(firstParserId));
            }

            selectedParsers.add(parser);
        }

        { // add second parser
            final DdlParser parser = getParser(secondParserId);

            if (parser == null) {
                throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(secondParserId));
            }

            selectedParsers.add(parser);
        }

        // add remaining parsers
        if ((additionalParserIds != null) && (additionalParserIds.length != 0)) {
            for (final String id : additionalParserIds) {
                final DdlParser parser = getParser(id);

                if (parser == null) {
                    throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.unknownParser.text(id));
                }

                selectedParsers.add(parser);
            }
        }
View Full Code Here

            }
        }

        if (scoreMap.isEmpty()) {
            if (firstException == null) {
                throw new ParsingException(Position.EMPTY_CONTENT_POSITION,
                                           DdlSequencerI18n.errorParsingDdlContent.text(this.parsers.size()));
            }

            throw firstException;
        }

        // sort the scores
        final List<Entry<DdlParser, Integer>> scoredParsers = new ArrayList<Entry<DdlParser, Integer>>(scoreMap.entrySet());
        Collections.sort(scoredParsers, SORTER);

        firstException = null;
        AstNode astRoot = null;

        for (final Entry<DdlParser, Integer> scoredParser : scoredParsers) {
            try {
                final DdlParser parser = scoredParser.getKey();

                // create DDL root node
                astRoot = createDdlStatementsContainer(parser.getId());

                // parse
                parser.parse(ddl, astRoot, null);
                return astRoot; // successfully parsed
            } catch (final RuntimeException e) {
                if (astRoot != null) {
                    astRoot.removeFromParent();
                }

                if (firstException == null) {
                    firstException = e;
                }
            }
        }

        if (firstException == null) {
            throw new ParsingException(Position.EMPTY_CONTENT_POSITION, DdlSequencerI18n.errorParsingDdlContent.text());
        }

        throw firstException;
    }
View Full Code Here

            text.append(token);
        }

        if ((numLeft != numRight) || (text.length() == 0)) {
            throw new ParsingException(tokens.nextPosition());
        }

        return text.toString();
    }
View Full Code Here

                indexNode.setProperty(OracleDdlLexicon.OTHER_INDEX_REFS, functions);
            }
        }

        if (numLeft != numRight) {
            throw new ParsingException(tokens.nextPosition());
        }

        tokens.consume(R_PAREN); // must have closing paren
    }
View Full Code Here

                parseNamespaceMapping(tokens);
            } else if (tokens.matches("[", ANY_VALUE, "]")) {
                parseNodeTypeDefinition(tokens);
            } else {
                Position position = tokens.previousPosition();
                throw new ParsingException(position, CndI18n.expectedNamespaceOrNodeDefinition.text(tokens.consume(),
                                                                                                    position.getLine(),
                                                                                                    position.getColumn()));
            }
        }
    }
View Full Code Here

                parseQueryOperators(tokens, propDefn);
            } else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) {
                Position pos = tokens.previousPosition();
                int line = pos.getLine();
                int column = pos.getColumn();
                throw new ParsingException(tokens.previousPosition(),
                                           CndI18n.primaryKeywordNotValidInJcr2CndFormat.text(line, column));
            } else if (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
                List<Property> properties = new LinkedList<Property>();
                parseVendorExtensions(tokens, properties);
                applyVendorExtensions(propDefn, properties);
View Full Code Here

        String operatorList = removeQuotes(tokens.consume());
        // Now split this string on ',' ...
        for (String operatorValue : operatorList.split(",")) {
            String operator = operatorValue.trim();
            if (!VALID_QUERY_OPERATORS.contains(operator)) {
                throw new ParsingException(tokens.previousPosition(), CndI18n.expectedValidQueryOperator.text(operator));
            }
            operators.add(operator);
        }
        if (operators.isEmpty()) {
            operators.addAll(VALID_QUERY_OPERATORS);
View Full Code Here

                sns = true;
            } else if (tokens.canConsumeAnyOf("MULTIPLE", "MUL", "*")) { // from pre-JCR 2.0 ref impl
                Position pos = tokens.previousPosition();
                int line = pos.getLine();
                int column = pos.getColumn();
                throw new ParsingException(tokens.previousPosition(),
                                           CndI18n.multipleKeywordNotValidInJcr2CndFormat.text(line, column));
            } else if (tokens.matchesAnyOf(VALID_ON_PARENT_VERSION)) {
                onParentVersion = tokens.consume();
                tokens.canConsume('?');
            } else if (tokens.matches("OPV")) {
                // variant on-parent-version
                onParentVersion = tokens.consume();
                tokens.canConsume('?');
            } else if (tokens.canConsumeAnyOf("PRIMARYITEM", "PRIMARY", "PRI", "!")) {
                Position pos = tokens.previousPosition();
                int line = pos.getLine();
                int column = pos.getColumn();
                throw new ParsingException(tokens.previousPosition(),
                                           CndI18n.primaryKeywordNotValidInJcr2CndFormat.text(line, column));
            } else if (tokens.matches(CndTokenizer.VENDOR_EXTENSION)) {
                List<Property> properties = new LinkedList<Property>();
                parseVendorExtensions(tokens, properties);
                applyVendorExtensions(childDefn, properties);
View Full Code Here

TOP

Related Classes of org.modeshape.common.text.ParsingException

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.