Skip to content

Commit

Permalink
a little cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed Oct 24, 2013
1 parent 7a737e7 commit bdc8193
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@

public interface SupportsOldOracleJoinSyntax {

static final int NO_ORACLE_JOIN = 0;
static final int ORACLE_JOIN_RIGHT = 1;
static final int ORACLE_JOIN_LEFT = 2;
final int NO_ORACLE_JOIN = 0;
final int ORACLE_JOIN_RIGHT = 1;
final int ORACLE_JOIN_LEFT = 2;

int getOldOracleJoinSyntax();

void setOldOracleJoinSyntax(int oldOracleJoinSyntax);
static final int NO_ORACLE_PRIOR = 0;
static final int ORACLE_PRIOR_START = 1;
static final int ORACLE_PRIOR_END = 2;

final int NO_ORACLE_PRIOR = 0;
final int ORACLE_PRIOR_START = 1;
final int ORACLE_PRIOR_END = 2;

int getOraclePriorPosition();

void setOraclePriorPosition(int priorPosition);
}
83 changes: 42 additions & 41 deletions src/main/java/net/sf/jsqlparser/util/deparser/SelectDeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class SelectDeParser implements SelectVisitor, OrderByVisitor, SelectItemVisitor, FromItemVisitor, PivotVisitor {

private StringBuilder buffer;
private ExpressionVisitor expressionVisitor;
private ExpressionVisitor expressionVisitor;

public SelectDeParser() {
}
Expand Down Expand Up @@ -90,15 +90,15 @@ public void visit(PlainSelect plainSelect) {
}

if (plainSelect.getJoins() != null) {
for (Join join : plainSelect.getJoins()) {
deparseJoin(join);
}
for (Join join : plainSelect.getJoins()) {
deparseJoin(join);
}
}

if (plainSelect.getOracleHierarchical() != null) {
plainSelect.getOracleHierarchical().accept(expressionVisitor);
}

if (plainSelect.getWhere() != null) {
buffer.append(" WHERE ");
plainSelect.getWhere().accept(expressionVisitor);
Expand Down Expand Up @@ -175,55 +175,56 @@ public void visit(SubSelect subSelect) {
@Override
public void visit(Table tableName) {
buffer.append(tableName.getWholeTableName());
Pivot pivot = tableName.getPivot();
if (pivot != null) {
pivot.accept(this);
}
Pivot pivot = tableName.getPivot();
if (pivot != null) {
pivot.accept(this);
}
String alias = tableName.getAlias();
if (alias != null && !alias.isEmpty()) {
buffer.append(" AS ").append(alias);
}
}

@Override
public void visit(Pivot pivot) {
List<Column> forColumns = pivot.getForColumns();
buffer.append(" PIVOT (")
.append(PlainSelect.getStringList(pivot.getFunctionItems()))
.append(" FOR ")
.append(PlainSelect.getStringList(forColumns, true, forColumns != null && forColumns.size() > 1))
.append(" IN ")
.append(PlainSelect.getStringList(pivot.getInItems(), true, true))
.append(")");
}

@Override
public void visit(PivotXml pivot) {
List<Column> forColumns = pivot.getForColumns();
buffer.append(" PIVOT XML (")
.append(PlainSelect.getStringList(pivot.getFunctionItems()))
.append(" FOR ")
.append(PlainSelect.getStringList(forColumns, true, forColumns != null && forColumns.size() > 1))
.append(" IN (");
if (pivot.isInAny()) {
buffer.append("ANY");
} else if (pivot.getInSelect() != null) {
buffer.append(pivot.getInSelect());
} else {
buffer.append(PlainSelect.getStringList(pivot.getInItems()));
}
buffer.append("))");
}
@Override
public void visit(Pivot pivot) {
List<Column> forColumns = pivot.getForColumns();
buffer.append(" PIVOT (")
.append(PlainSelect.getStringList(pivot.getFunctionItems()))
.append(" FOR ")
.append(PlainSelect.getStringList(forColumns, true, forColumns != null && forColumns.size() > 1))
.append(" IN ")
.append(PlainSelect.getStringList(pivot.getInItems(), true, true))
.append(")");
}

@Override
public void visit(PivotXml pivot) {
List<Column> forColumns = pivot.getForColumns();
buffer.append(" PIVOT XML (")
.append(PlainSelect.getStringList(pivot.getFunctionItems()))
.append(" FOR ")
.append(PlainSelect.getStringList(forColumns, true, forColumns != null && forColumns.size() > 1))
.append(" IN (");
if (pivot.isInAny()) {
buffer.append("ANY");
} else if (pivot.getInSelect() != null) {
buffer.append(pivot.getInSelect());
} else {
buffer.append(PlainSelect.getStringList(pivot.getInItems()));
}
buffer.append("))");
}

public void deparseOrderBy(List<OrderByElement> orderByElements) {
deparseOrderBy(false, orderByElements);
}

public void deparseOrderBy(boolean oracleSiblings, List<OrderByElement> orderByElements) {
if (oracleSiblings)
if (oracleSiblings) {
buffer.append(" ORDER SIBLINGS BY ");
else
} else {
buffer.append(" ORDER BY ");
}
for (Iterator<OrderByElement> iter = orderByElements.iterator(); iter.hasNext();) {
OrderByElement orderByElement = iter.next();
orderByElement.accept(this);
Expand Down

0 comments on commit bdc8193

Please sign in to comment.