com.spikeify.aerospikeql.parse.fields.HavingField Maven / Gradle / Ivy
                 Go to download
                
        
                    Show more of this group  Show more artifacts with this name
Show all versions of aerospike-ql Show documentation
                Show all versions of aerospike-ql Show documentation
SQL wrapper for Aerospike database
                
            package com.spikeify.aerospikeql.parse.fields;
import com.udojava.evalex.Expression;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by roman on 07/08/15.
 *
 * HavingField is used to parse conditions of having field
 */
public class HavingField {
	private final ArrayList fields;
	private String statement;
	private Expression expression;
	public HavingField() {
		this.statement = "";
		this.fields = new ArrayList<>();
		this.expression = null;
	}
	public ArrayList getFields() {
		return fields;
	}
	/**
	 * set fields that are in having statements
	 *
	 * @param aliases - list of aliases
	 */
	public void setFields(List aliases) {
		statement = statement.replace("AND", "&&").replace("OR", "||"); //JSQL parser automatically converts and to AND.
		for (String field : aliases) {
			if (statement.contains(field)) {
				fields.add(field);
			}
		}
	}
	public Expression getExpression() {
		return expression;
	}
	public void setExpression(Long currentTimestamp) {
		statement = statement.replaceAll("(?i)NOW\\(\\)", String.valueOf(currentTimestamp));
		expression = new Expression(statement);
	}
	public String getStatement() {
		return statement;
	}
	public void setStatement(String statement) {
		this.statement = statement;
	}
}
       © 2015 - 2025 Weber Informatics LLC | Privacy Policy