| | -package com.whitemagicsoftware.rxm.tree.xml; |
| | - |
| | -import com.whitemagicsoftware.rxm.tree.Payload; |
| | -import com.whitemagicsoftware.rxm.tree.Tree; |
| | -import com.whitemagicsoftware.rxm.tree.TransformationTree; |
| | - |
| | -import org.antlr.v4.runtime.ParserRuleContext; |
| | -import org.antlr.v4.runtime.Token; |
| | - |
| | -/** |
| | - * <p> |
| | - * Stores a list of Payload instances. This is instantiated by the parser |
| | - * to create a transformation list capable of generating SQL/XML JOIN |
| | - * clauses. The payload dynamically determines the set of wrapper classes |
| | - * using the package for name of class. |
| | - * </p> |
| | - * <p> |
| | - * The tree is being re-used as a list. (A list is simply a tree with |
| | - * one branch and many siblings.) |
| | - * </p> |
| | - */ |
| | -public class JoinClauseList<T extends Payload> extends TransformationTree<T> { |
| | - /** |
| | - * Constructs a list capable of transforming itself into a SQL/XML |
| | - * FROM clause. |
| | - * |
| | - * @param payload The data associated with this list (must not be null). |
| | - */ |
| | - public JoinClauseList( T payload ) { |
| | - super( payload ); |
| | - } |
| | - |
| | - /** |
| | - * Converts the list of <b>rxm</b> JOIN expressions into an equivalent SQL |
| | - * FROM clause. |
| | - */ |
| | - @SuppressWarnings( "unchecked" ) |
| | - public String toString() { |
| | - StringBuilder sb = createBuffer(); |
| | - final String NL = getNewline(); |
| | - |
| | - // Separate the JOIN statements from each other. |
| | - String separateStart = beautify() ? NL + getDefaultIndent() : " "; |
| | - String separateStop = beautify() ? NL : " "; |
| | - |
| | - for( Tree<T> branch : getBranches() ) { |
| | - Payload payload = branch.getPayload(); |
| | - |
| | - // Payload must be able to find the appropriate subclass to instantiate |
| | - // based on its tree instance's package. See the getStart and getStop |
| | - // methods in the Payload class for details. |
| | - payload.setTree( (Tree<Payload>)this ); |
| | - |
| | - sb.append( payload.getStart() ).append( separateStart ); |
| | - sb.append( payload.getStop() ).append( separateStop ); |
| | - } |
| | - |
| | - return sb.toString(); |
| | - } |
| | - |
| | - /** |
| | - * Called when entering a new hierarchy in the transformation tree. |
| | - * |
| | - * @param tree Unused. |
| | - * @return Empty string. |
| | - */ |
| | - protected String start( Tree<T> tree ) { |
| | - return ""; |
| | - } |
| | - |
| | - /** |
| | - * Called when exiting a new hierarchy in the transformation tree. |
| | - * |
| | - * @param tree Unused. |
| | - * @return Empty string. |
| | - */ |
| | - protected String stop( Tree<T> tree ) { |
| | - return ""; |
| | - } |
| | -} |
| | - |
| | |