Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/AllArrayExpression.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2016 JSQLParser
* %%
* This program 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 program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package net.sf.jsqlparser.expression;

public class AllArrayExpression implements AllExpression {

private final ArrayLiteral array;

public AllArrayExpression(ArrayLiteral array) {
this.array = array;
}

public ArrayLiteral getArray() {
return array;
}

@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}

@Override
public String toString() {
return "ALL (" + array.toString() + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import net.sf.jsqlparser.statement.select.SubSelect;

public class AllComparisonExpression implements Expression {
public class AllComparisonExpression implements AllExpression {

private final SubSelect subSelect;

Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/AllExpression.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2016 JSQLParser
* %%
* This program 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 program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package net.sf.jsqlparser.expression;

public interface AllExpression extends Expression {

void accept(ExpressionVisitor ExpressionVisitor);
}
45 changes: 45 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/AnyArrayExpression.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2016 JSQLParser
* %%
* This program 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 program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package net.sf.jsqlparser.expression;

public class AnyArrayExpression implements AnyExpression {

private final ArrayLiteral array;

public AnyArrayExpression(ArrayLiteral array) {
this.array = array;
}

public ArrayLiteral getArray() {
return array;
}

@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}

@Override
public String toString() {
return "ANY (" + array.toString()+")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Combines ANY and SOME expressions.
* @author toben
*/
public class AnyComparisonExpression implements Expression {
public class AnyComparisonExpression implements AnyExpression {

private final SubSelect subSelect;
private final AnyType anyType;
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/AnyExpression.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2016 JSQLParser
* %%
* This program 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 program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package net.sf.jsqlparser.expression;

public interface AnyExpression extends Expression {

void accept(ExpressionVisitor ExpressionVisitor);
}
58 changes: 58 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/ArrayLiteral.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2016 JSQLParser
* %%
* This program 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 program 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 General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package net.sf.jsqlparser.expression;

import net.sf.jsqlparser.expression.operators.relational.ExpressionList;

/**
* An array literal is a list of simple expressions
* <p>
* This shows up in Postgres SQL as
* <pre>
* ARRAY[val1, val2, val3, ...]
* </pre>
*/
public class ArrayLiteral implements Expression {

private ExpressionList list;

public ArrayLiteral() {
}

@Override
public void accept(ExpressionVisitor expressionVisitor) {
expressionVisitor.visit(this);
}

public ExpressionList getList() {
return list;
}

public void setList(ExpressionList list) {
this.list = list;
}

@Override
public String toString() {
return "ARRAY["+list.toStringNoBrackets()+"]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ public interface ExpressionVisitor {

void visit(AllComparisonExpression allComparisonExpression);

void visit(AllArrayExpression allArrayExpression);

void visit(AnyComparisonExpression anyComparisonExpression);

void visit(AnyArrayExpression anyArrayExpression);

void visit(Concat concat);

void visit(Matches matches);
Expand Down Expand Up @@ -169,4 +173,7 @@ public interface ExpressionVisitor {

void visit(DateTimeLiteralExpression literal);

void visit(ArrayLiteral arrayLiteral);


}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public void visit(TimestampValue value) {

}

@Override
public void visit(ArrayLiteral array) {

}

@Override
public void visit(Parenthesis parenthesis) {
parenthesis.getExpression().accept(this);
Expand Down Expand Up @@ -247,11 +252,21 @@ public void visit(AllComparisonExpression expr) {

}

@Override
public void visit(AllArrayExpression expr) {

}

@Override
public void visit(AnyComparisonExpression expr) {

}

@Override
public void visit(AnyArrayExpression expr) {

}

@Override
public void visit(Concat expr) {
visitBinaryExpression(expr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public void accept(ItemsListVisitor itemsListVisitor) {
itemsListVisitor.visit(this);
}

public String toStringNoBrackets() {
return PlainSelect.getStringList(expressions, true, false);
}

@Override
public String toString() {
return PlainSelect.getStringList(expressions, true, true);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ public void visit(TimestampValue timestampValue) {
public void visit(TimeValue timeValue) {
}

@Override
public void visit(ArrayLiteral array) {
array.getList().accept(this);
}

/*
* (non-Javadoc)
*
Expand All @@ -324,11 +329,21 @@ public void visit(AllComparisonExpression allComparisonExpression) {
allComparisonExpression.getSubSelect().getSelectBody().accept(this);
}

@Override
public void visit(AllArrayExpression allArrayExpression) {
allArrayExpression.getArray().accept(this);
}

@Override
public void visit(AnyComparisonExpression anyComparisonExpression) {
anyComparisonExpression.getSubSelect().getSelectBody().accept(this);
}

@Override
public void visit(AnyArrayExpression anyArrayExpression) {
anyArrayExpression.getArray().accept(this);
}

@Override
public void visit(SubJoin subjoin) {
subjoin.getLeft().accept(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ public void visit(TimeValue timeValue) {
buffer.append("{t '").append(timeValue.getValue().toString()).append("'}");
}

@Override
public void visit(ArrayLiteral array) {
buffer.append(array.toString());
}

@Override
public void visit(CaseExpression caseExpression) {
buffer.append("CASE ");
Expand Down Expand Up @@ -426,12 +431,27 @@ public void visit(AllComparisonExpression allComparisonExpression) {
allComparisonExpression.getSubSelect().accept((ExpressionVisitor) this);
}

@Override
public void visit(AllArrayExpression allArrayExpression) {
buffer.append("ALL (");
allArrayExpression.getArray().accept((ExpressionVisitor) this);
buffer.append(")");
}

@Override
public void visit(AnyComparisonExpression anyComparisonExpression) {
buffer.append(anyComparisonExpression.getAnyType().name()).append(" ");
anyComparisonExpression.getSubSelect().accept((ExpressionVisitor) this);
}

@Override
public void visit(AnyArrayExpression anyArrayExpression) {

buffer.append("ANY (");
anyArrayExpression.getArray().accept((ExpressionVisitor) this);
buffer.append(")");
}

@Override
public void visit(Concat concat) {
visitBinaryExpression(concat, " || ");
Expand Down
Loading