studio.raptor.sqlparser.fast.command.dml.Insert Maven / Gradle / Ivy
/*
* Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package studio.raptor.sqlparser.fast.command.dml;
import java.util.ArrayList;
import studio.raptor.sqlparser.fast.command.CommandInterface;
import studio.raptor.sqlparser.fast.command.Prepared;
import studio.raptor.sqlparser.fast.expression.Expression;
import studio.raptor.sqlparser.fast.table.Column;
import studio.raptor.sqlparser.fast.util.New;
/**
* This class represents the statement
* INSERT
*/
public class Insert extends Prepared {
private final ArrayList list = New.arrayList();
private Column[] columns;
public Insert() {
super();
}
public void setColumns(Column[] columns) {
this.columns = columns;
}
public void setColumns(String[] columns) {
Column[] cols = new Column[columns.length];
int i = 0;
for (String column : columns) {
cols[i++] = new Column(column);
}
this.columns = cols;
}
/**
* Add a row to this merge statement.
*
* @param expr the list of values
*/
public void addRow(Expression[] expr) {
list.add(expr);
}
@Override
public int getType() {
return CommandInterface.INSERT;
}
public Column[] getColumns() {
return columns;
}
public ArrayList getValues() {
return list;
}
}