Package net.mindengine.galen.parser

Examples of net.mindengine.galen.parser.SyntaxException


    @Override
    public Void build(VarsContext context) {
       
        String name = getArguments().trim();
        if (name.isEmpty()) {
            throw new SyntaxException(getLine(), "Table name should not be empty");
        }
       
        Table table = new Table();
       
        for (Node<?> childNode : getChildNodes()) {
View Full Code Here


        else throw new SuiteReaderException("Unknown instruction: " + firstWord);
    }

    private List<Node<?>> importSuite(String path, Line line) throws FileNotFoundException, IOException {
        if (path.isEmpty()) {
            throw new SyntaxException(line, "No path specified for importing");
        }
       
        String fullChildPath = contextPath + File.separator + path;
        String childContextPath = new File(fullChildPath).getParent();
        GalenSuiteLineProcessor childProcessor = new GalenSuiteLineProcessor(properties, childContextPath);
       
        File file = new File(fullChildPath);
        if (!file.exists()) {
            throw new SyntaxException(line, "File doesn't exist: " + file.getAbsolutePath());
        }
        childProcessor.readLines(new FileInputStream(file));
        return childProcessor.rootNode.getChildNodes();
    }
View Full Code Here

    }

    @Override
    public Node<?> processNewNode(Line line) {
        if (line.startsWith(" ")) {
            throw new SyntaxException(line, "Should not start with space");
        }
       
        SuiteNode suiteNode = new SuiteNode(line);
        add(suiteNode);
        return suiteNode;
View Full Code Here

        if (headers == null) {
            headers = row;
        }
        else {
            if (row.size() != headers.size()) {
                throw new SyntaxException(UNKNOWN_LINE, "Amount of cells in a row is not the same in header");
            }
            rows.add(row);
        }
       
    }
View Full Code Here

    }

    public void mergeWith(Table table) {
        if (table.headers != null && table.rows.size() > 0) {
            if (table.headers.size() != headers.size()) {
                throw new SyntaxException(UNKNOWN_LINE, "Cannot merge tables. Amount of columns should be same");
            }
            else {
                for (List<String> row : table.rows) {
                    rows.add(row);
                }
View Full Code Here

        childNode.parent = this;
        childNode.level = this.level + 1;
       
        int spaceDiff = childNode.getSpacesIndentation() - this.getSpacesIndentation();
        if (spaceDiff > 8) {
            throw new SyntaxException(childNode.line, "Incorrect indentation. Should use from 1 to 8 spaces");
        }
       
        if (getChildNodes().size() > 0) {
            if (getChildNodes().get(0).getSpacesIndentation() != childNode.getSpacesIndentation()) {
                throw new SyntaxException(childNode.line, "Incorrect indentation. Amount of spaces in indentation should be the same within one level");
            }
        }
       
        getChildNodes().add(childNode);
    }
View Full Code Here

    }
   
   
    @Test(dataProvider = "provideBadSamples")
    public void shouldGiveError_forIncorrect_objectDefinitions(String objectDefinitionText, String expectedErrorMessage) {
        SyntaxException exception = null;
        try {
            PageSpec pageSpec = new PageSpec();
            new StateObjectDefinition(pageSpec, new PageSpecReader(EMPTY_PROPERTIES, NO_BROWSER)).process(objectDefinitionText, EMPTY_PLACE);
        }
        catch (SyntaxException e) {
            exception = e;
        }
       
        assertThat("Exception should be", exception, is(notNullValue()));
        assertThat("Exception message should be", exception.getMessage(), is(expectedErrorMessage));
    }
View Full Code Here

                    valueB = valueB * value / 100.0;
                }
               
                return new Range(valueA, valueB).withType(range.getRangeType());
            }
            else throw new SyntaxException(UNKNOWN_LINE, format("Locator for object \"%s\" is not specified", objectName));
        }
        else throw new SyntaxException(UNKNOWN_LINE, format("Value path is incorrect %s", valuePath));
    }
View Full Code Here

            }
            else if (objectValue instanceof Double) {
                return ((Double)objectValue).intValue();
            }
            else {
                throw new SyntaxException(UNKNOWN_LINE, format("Cannot convert value to integer. The obtained value is of %s type", objectValue.getClass()));
            }
        }
    }
View Full Code Here

        if (index > 0 && index < fieldPath.length() - 1) {
           
            String fieldName = fieldPath.substring(0, index);
            String leftOverPath = fieldPath.substring(index + 1);
            if (leftOverPath.isEmpty()) {
                throw new SyntaxException(UNKNOWN_LINE, format("Cannot read path %s", fieldPath));
            }
           
            Object field = getField(object, fieldName);
            if (field == null) {
                throw new NullPointerException(format("\"%s\" returned null", fieldName));
View Full Code Here

TOP

Related Classes of net.mindengine.galen.parser.SyntaxException

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.