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

com.yahoo.document.select.simple.OperatorParser Maven / Gradle / Ivy

There is a newer version: 8.458.13
Show newest version
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.select.simple;

/**
 * @author baldersheim
 */
public class OperatorParser extends Parser {
    private String operator;
    public String getOperator() { return operator; }
    public boolean parse(CharSequence s) {
        boolean retval = false;
        int pos = eatWhite(s);

        if (pos+1 < s.length()) {
            retval = true;
            int startPos = pos;
            if (s.charAt(pos) == '=') {
                pos++;
                if ((s.charAt(pos) == '=') || (s.charAt(pos) == '~')) {
                    pos++;
                }
            } else if (s.charAt(pos) == '>') {
                pos++;
                if (s.charAt(pos) == '=') {
                    pos++;
                }
            } else if (s.charAt(pos) == '<') {
                pos++;
                if (s.charAt(pos) == '=') {
                    pos++;
                }
            } else if ((s.charAt(pos) == '!') && (s.charAt(pos) == '=')) {
                pos += 2;
            } else {
                retval = false;
            }
            if (retval) {
                operator = s.subSequence(startPos, pos).toString();
            }
        }
        setRemaining(s.subSequence(pos, s.length()));

        return retval;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy