All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mindengine.galen.parser.Expectations Maven / Gradle / Ivy

There is a newer version: 1.6.4
Show newest version
/*******************************************************************************
* Copyright 2014 Ivan Shubin http://mindengine.net
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*   http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package net.mindengine.galen.parser;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import net.mindengine.galen.specs.Location;
import net.mindengine.galen.specs.Range;
import net.mindengine.galen.specs.Side;
import net.mindengine.galen.specs.colors.ColorRange;
import net.mindengine.galen.specs.page.CorrectionsRect;
import net.mindengine.galen.specs.reader.StringCharReader;
import org.apache.commons.lang3.tuple.Pair;

public class Expectations {

    
    public static List> expectThese(Expectation...expectations) {
        return Arrays.asList(expectations);
    }

    public static Expectation> sides() {
        return new ExpectSides();
    }

    public static Expectation range() {
        return new ExpectRange();
    }

    public static Expectation objectName() {
        return new ExpectWord();
    }

    public static Expectation filePath() {
        return new ExpectWord();
    }

    public static Expectationnumber() {
        return new ExpectNumber();
    }

    public static Expectation word() {
        return new ExpectWord();
    }
    
    public static Expectation commandLineArguments() {
        return new ExpectCommandLineArguments();
    }
    
    public static boolean isDelimeter(char symbol) {
        return symbol == ' ' || symbol == '\t';
    }
    
    public static boolean isWordDelimeter(char symbol) {
        return symbol == ' ' || symbol == '\t' || symbol == ',';
    }
    
    public static boolean isNumeric(char symbol) {
        return symbol == '-' || (symbol >= '0' && symbol <= '9');
    }

    public static Expectation> locations() {
        return new ExpectLocations();
    }

    public static Expectation corrections() {
        return new ExpectCorrection();
    }

    public static Expectation> colorRanges() {
        return new ExpectColorRanges();
    }


    public static Expectation>> commaSeparatedRepeatedKeyValues() {
        return new ExpectCommaSeparatedKeyValue();
    }

    public static List readAllWords(String arguments) {
        List words = new LinkedList();
        StringCharReader reader = new StringCharReader(arguments);

        ExpectWord expectWord = new ExpectWord();

        while(reader.hasMoreNormalSymbols()) {
            String word = expectWord.read(reader);
            if (!word.isEmpty()) {
                words.add(word);
            }
        }

        return words;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy