Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.parser

public final Class FunctionExpression

extends AbstractSingleEncapsulatedExpression
Class Inheritance
Imports
java.util.List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .WordParser, org.eclipse.persistence.jpa.jpql.parser.FunctionExpressionFactory.ParameterCount

This expression adds support to call native database functions.

New to JPA 2.1.

BNF: func_expression ::= <identifier>('function_name' {, func_item}*)
Author
James
Since
2.4
Version
2.5

Field Summary

Modifier and TypeField and Description
private String
functionName

The name of the SQL function.

private boolean
hasComma

Determines whether the comma separating the function name and the first expression.

private boolean
hasSpaceAfterComma

Determines whether a whitespace is following the comma.

private FunctionExpressionFactory.ParameterCount
parameterCount

The number of parameters a FunctionExpression can have.

private String
parameterQueryBNFId

The unique identifier of the JPQLQueryBNF that will be used to parse the arguments of the function expression.

Constructor Summary

AccessConstructor and Description
public
FunctionExpression(AbstractExpression
The parent of this expression
parent
,
String
The JPQL identifier
identifier
)

Creates a new FuncExpression.

public
FunctionExpression(AbstractExpression
The parent of this expression
parent
,
String
The JPQL identifier
identifier
,
FunctionExpressionFactory.ParameterCount
The number of parameters a FunctionExpression can have
parameterCount
,
String
The unique identifier of the JPQLQueryBNF that will be used to parse the arguments of the function expression
parameterQueryBNFId
)

Creates a new FunctionExpression.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ExpressionVisitor
The ExpressionVisitor to visit this object
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.
protected void
addOrderedEncapsulatedExpressionTo(List<Expression>
The list used to store the string representation of the encapsulated Expression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Adds the Expressions representing the encapsulated Expression.
public String
public String

Returns:

The name of the SQL function
getFunctionName
()

Returns the name of the SQL function.

public FunctionExpressionFactory.ParameterCount

Returns:

The number of parameters (encapsulated expressions) allowed by this expression
getParameterCount
()

Returns the number of parameters a FunctionExpression can have, which will be during validation.

public JPQLQueryBNF
public String

Returns:

The name of the SQL function
getUnquotedFunctionName
()

Returns the name of the SQL function.

public boolean

Returns:

true if a comma was parsed after the function name and the first expression; false otherwise
hasComma
()

Determines whether the comma was parsed after the function name.

public boolean
public boolean

Returns:

true if the function name was parsed; false otherwise
hasFunctionName
()

Determines whether the function name was parsed.

public boolean

Returns:

true if there was a whitespace after the comma; false otherwise
hasSpaceAfterComma
()

Determines whether a whitespace was parsed after the comma.

protected void
parseEncapsulatedExpression(WordParser
The text to parse based on the current position of the cursor
wordParser
,
int
The number of whitespace characters that were parsed after '('
whitespaceCount
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.parseEncapsulatedExpression.

Parses the encapsulated expression by starting at the current position, which is part of the given WordParser.
protected void
toParsedTextEncapsulatedExpression(StringBuilder
The buffer used to append the encapsulated Expression's string representation
writer
,
boolean
Determines whether to include any characters that are considered virtual, i.e. that was parsed when the query is incomplete and is needed for functionality like content assist
actual
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Generates a string representation of the encapsulated Expression.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression:
acceptChildrenaddChildrenTofindQueryBNFgetExpressionhasExpressionremoveEncapsulatedExpressionsetExpression

Field Detail

functionNameback to summary
private String functionName

The name of the SQL function.

hasCommaback to summary
private boolean hasComma

Determines whether the comma separating the function name and the first expression.

hasSpaceAfterCommaback to summary
private boolean hasSpaceAfterComma

Determines whether a whitespace is following the comma.

parameterCountback to summary
private FunctionExpressionFactory.ParameterCount parameterCount

The number of parameters a FunctionExpression can have.

Since
2.4
parameterQueryBNFIdback to summary
private String parameterQueryBNFId

The unique identifier of the JPQLQueryBNF that will be used to parse the arguments of the function expression.

Since
2.4

Constructor Detail

FunctionExpressionback to summary
public FunctionExpression(AbstractExpression parent, String identifier)

Creates a new FuncExpression.

Parameters
parent:AbstractExpression

The parent of this expression

identifier:String

The JPQL identifier

FunctionExpressionback to summary
public FunctionExpression(AbstractExpression parent, String identifier, FunctionExpressionFactory.ParameterCount parameterCount, String parameterQueryBNFId)

Creates a new FunctionExpression.

Parameters
parent:AbstractExpression

The parent of this expression

identifier:String

The JPQL identifier

parameterCount:FunctionExpressionFactory.ParameterCount

The number of parameters a FunctionExpression can have

parameterQueryBNFId:String

The unique identifier of the JPQLQueryBNF that will be used to parse the arguments of the function expression

Method Detail

acceptback to summary
public void accept(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.

Parameters
visitor:ExpressionVisitor

The ExpressionVisitor to visit this object

Annotations
@Override
addOrderedEncapsulatedExpressionToback to summary
protected void addOrderedEncapsulatedExpressionTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Adds the Expressions representing the encapsulated Expression.

Parameters
children:List<Expression>

The list used to store the string representation of the encapsulated Expression

Annotations
@Override
getEncapsulatedExpressionQueryBNFIdback to summary
public String getEncapsulatedExpressionQueryBNFId()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.getEncapsulatedExpressionQueryBNFId.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.getEncapsulatedExpressionQueryBNFId.

Returns the BNF used to parse the encapsulated expression.

Returns:String

The BNF used to parse the encapsulated expression

Annotations
@Override
getFunctionNameback to summary
public String getFunctionName()

Returns the name of the SQL function.

Returns:String

The name of the SQL function

getParameterCountback to summary
public FunctionExpressionFactory.ParameterCount getParameterCount()

Returns the number of parameters a FunctionExpression can have, which will be during validation.

Returns:FunctionExpressionFactory.ParameterCount

The number of parameters (encapsulated expressions) allowed by this expression

Since
2.4
getQueryBNFback to summary
public JPQLQueryBNF getQueryBNF()

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Returns the BNF of this Expression.

Returns:JPQLQueryBNF

The JPQLQueryBNF, which represents the grammar of this Expression

Annotations
@Override
getUnquotedFunctionNameback to summary
public String getUnquotedFunctionName()

Returns the name of the SQL function.

Returns:String

The name of the SQL function

hasCommaback to summary
public boolean hasComma()

Determines whether the comma was parsed after the function name.

Returns:boolean

true if a comma was parsed after the function name and the first expression; false otherwise

hasEncapsulatedExpressionback to summary
public boolean hasEncapsulatedExpression()

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.hasEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.hasEncapsulatedExpression.

Determines whether something was parsed after the left parenthesis.

Returns:boolean

true if something was parsed; false otherwise

Annotations
@Override
hasFunctionNameback to summary
public boolean hasFunctionName()

Determines whether the function name was parsed.

Returns:boolean

true if the function name was parsed; false otherwise

hasSpaceAfterCommaback to summary
public boolean hasSpaceAfterComma()

Determines whether a whitespace was parsed after the comma.

Returns:boolean

true if there was a whitespace after the comma; false otherwise

parseEncapsulatedExpressionback to summary
protected void parseEncapsulatedExpression(WordParser wordParser, int whitespaceCount, boolean tolerant)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.parseEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.parseEncapsulatedExpression.

Parses the encapsulated expression by starting at the current position, which is part of the given WordParser.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

whitespaceCount:int

The number of whitespace characters that were parsed after '('

tolerant:boolean

Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries

Annotations
@Override
toParsedTextEncapsulatedExpressionback to summary
protected void toParsedTextEncapsulatedExpression(StringBuilder writer, boolean actual)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Generates a string representation of the encapsulated Expression.

Parameters
writer:StringBuilder

The buffer used to append the encapsulated Expression's string representation

actual:boolean

Determines whether to include any characters that are considered virtual, i.e. that was parsed when the query is incomplete and is needed for functionality like content assist

Annotations
@Override