@Override public final C visit(QueryPart part) { if (part != null) { // Issue start clause events // ----------------------------------------------------------------- Clause[] clauses = visitListeners.length > 0 ? clause(part) : null; if (clauses != null) for (int i = 0; i < clauses.length; i++) start(clauses[i]); // Perform the actual visiting, or recurse into the replacement // ----------------------------------------------------------------- QueryPart original = part; QueryPart replacement = start(part); if (original == replacement) visit0(original); else visit0(replacement); end(replacement); // Issue end clause events // ----------------------------------------------------------------- if (clauses != null) for (int i = clauses.length - 1; i >= 0; i--) end(clauses[i]); } return (C) this; }
@Override public final C declareFields(boolean d) { this.declareFields = d; declareAliases(d); return (C) this; }
if (declareFields() && !internal.declaresFields()) { boolean aliases = declareAliases(); declareFields(false); visit0(internal); declareFields(true); declareAliases(aliases); else if (declareTables() && !internal.declaresTables()) { boolean aliases = declareAliases(); declareTables(false); visit0(internal); declareTables(true); declareAliases(aliases); else if (declareWindows() && !internal.declaresWindows()) { declareWindows(false); visit0(internal); declareWindows(true); else if (declareCTE() && !internal.declaresCTE()) { declareCTE(false); visit0(internal); declareCTE(true); else if (!castModeOverride && castMode() != CastMode.DEFAULT && !internal.generatesCast()) { CastMode previous = castMode(); castMode(CastMode.DEFAULT); visit0(internal);
private final C visit0(QueryPart part) { if (part != null) { QueryPartInternal internal = (QueryPartInternal) part; // If this is supposed to be a declaration section and the part isn't // able to declare anything, then disable declaration temporarily // We're declaring fields, but "part" does not declare fields if (declareFields() && !internal.declaresFields()) { declareFields(false); visit0(internal); declareFields(true); } // We're declaring tables, but "part" does not declare tables else if (declareTables() && !internal.declaresTables()) { declareTables(false); visit0(internal); declareTables(true); } // We're declaring windows, but "part" does not declare windows else if (declareWindows() && !internal.declaresWindows()) { declareWindows(false); visit0(internal); declareWindows(true); } // We're not declaring, or "part" can declare else { visit0(internal); } } return (C) this; }
@Override public final C subquery(boolean s) { if (s) { subquery++; // [#7222] If present the nested set operations flag needs to be reset whenever we're // entering a subquery (and restored when leaving it). // [#2791] This works differently from the scope marking mechanism, which wraps a // [#7152] naming scope for aliases and other object names. if (TRUE.equals(data(DATA_NESTED_SET_OPERATIONS))) { data().remove(DATA_NESTED_SET_OPERATIONS); if (subqueryScopedNestedSetOperations == null) subqueryScopedNestedSetOperations = new BitSet(); subqueryScopedNestedSetOperations.set(subquery); } } else { if (subqueryScopedNestedSetOperations != null && subqueryScopedNestedSetOperations.get(subquery)) data(DATA_NESTED_SET_OPERATIONS, true); else data().remove(DATA_NESTED_SET_OPERATIONS); subquery--; } return (C) this; }
/** * Emit a clause from a query part being visited. * <p> * This method returns a clause to emit as a surrounding event before / * after visiting a query part. This is needed for all reusable query parts, * whose clause type is ambiguous at the container site. An example: * <p> * <code><pre>SELECT * FROM [A CROSS JOIN B]</pre></code> * <p> * The type of the above <code>JoinTable</code> modelling * <code>A CROSS JOIN B</code> is not known to the surrounding * <code>SELECT</code> statement, which only knows {@link Table} types. The * {@link Clause#TABLE_JOIN} event that is required to be emitted around the * {@link Context#visit(QueryPart)} event has to be issued here in * <code>AbstractContext</code>. */ private final Clause[] clause(QueryPart part) { if (part instanceof QueryPartInternal && data(DATA_OMIT_CLAUSE_EVENT_EMISSION) == null) return ((QueryPartInternal) part).clauses(this); return null; }
@Override public final C visit(QueryPart part) { if (part != null) { // Issue start clause events // ----------------------------------------------------------------- Clause[] clauses = Tools.isNotEmpty(visitListeners) ? clause(part) : null; if (clauses != null) for (int i = 0; i < clauses.length; i++) start(clauses[i]); // Perform the actual visiting, or recurse into the replacement // ----------------------------------------------------------------- QueryPart original = part; QueryPart replacement = start(part); if (original == replacement) visit0(original); else visit0(replacement); end(replacement); // Issue end clause events // ----------------------------------------------------------------- if (clauses != null) for (int i = clauses.length - 1; i >= 0; i--) end(clauses[i]); } return (C) this; }
/** * Emit a clause from a query part being visited. * <p> * This method returns a clause to emit as a surrounding event before / * after visiting a query part. This is needed for all reusable query parts, * whose clause type is ambiguous at the container site. An example: * <p> * <code><pre>SELECT * FROM [A CROSS JOIN B]</pre></code> * <p> * The type of the above <code>JoinTable</code> modelling * <code>A CROSS JOIN B</code> is not known to the surrounding * <code>SELECT</code> statement, which only knows {@link Table} types. The * {@link Clause#TABLE_JOIN} event that is required to be emitted around the * {@link Context#visit(QueryPart)} event has to be issued here in * <code>AbstractContext</code>. */ private final Clause[] clause(QueryPart part) { if (part instanceof QueryPartInternal && data(DATA_OMIT_CLAUSE_EVENT_EMISSION) == null) { return ((QueryPartInternal) part).clauses(this); } return null; }
@Override public final C declareTables(boolean d) { this.declareTables = d; declareAliases(d); return (C) this; }