@Override public void processMemberOf(Token n, AST p, ASTPair currentAST) { // convert MEMBER OF to the equivalent IN ELEMENTS structure... AST inNode = n == null ? astFactory.create( IN, "in" ) : astFactory.create( NOT_IN, "not in" ); astFactory.makeASTRoot( currentAST, inNode ); AST inListNode = astFactory.create( IN_LIST, "inList" ); inNode.addChild( inListNode ); AST elementsNode = astFactory.create( ELEMENTS, "elements" ); inListNode.addChild( elementsNode ); elementsNode.addChild( p ); }
private SortSpecification createSortSpecification( AST ident, CollationSpecification collationSpecification, OrderingSpecification orderingSpecification) { AST sortSpecification = getASTFactory().create( SORT_SPEC, "{{sort specification}}" ); AST sortKey = getASTFactory().create( SORT_KEY, "{{sort key}}" ); AST newIdent = getASTFactory().create( ident.getType(), ident.getText() ); sortKey.setFirstChild( newIdent ); sortSpecification.setFirstChild( sortKey ); if ( collationSpecification != null ) { sortSpecification.addChild( collationSpecification ); } if ( orderingSpecification != null ) { sortSpecification.addChild( orderingSpecification ); } return (SortSpecification) sortSpecification; }
private AST generateSyntheticDotNodeForNonQualifiedPropertyRef(AST property, FromElement fromElement) { AST dot = getASTFactory().create( DOT, "{non-qualified-property-ref}" ); // TODO : better way?!? ( (DotNode) dot ).setPropertyPath( ( (FromReferenceNode) property ).getPath() ); IdentNode syntheticAlias = (IdentNode) getASTFactory().create( IDENT, "{synthetic-alias}" ); syntheticAlias.setFromElement( fromElement ); syntheticAlias.setResolved(); dot.setFirstChild( syntheticAlias ); dot.addChild( property ); return dot; }
AST currentFirstChild = statement.getWhereClause().getFirstChild(); and.setFirstChild( discrimNode ); and.addChild( currentFirstChild ); statement.getWhereClause().setFirstChild( and );
@Override protected AST resolveIdent(AST ident) { /* * Semantic action used during recognition of an identifier. This identifier might be a column name, it might * be a property name. */ String text = ident.getText(); SqlValueReference[] sqlValueReferences; try { sqlValueReferences = context.getColumnMapper().map( text ); } catch (Throwable t) { sqlValueReferences = null; } if ( sqlValueReferences == null || sqlValueReferences.length == 0 ) { return getASTFactory().create( OrderByTemplateTokenTypes.IDENT, makeColumnReference( text ) ); } else if ( sqlValueReferences.length == 1 ) { return processSqlValueReference( sqlValueReferences[0] ); } else { final AST root = getASTFactory().create( OrderByTemplateTokenTypes.IDENT_LIST, "{ident list}" ); for ( SqlValueReference sqlValueReference : sqlValueReferences ) { root.addChild( processSqlValueReference( sqlValueReference ) ); } return root; } }
@Override protected AST postProcessSortSpecification(AST sortSpec) { assert SORT_SPEC == sortSpec.getType(); SortSpecification sortSpecification = (SortSpecification) sortSpec; AST sortKey = sortSpecification.getSortKey(); if ( IDENT_LIST == sortKey.getFirstChild().getType() ) { AST identList = sortKey.getFirstChild(); AST ident = identList.getFirstChild(); AST holder = new CommonAST(); do { holder.addChild( createSortSpecification( ident, sortSpecification.getCollation(), sortSpecification.getOrdering() ) ); ident = ident.getNextSibling(); } while ( ident != null ); sortSpec = holder.getFirstChild(); } return sortSpec; }
AST fromElement = inputAstFactory.create( HqlTokenTypes.FILTER_ENTITY, collectionElementEntityName ); ASTUtil.createSibling( inputAstFactory, HqlTokenTypes.ALIAS, "this", fromElement ); fromClauseInput.addChild( fromElement );
AST castExprListNode = getASTFactory().create( HqlSqlTokenTypes.EXPR_LIST, "exprList" ); methodIdentNode.setNextSibling( castExprListNode ); castExprListNode.addChild( versionValueNode ); versionValueNode.setNextSibling( getASTFactory().create(
v_AST.addChild(s6_AST);
v_AST.addChild(s6_AST);
v_AST.addChild(s6_AST);
private AST parseEqFragmentToSubtree(String whereFragment) { int chunkPos = whereFragment.lastIndexOf( "=" ); String check = whereFragment.substring( 0, chunkPos ).trim(); String test = whereFragment.substring( chunkPos + 1 ).trim(); AST eq = astFactory.create( EQ, "{discriminator}" ); eq.setFirstChild( astFactory.create( IDENT, check ) ); eq.addChild( astFactory.create( SQL_TOKEN, test ) ); return eq; } }
@Override public void processMemberOf(Token n, AST p, ASTPair currentAST) { AST inAst = n == null ? astFactory.create( IN, "in" ) : astFactory.create( NOT_IN, "not in" ); astFactory.makeASTRoot( currentAST, inAst ); AST ast = createSubquery( p ); ast = ASTUtil.createParent( astFactory, IN_LIST, "inList", ast ); inAst.addChild( ast ); }
@Override public void processMemberOf(Token n, AST p, ASTPair currentAST) { AST inAst = n == null ? astFactory.create( IN, "in" ) : astFactory.create( NOT_IN, "not in" ); astFactory.makeASTRoot( currentAST, inAst ); AST ast = createSubquery( p ); ast = ASTUtil.createParent( astFactory, IN_LIST, "inList", ast ); inAst.addChild( ast ); }
public void processMemberOf(Token n, AST p, ASTPair currentAST) { AST inAst = n == null ? astFactory.create( IN, "in" ) : astFactory.create( NOT_IN, "not in" ); astFactory.makeASTRoot( currentAST, inAst ); AST ast = createSubquery( p ); ast = ASTUtil.createParent( astFactory, IN_LIST, "inList", ast ); inAst.addChild( ast ); }
public void processMemberOf(Token n, AST p, ASTPair currentAST) { AST inAst = n == null ? astFactory.create( IN, "in" ) : astFactory.create( NOT_IN, "not in" ); astFactory.makeASTRoot( currentAST, inAst ); AST ast = createSubquery( p ); ast = ASTUtil.createParent( astFactory, IN_LIST, "inList", ast ); inAst.addChild( ast ); }
private AST generateSyntheticDotNodeForNonQualifiedPropertyRef(AST property, FromElement fromElement) { AST dot = getASTFactory().create( DOT, "{non-qualified-property-ref}" ); // TODO : better way?!? ( ( DotNode ) dot ).setPropertyPath( ( ( FromReferenceNode ) property ).getPath() ); IdentNode syntheticAlias = ( IdentNode ) getASTFactory().create( IDENT, "{synthetic-alias}" ); syntheticAlias.setFromElement( fromElement ); syntheticAlias.setResolved(); dot.setFirstChild( syntheticAlias ); dot.addChild( property ); return dot; }
private AST generateSyntheticDotNodeForNonQualifiedPropertyRef(AST property, FromElement fromElement) { AST dot = getASTFactory().create( DOT, "{non-qualified-property-ref}" ); // TODO : better way?!? ( ( DotNode ) dot ).setPropertyPath( ( ( FromReferenceNode ) property ).getPath() ); IdentNode syntheticAlias = ( IdentNode ) getASTFactory().create( IDENT, "{synthetic-alias}" ); syntheticAlias.setFromElement( fromElement ); syntheticAlias.setResolved(); dot.setFirstChild( syntheticAlias ); dot.addChild( property ); return dot; }