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

com.github.schlak.universalQB.Definition.Statements.BasicSelectBuilder Maven / Gradle / Ivy

Go to download

The java lib universalQB can be used to access different databases using formalized objects. These objects got converted into a query matching to the syntactical rules of the database management system

There is a newer version: 0.6.4
Show newest version
package com.github.schlak.universalQB.Definition.Statements;

import com.github.schlak.universalQB.Definition.Cleanable;
import com.github.schlak.universalQB.Definition.GeneralObjects.Column;
import com.github.schlak.universalQB.Definition.GeneralObjects.ConditionStack;
import com.github.schlak.universalQB.Definition.GeneralObjects.ValueAllocation;
import com.github.schlak.universalQB.Definition.GeneralOperations.AddColumnToShow;
import com.github.schlak.universalQB.Definition.GeneralOperations.AddLimitClause;
import com.github.schlak.universalQB.Definition.GeneralOperations.AddWhereClause;
import com.github.schlak.universalQB.Definition.GeneralOperations.SetTable;
import com.github.schlak.universalQB.Definition.IQuery;
import com.github.schlak.universalQB.Definition.StatementBoxes.BasicSelectBox;
import com.github.schlak.universalQB.Exeptions.QueryBuildException;
import com.github.schlak.universalQB.ObjectRecycler;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jonas on 15.03.17.
 */
public abstract class BasicSelectBuilder implements SetTable, AddColumnToShow,
        AddWhereClause, AddLimitClause,
        IQuery, Cleanable{

    protected List columnList;
    protected String table;
    protected ConditionStack whereConditionStack;
    /**
     * The limit of data sets the query will effect.
     * 

* if the limit is set zero the code handel's the value as not set and ignores the limit while * generating the statement */ protected int limit; public BasicSelectBuilder() { this.clean(); } @Override public void column(Column column) { this.columnList.add(column); } public void setTableName(String tableName) { this.table = tableName; } @Override public void where(ConditionStack conditionStack) { whereConditionStack.addCondition(conditionStack); } @Override public void where(ValueAllocation valueAllocation) { whereConditionStack.addCondition(valueAllocation); } @Override public void limit(int limit) { if (limit < 0) this.limit = 0; this.limit = limit; } @Override public abstract BasicSelectBox getStatementBox() throws QueryBuildException; @Override public void clean() { if (this.columnList != null){ this.columnList.forEach(ObjectRecycler::returnInstance); this.columnList.clear(); } else { this.columnList = new ArrayList<>(); } this.table = ""; this.limit = 0; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy