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

org.tinygroup.jsqlparser.util.SelectUtils Maven / Gradle / Ivy

There is a newer version: 3.4.9
Show newest version
/**
 *  Copyright (c) 1997-2013, www.tinygroup.org ([email protected]).
 *
 *  Licensed under the GPL, Version 3.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.gnu.org/licenses/gpl.html
 *
 *  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 org.tinygroup.jsqlparser.util;

import org.tinygroup.jsqlparser.JSQLParserException;
import org.tinygroup.jsqlparser.expression.Expression;
import org.tinygroup.jsqlparser.parser.CCJSqlParserUtil;
import org.tinygroup.jsqlparser.schema.Table;
import org.tinygroup.jsqlparser.statement.select.*;

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

/**
 * Utility function for select statements.
 *
 * @author toben
 */
public final class SelectUtils {

	private SelectUtils() {
	}
	
	/**
	 * Builds select expr1, expr2 from table.
	 * @param table
	 * @param expr
	 * @return 
	 */
	public static Select buildSelectFromTableAndExpressions(Table table, Expression ... expr) {
		SelectItem[] list = new SelectItem[expr.length];
		for (int i=0;i joins = plainSelect.getJoins();
			if (joins == null) {
				joins = new ArrayList();
				plainSelect.setJoins(joins);
			}
			Join join = new Join();
			join.setRightItem(table);
			join.setOnExpression(onExpression);
			joins.add(join);
			return join;
		}
		throw new UnsupportedOperationException("Not supported yet.");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy