/** * {@inheritDoc} */ @Override protected final void addChildrenTo(Collection<Expression> children) { children.add(getExpression()); }
/** * Returns the {@link Expression} that is encapsulated within parenthesis. * * @return The {@link Expression} that is encapsulated within parenthesis */ public final Expression getExpression() { if (expression == null) { expression = buildNullExpression(); } return expression; }
/** * Determines whether the encapsulated expression is valid. * * @param expression The {@link AbstractSingleEncapsulatedExpression} being validated * @return <code>true</code> if the encapsulated expression is valid; <code>false</code> * otherwise */ protected boolean isEncapsulatedExpressionValid(T expression) { return validator.isValid(expression.getExpression(), expression.getEncapsulatedExpressionQueryBNFId()); }
/** * {@inheritDoc} */ @Override protected void parseEncapsulatedExpression(WordParser wordParser, int whitespaceCount, boolean tolerant) { expression = parse(wordParser, getEncapsulatedExpressionQueryBNFId(), tolerant); }
/** * {@inheritDoc} */ public boolean hasRightParenthesis(T expression) { // If the encapsulated expression is missing, then no need to // add a problem for a missing ')' because the encapsulated // expression needs to be specified first return !expression.hasEncapsulatedExpression() || expression.hasRightParenthesis(); }
protected void visitAbstractSingleEncapsulatedExpression(AbstractSingleEncapsulatedExpression expression) { if (badExpression) { if (positionWithinInvalidExpression <= expression.getIdentifier().length()) { queryPosition.setExpression(expression); queryPosition.addPosition(expression, positionWithinInvalidExpression); } } else { if (expression.hasEncapsulatedExpression() && !expression.hasRightParenthesis()) { expression.getExpression().accept(this); } if (queryPosition.getExpression() == null) { queryPosition.setExpression(expression); } queryPosition.addPosition(expression, expression.getLength() - correction); } }
String actualIdentifier = expression.getIdentifier(); boolean added = false; else if (expression.hasLeftParenthesis()) { int length = identifier.length() + 1 /* '(' */; String queryBNF = expression.getEncapsulatedExpressionQueryBNFId(); addFunctionIdentifiers(queryBNF); addClauseIdentifiers(queryBNF);
/** * Validates the given {@link AbstractSingleEncapsulatedExpression}'s encapsulated expression if * it is a state field path expression and makes sure it is mapping to a basic mapping. That * means relationship field mapping is not allowed. * * @param expression The {@link AbstractSingleEncapsulatedExpression} to validate its encapsulated * expression if it's a state field path expression, otherwise does nothing * @return <code>false</code> if the encapsulated expression was validated and is invalid; * <code>true</code> otherwise */ protected boolean validateFunctionPathExpression(AbstractSingleEncapsulatedExpression expression) { boolean valid = true; if (expression.hasEncapsulatedExpression()) { Expression encapsulatedExpression = expression.getExpression(); // Special case for state field path expression, association field is not allowed StateFieldPathExpression pathExpression = getStateFieldPathExpression(encapsulatedExpression); if (pathExpression != null) { valid = validateStateFieldPathExpression(pathExpression, PathType.BASIC_FIELD_ONLY); } else { encapsulatedExpression.accept(this); } } return valid; }
/** * {@inheritDoc} */ @Override protected void addOrderedEncapsulatedExpressionTo(List<Expression> children) { if (distinctIdentifier != null) { children.add(buildStringExpression(DISTINCT)); } if (hasSpaceAfterDistinct) { children.add(buildStringExpression(SPACE)); } super.addOrderedEncapsulatedExpressionTo(children); }
protected void toStringSingleEncapsulated(AbstractSingleEncapsulatedExpressionStateObject stateObject) { if (stateObject.isDecorated()) { toText(stateObject); } else { AbstractSingleEncapsulatedExpression expression = stateObject.getExpression(); // Identifier appendIdentifier((expression != null) ? expression.getActualIdentifier() : stateObject.getIdentifier(), stateObject.getIdentifier()); // '(' if (shouldOutput(expression) || expression.hasLeftParenthesis()) { writer.append(LEFT_PARENTHESIS); } if (stateObject.hasStateObject()) { stateObject.getStateObject().accept(this); } // ')' if (shouldOutput(expression) || expression.hasRightParenthesis()) { writer.append(RIGHT_PARENTHESIS); } } }
/** * {@inheritDoc} */ @Override public JPQLQueryBNF findQueryBNF(Expression expression) { if ((expression != null) && expression.isAncestor(expression)) { return getQueryBNF(getEncapsulatedExpressionQueryBNFId()); } return super.findQueryBNF(expression); }
/** * Determines whether something was parsed after the left parenthesis and before the * <code><b>AS</b></code> identifier. * * @return <code>true</code> the expression to be cast was parsed; <code>false</code> otherwise * @since 2.5 */ public boolean hasScalarExpression() { return super.hasEncapsulatedExpression(); }
/** * Determines whether there is an encapsulated expression or not. * * @param expression The {@link AbstractSingleEncapsulatedExpression} being validated * @return <code>true</code> if the given {@link AbstractSingleEncapsulatedExpression} has an * encapsulated expression; <code>false</code> otherwise */ protected boolean isEncapsulatedExpressionMissing(T expression) { return !expression.hasExpression(); }
/** * {@inheritDoc} */ public final String identifier(T expression) { return expression.getIdentifier(); }
/** * {@inheritDoc} */ @Override public void acceptChildren(ExpressionVisitor visitor) { getTrimCharacter().accept(visitor); super.acceptChildren(visitor); }
/** * {@inheritDoc} */ public boolean hasLeftParenthesis(T expression) { return expression.hasLeftParenthesis(); }
/** * Validates the given {@link AbstractSingleEncapsulatedExpression}'s encapsulated expression if * it is a state field path expression and makes sure it is mapping to a basic mapping. That * means relationship field mapping is not allowed. * * @param expression The {@link AbstractSingleEncapsulatedExpression} to validate its encapsulated * expression if it's a state field path expression, otherwise does nothing * @return <code>false</code> if the encapsulated expression was validated and is invalid; * <code>true</code> otherwise */ protected boolean validateFunctionPathExpression(AbstractSingleEncapsulatedExpression expression) { boolean valid = true; if (expression.hasEncapsulatedExpression()) { Expression encapsulatedExpression = expression.getExpression(); // Special case for state field path expression, association field is not allowed StateFieldPathExpression pathExpression = getStateFieldPathExpression(encapsulatedExpression); if (pathExpression != null) { valid = validateStateFieldPathExpression(pathExpression, PathType.BASIC_FIELD_ONLY); } else { encapsulatedExpression.accept(this); } } return valid; }
/** * {@inheritDoc} */ @Override protected void addOrderedEncapsulatedExpressionTo(List<Expression> children) { if (distinctIdentifier != null) { children.add(buildStringExpression(DISTINCT)); } if (hasSpaceAfterDistinct) { children.add(buildStringExpression(SPACE)); } super.addOrderedEncapsulatedExpressionTo(children); }
/** * {@inheritDoc} */ @Override public JPQLQueryBNF findQueryBNF(Expression expression) { if ((expression != null) && expression.isAncestor(expression)) { return getQueryBNF(getEncapsulatedExpressionQueryBNFId()); } return super.findQueryBNF(expression); }
/** * {@inheritDoc} */ @Override protected void parseEncapsulatedExpression(WordParser wordParser, int whitespaceCount, boolean tolerant) { expression = parse(wordParser, getEncapsulatedExpressionQueryBNFId(), tolerant); }