-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi value expression for select included
- Loading branch information
Showing
7 changed files
with
222 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/main/java/net/sf/jsqlparser/statement/select/ValuesList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright (C) 2013 toben. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301 USA | ||
*/ | ||
package net.sf.jsqlparser.statement.select; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
import net.sf.jsqlparser.expression.operators.relational.ExpressionList; | ||
import net.sf.jsqlparser.expression.operators.relational.MultiExpressionList; | ||
|
||
/** | ||
* This is a container for a values item within a select statement. It holds | ||
* some syntactical stuff that differs from values within an insert statement. | ||
* | ||
* @author toben | ||
*/ | ||
public class ValuesList implements FromItem { | ||
|
||
private String alias; | ||
private MultiExpressionList multiExpressionList; | ||
private boolean noBrackets = false; | ||
private List<String> columnNames; | ||
|
||
public ValuesList() { | ||
} | ||
|
||
public ValuesList(MultiExpressionList multiExpressionList) { | ||
this.multiExpressionList = multiExpressionList; | ||
} | ||
|
||
@Override | ||
public void accept(FromItemVisitor fromItemVisitor) { | ||
fromItemVisitor.visit(this); | ||
} | ||
|
||
@Override | ||
public String getAlias() { | ||
return alias; | ||
} | ||
|
||
@Override | ||
public void setAlias(String alias) { | ||
this.alias = alias; | ||
} | ||
|
||
public MultiExpressionList getMultiExpressionList() { | ||
return multiExpressionList; | ||
} | ||
|
||
public void setMultiExpressionList(MultiExpressionList multiExpressionList) { | ||
this.multiExpressionList = multiExpressionList; | ||
} | ||
|
||
public boolean isNoBrackets() { | ||
return noBrackets; | ||
} | ||
|
||
public void setNoBrackets(boolean noBrackets) { | ||
this.noBrackets = noBrackets; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder b = new StringBuilder(); | ||
|
||
b.append("(VALUES "); | ||
for (Iterator<ExpressionList> it = getMultiExpressionList().getExprList().iterator(); it.hasNext();) { | ||
b.append(PlainSelect.getStringList(it.next().getExpressions(), true, !isNoBrackets())); | ||
if (it.hasNext()) { | ||
b.append(", "); | ||
} | ||
} | ||
b.append(")"); | ||
if (alias != null) { | ||
b.append(" AS ").append(alias); | ||
|
||
if (columnNames != null) { | ||
b.append("("); | ||
for (Iterator<String> it = columnNames.iterator(); it.hasNext();) { | ||
b.append(it.next()); | ||
if (it.hasNext()) { | ||
b.append(", "); | ||
} | ||
} | ||
b.append(")"); | ||
} | ||
} | ||
return b.toString(); | ||
} | ||
|
||
public List<String> getColumnNames() { | ||
return columnNames; | ||
} | ||
|
||
public void setColumnNames(List<String> columnNames) { | ||
this.columnNames = columnNames; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters