Search in sources :

Example 1 with CastExpression

use of org.eclipse.persistence.jpa.jpql.parser.CastExpression in project eclipselink by eclipse-ee4j.

the class EclipseLinkContentAssistVisitor method visit.

@Override
public void visit(CastExpression expression) {
    super.visit(expression);
    int position = queryPosition.getPosition(expression) - corrections.peek();
    String identifier = expression.getIdentifier();
    // Within CAST
    if (isPositionWithin(position, identifier)) {
        addIdentifier(identifier);
        addIdentificationVariables();
        addFunctionIdentifiers(expression.getParent().findQueryBNF(expression));
    } else // After "CAST("
    if (expression.hasLeftParenthesis()) {
        int length = identifier.length() + 1;
        // Right after "CAST("
        if (position == length) {
            addIdentificationVariables();
            addFunctionIdentifiers(expression.getEncapsulatedExpressionQueryBNFId());
        } else if (expression.hasExpression()) {
            Expression scalarExpression = expression.getExpression();
            if (isComplete(scalarExpression)) {
                length += scalarExpression.getLength();
                if (expression.hasSpaceAfterExpression()) {
                    length++;
                    // Right before "AS" or database type
                    if (position == length) {
                        addAggregateIdentifiers(expression.getEncapsulatedExpressionQueryBNFId());
                        proposals.addIdentifier(AS);
                    } else // Within "AS"
                    if (isPositionWithin(position, length, AS)) {
                        proposals.addIdentifier(AS);
                    }
                }
            }
        }
    }
}
Also used : CastExpression(org.eclipse.persistence.jpa.jpql.parser.CastExpression) Expression(org.eclipse.persistence.jpa.jpql.parser.Expression) TableExpression(org.eclipse.persistence.jpa.jpql.parser.TableExpression) AbstractPathExpression(org.eclipse.persistence.jpa.jpql.parser.AbstractPathExpression) ExtractExpression(org.eclipse.persistence.jpa.jpql.parser.ExtractExpression) CollectionExpression(org.eclipse.persistence.jpa.jpql.parser.CollectionExpression) RegexpExpression(org.eclipse.persistence.jpa.jpql.parser.RegexpExpression)

Example 2 with CastExpression

use of org.eclipse.persistence.jpa.jpql.parser.CastExpression in project eclipselink by eclipse-ee4j.

the class ReportItemBuilder method visit.

@Override
public void visit(CastExpression expression) {
    Expression queryExpression = queryContext.buildExpression(expression, type);
    addAttribute(ExpressionTools.EMPTY_STRING, queryExpression, type[0]);
}
Also used : TrimExpression(org.eclipse.persistence.jpa.jpql.parser.TrimExpression) AbsExpression(org.eclipse.persistence.jpa.jpql.parser.AbsExpression) ValueExpression(org.eclipse.persistence.jpa.jpql.parser.ValueExpression) CoalesceExpression(org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression) ConcatExpression(org.eclipse.persistence.jpa.jpql.parser.ConcatExpression) SubstringExpression(org.eclipse.persistence.jpa.jpql.parser.SubstringExpression) SizeExpression(org.eclipse.persistence.jpa.jpql.parser.SizeExpression) CastExpression(org.eclipse.persistence.jpa.jpql.parser.CastExpression) SqrtExpression(org.eclipse.persistence.jpa.jpql.parser.SqrtExpression) SubExpression(org.eclipse.persistence.jpa.jpql.parser.SubExpression) FunctionExpression(org.eclipse.persistence.jpa.jpql.parser.FunctionExpression) ExtractExpression(org.eclipse.persistence.jpa.jpql.parser.ExtractExpression) ConstructorExpression(org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression) NullIfExpression(org.eclipse.persistence.jpa.jpql.parser.NullIfExpression) IndexExpression(org.eclipse.persistence.jpa.jpql.parser.IndexExpression) CollectionValuedPathExpression(org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpression) LocateExpression(org.eclipse.persistence.jpa.jpql.parser.LocateExpression) StateFieldPathExpression(org.eclipse.persistence.jpa.jpql.parser.StateFieldPathExpression) UpperExpression(org.eclipse.persistence.jpa.jpql.parser.UpperExpression) AdditionExpression(org.eclipse.persistence.jpa.jpql.parser.AdditionExpression) ObjectExpression(org.eclipse.persistence.jpa.jpql.parser.ObjectExpression) CollectionExpression(org.eclipse.persistence.jpa.jpql.parser.CollectionExpression) KeyExpression(org.eclipse.persistence.jpa.jpql.parser.KeyExpression) LowerExpression(org.eclipse.persistence.jpa.jpql.parser.LowerExpression) TreatExpression(org.eclipse.persistence.jpa.jpql.parser.TreatExpression) ModExpression(org.eclipse.persistence.jpa.jpql.parser.ModExpression) TypeExpression(org.eclipse.persistence.jpa.jpql.parser.TypeExpression) Expression(org.eclipse.persistence.expressions.Expression) SubtractionExpression(org.eclipse.persistence.jpa.jpql.parser.SubtractionExpression) EntryExpression(org.eclipse.persistence.jpa.jpql.parser.EntryExpression) CaseExpression(org.eclipse.persistence.jpa.jpql.parser.CaseExpression) LengthExpression(org.eclipse.persistence.jpa.jpql.parser.LengthExpression) MultiplicationExpression(org.eclipse.persistence.jpa.jpql.parser.MultiplicationExpression) DivisionExpression(org.eclipse.persistence.jpa.jpql.parser.DivisionExpression) KeywordExpression(org.eclipse.persistence.jpa.jpql.parser.KeywordExpression)

Aggregations

CastExpression (org.eclipse.persistence.jpa.jpql.parser.CastExpression)2 CollectionExpression (org.eclipse.persistence.jpa.jpql.parser.CollectionExpression)2 ExtractExpression (org.eclipse.persistence.jpa.jpql.parser.ExtractExpression)2 Expression (org.eclipse.persistence.expressions.Expression)1 AbsExpression (org.eclipse.persistence.jpa.jpql.parser.AbsExpression)1 AbstractPathExpression (org.eclipse.persistence.jpa.jpql.parser.AbstractPathExpression)1 AdditionExpression (org.eclipse.persistence.jpa.jpql.parser.AdditionExpression)1 CaseExpression (org.eclipse.persistence.jpa.jpql.parser.CaseExpression)1 CoalesceExpression (org.eclipse.persistence.jpa.jpql.parser.CoalesceExpression)1 CollectionValuedPathExpression (org.eclipse.persistence.jpa.jpql.parser.CollectionValuedPathExpression)1 ConcatExpression (org.eclipse.persistence.jpa.jpql.parser.ConcatExpression)1 ConstructorExpression (org.eclipse.persistence.jpa.jpql.parser.ConstructorExpression)1 DivisionExpression (org.eclipse.persistence.jpa.jpql.parser.DivisionExpression)1 EntryExpression (org.eclipse.persistence.jpa.jpql.parser.EntryExpression)1 Expression (org.eclipse.persistence.jpa.jpql.parser.Expression)1 FunctionExpression (org.eclipse.persistence.jpa.jpql.parser.FunctionExpression)1 IndexExpression (org.eclipse.persistence.jpa.jpql.parser.IndexExpression)1 KeyExpression (org.eclipse.persistence.jpa.jpql.parser.KeyExpression)1 KeywordExpression (org.eclipse.persistence.jpa.jpql.parser.KeywordExpression)1 LengthExpression (org.eclipse.persistence.jpa.jpql.parser.LengthExpression)1