Skip to content

Commit 55f42ea

Browse files
author
Jonathan Burnhams
committed
Add support old oracle join syntax to more expressions (simple comparisons and IN)
1 parent 99b46bf commit 55f42ea

File tree

13 files changed

+146
-103
lines changed

13 files changed

+146
-103
lines changed

src/main/java/net/sf/jsqlparser/expression/operators/relational/EqualsTo.java

100644100755
Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class EqualsTo extends BinaryExpression {
26+
public class EqualsTo extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {
@@ -35,24 +34,4 @@ public void accept(ExpressionVisitor expressionVisitor) {
3534
public String getStringExpression() {
3635
return "=";
3736
}
38-
public static final int NO_ORACLE_JOIN = 0;
39-
public static final int ORACLE_JOIN_RIGHT = 1;
40-
public static final int ORACLE_JOIN_LEFT = 2;
41-
private int oldOracleJoinSyntax = NO_ORACLE_JOIN;
42-
43-
public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) {
44-
this.oldOracleJoinSyntax = oldOracleJoinSyntax;
45-
if (oldOracleJoinSyntax < 0 || oldOracleJoinSyntax > 2) {
46-
throw new IllegalArgumentException("unknown join type for oracle found (type=" + oldOracleJoinSyntax + ")");
47-
}
48-
}
49-
50-
@Override
51-
public String toString() {
52-
return (isNot() ? "NOT " : "") + getLeftExpression() + (oldOracleJoinSyntax == ORACLE_JOIN_RIGHT ? "(+)" : "") + " " + getStringExpression() + " " + getRightExpression() + (oldOracleJoinSyntax == ORACLE_JOIN_LEFT ? "(+)" : "");
53-
}
54-
55-
public int getOldOracleJoinSyntax() {
56-
return oldOracleJoinSyntax;
57-
}
5837
}

src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThan.java

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class GreaterThan extends BinaryExpression {
26+
public class GreaterThan extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {

src/main/java/net/sf/jsqlparser/expression/operators/relational/GreaterThanEquals.java

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class GreaterThanEquals extends BinaryExpression {
26+
public class GreaterThanEquals extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {

src/main/java/net/sf/jsqlparser/expression/operators/relational/InExpression.java

100644100755
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
import net.sf.jsqlparser.expression.Expression;
2525
import net.sf.jsqlparser.expression.ExpressionVisitor;
2626

27-
public class InExpression implements Expression {
27+
public class InExpression implements Expression, SupportsOldOracleJoinSyntax {
2828

2929
private Expression leftExpression;
3030
private ItemsList leftItemsList;
3131
private ItemsList rightItemsList;
3232
private boolean not = false;
3333

34+
private int oldOracleJoinSyntax = NO_ORACLE_JOIN;
35+
3436
public InExpression() {
3537
}
3638

@@ -39,6 +41,17 @@ public InExpression(Expression leftExpression, ItemsList itemsList) {
3941
setRightItemsList(itemsList);
4042
}
4143

44+
public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) {
45+
this.oldOracleJoinSyntax = oldOracleJoinSyntax;
46+
if (oldOracleJoinSyntax < 0 || oldOracleJoinSyntax > 1) {
47+
throw new IllegalArgumentException("unexpected join type for oracle found with IN (type=" + oldOracleJoinSyntax + ")");
48+
}
49+
}
50+
51+
public int getOldOracleJoinSyntax() {
52+
return oldOracleJoinSyntax;
53+
}
54+
4255
public ItemsList getRightItemsList() {
4356
return rightItemsList;
4457
}
@@ -76,8 +89,12 @@ public void accept(ExpressionVisitor expressionVisitor) {
7689
expressionVisitor.visit(this);
7790
}
7891

92+
private String getLeftExpressionString() {
93+
return leftExpression + (oldOracleJoinSyntax == ORACLE_JOIN_RIGHT ? "(+)" : "");
94+
}
95+
7996
@Override
8097
public String toString() {
81-
return (leftExpression == null ? leftItemsList : leftExpression) + " " + ((not) ? "NOT " : "") + "IN " + rightItemsList + "";
98+
return (leftExpression == null ? leftItemsList : getLeftExpressionString()) + " " + ((not) ? "NOT " : "") + "IN " + rightItemsList + "";
8299
}
83100
}

src/main/java/net/sf/jsqlparser/expression/operators/relational/Matches.java

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class Matches extends BinaryExpression {
26+
public class Matches extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {

src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThan.java

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class MinorThan extends BinaryExpression {
26+
public class MinorThan extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {

src/main/java/net/sf/jsqlparser/expression/operators/relational/MinorThanEquals.java

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class MinorThanEquals extends BinaryExpression {
26+
public class MinorThanEquals extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {

src/main/java/net/sf/jsqlparser/expression/operators/relational/NotEqualsTo.java

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
*/
2222
package net.sf.jsqlparser.expression.operators.relational;
2323

24-
import net.sf.jsqlparser.expression.BinaryExpression;
2524
import net.sf.jsqlparser.expression.ExpressionVisitor;
2625

27-
public class NotEqualsTo extends BinaryExpression {
26+
public class NotEqualsTo extends OldOracleJoinBinaryExpression {
2827

2928
@Override
3029
public void accept(ExpressionVisitor expressionVisitor) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2013 JSQLParser
6+
* %%
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation, either version 2.1 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Lesser Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Lesser Public
18+
* License along with this program. If not, see
19+
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
20+
* #L%
21+
*/
22+
package net.sf.jsqlparser.expression.operators.relational;
23+
24+
import net.sf.jsqlparser.expression.BinaryExpression;
25+
26+
public abstract class OldOracleJoinBinaryExpression extends BinaryExpression implements SupportsOldOracleJoinSyntax {
27+
28+
private int oldOracleJoinSyntax = NO_ORACLE_JOIN;
29+
30+
public void setOldOracleJoinSyntax(int oldOracleJoinSyntax) {
31+
this.oldOracleJoinSyntax = oldOracleJoinSyntax;
32+
if (oldOracleJoinSyntax < 0 || oldOracleJoinSyntax > 2) {
33+
throw new IllegalArgumentException("unknown join type for oracle found (type=" + oldOracleJoinSyntax + ")");
34+
}
35+
}
36+
37+
@Override
38+
public String toString() {
39+
return (isNot() ? "NOT " : "") + getLeftExpression() + (oldOracleJoinSyntax == ORACLE_JOIN_RIGHT ? "(+)" : "") + " " + getStringExpression() + " " + getRightExpression() + (oldOracleJoinSyntax == ORACLE_JOIN_LEFT ? "(+)" : "");
40+
}
41+
42+
public int getOldOracleJoinSyntax() {
43+
return oldOracleJoinSyntax;
44+
}
45+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2013 JSQLParser
6+
* %%
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation, either version 2.1 of the
10+
* License, or (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Lesser Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Lesser Public
18+
* License along with this program. If not, see
19+
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
20+
* #L%
21+
*/
22+
package net.sf.jsqlparser.expression.operators.relational;
23+
24+
public interface SupportsOldOracleJoinSyntax {
25+
public static final int NO_ORACLE_JOIN = 0;
26+
public static final int ORACLE_JOIN_RIGHT = 1;
27+
public static final int ORACLE_JOIN_LEFT = 2;
28+
29+
public int getOldOracleJoinSyntax();
30+
31+
public void setOldOracleJoinSyntax(int oldOracleJoinSyntax);
32+
}

0 commit comments

Comments
 (0)