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

public final Class LikeExpression

extends AbstractExpression
Class Inheritance
Imports
java.util.Collection, .List, org.eclipse.persistence.jpa.jpql.ExpressionTools, .WordParser

The LIKE condition is used to specify a search for a pattern.

The string_expression must have a string value. The pattern_value is a string literal or a string-valued input parameter in which an underscore (_) stands for any single character, a percent (%) character stands for any sequence of characters (including the empty sequence), and all other characters stand for themselves. The optional escape_character is a single-character string literal or a character-valued input parameter (i.e., char or Character) and is used to escape the special meaning of the underscore and percent characters in pattern_value.

BNF: like_expression ::= string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]
Author
Pascal Filion
Since
2.3
Version
2.5

Field Summary

Modifier and TypeField and Description
private AbstractExpression
escapeCharacter

The Expression representing the escape character, which is either a single character or an input parameter.

private String
escapeIdentifier

The actual escape identifier found in the string representation of the JPQL query.

private boolean
hasSpaceAfterEscape

Determines whether a whitespace was parsed after ESCAPE.

private boolean
hasSpaceAfterLike

Determines whether a whitespace was parsed after LIKE.

private boolean
hasSpaceAfterPatternValue

Determines whether a whitespace was parsed after the pattern value.

private String
likeIdentifier

The actual LIKE identifier found in the string representation of the JPQL query.

private String
notIdentifier

The actual NOT identifier found in the string representation of the JPQL query.

private AbstractExpression
patternValue

The Expression representing the pattern value.

private AbstractExpression
stringExpression

The Expression representing the string expression.

Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
COMMADOTDOUBLE_QUOTELEFT_CURLY_BRACKETLEFT_PARENTHESISNOT_DEFINEDRIGHT_CURLY_BRACKETRIGHT_PARENTHESISSINGLE_QUOTESPACEUNDERSCORE

Constructor Summary

AccessConstructor and Description
public
LikeExpression(AbstractExpression
The parent of this expression
parent
,
AbstractExpression
The first part of this expression, which is the string expression
stringExpression
)

Creates a new LikeExpression.

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.
public void
acceptChildren(ExpressionVisitor
The visitor to visit the children of this object.
visitor
)

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

Visits the children of this Expression.
protected void
addChildrenTo(Collection<Expression>
The collection used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.
protected void
addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this AbstractExpression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.
public JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

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

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.
public String

Returns:

The ESCAPE identifier that was actually parsed, or an empty string if it was not parsed
getActualEscapeIdentifier
()

Returns the actual ESCAPE found in the string representation of the JPQL query, which has the actual case that was used.

public String

Returns:

The LIKE identifier that was actually parsed
getActualLikeIdentifier
()

Returns the actual LIKE found in the string representation of the JPQL query, which has the actual case that was used.

public String

Returns:

The NOT identifier that was actually parsed, or an empty string if it was not parsed
getActualNotIdentifier
()

Returns the actual NOT found in the string representation of the JPQL query, which has the actual case that was used.

public Expression

Returns:

The expression that was parsed representing the escape character
getEscapeCharacter
()

Returns the Expression that represents the escape character, which is either a single character or an input parameter.

public String

Returns:

Either LIKE or NOT LIKE
getIdentifier
()

Returns the enum constant that represents the identifier.

public Expression

Returns:

The expression that was parsed representing the pattern value
getPatternValue
()

Returns the Expression that represents the pattern value.

public JPQLQueryBNF
public Expression

Returns:

The expression that was parsed representing the string expression
getStringExpression
()

Returns the Expression that represents the string expression.

public boolean

Returns:

true if the identifier ESCAPE was parsed; false otherwise
hasEscape
()

Determines whether the identifier ESCAPE was parsed.

public boolean

Returns:

true if the escape character was parsed; false otherwise
hasEscapeCharacter
()

Determines whether the escape character was parsed, which is either a single character or an input parameter.

public boolean

Returns:

true if the identifier NOT was parsed; false otherwise
hasNot
()

Determines whether the identifier NOT was parsed.

public boolean

Returns:

true if the pattern value was parsed; false otherwise
hasPatternValue
()

Determines whether the pattern value was parsed.

public boolean

Returns:

true if there was a whitespace after ESCAPE; false otherwise
hasSpaceAfterEscape
()

Determines whether a whitespace was parsed after ESCAPE.

public boolean

Returns:

true if there was a whitespace after LIKE; false otherwise
hasSpaceAfterLike
()

Determines whether a whitespace was parsed after LIKE.

public boolean

Returns:

true if there was a whitespace after the pattern value; false otherwise
hasSpaceAfterPatternValue
()

Determines whether a whitespace was parsed after the pattern value.

public boolean

Returns:

true if there was a whitespace after the string expression; false otherwise
hasSpaceAfterStringExpression
()

Determines whether a whitespace was parsed after the string expression.

public boolean

Returns:

true if the string expression was parsed; false otherwise
hasStringExpression
()

Determines whether the string expression was parsed.

protected boolean
isParsingComplete(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The word that was retrieved from the given text, which is the first word in the text
word
,
Expression
The Expression that has already been parsed
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text.
protected void
parse(WordParser
The text to parse based on the current position of the cursor
wordParser
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.
protected void
toParsedText(StringBuilder
The buffer used to append this Expression's string representation
writer
,
boolean
Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers
actual
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

escapeCharacterback to summary
private AbstractExpression escapeCharacter

The Expression representing the escape character, which is either a single character or an input parameter.

escapeIdentifierback to summary
private String escapeIdentifier

The actual escape identifier found in the string representation of the JPQL query.

hasSpaceAfterEscapeback to summary
private boolean hasSpaceAfterEscape

Determines whether a whitespace was parsed after ESCAPE.

hasSpaceAfterLikeback to summary
private boolean hasSpaceAfterLike

Determines whether a whitespace was parsed after LIKE.

hasSpaceAfterPatternValueback to summary
private boolean hasSpaceAfterPatternValue

Determines whether a whitespace was parsed after the pattern value.

likeIdentifierback to summary
private String likeIdentifier

The actual LIKE identifier found in the string representation of the JPQL query.

notIdentifierback to summary
private String notIdentifier

The actual NOT identifier found in the string representation of the JPQL query.

patternValueback to summary
private AbstractExpression patternValue

The Expression representing the pattern value.

stringExpressionback to summary
private AbstractExpression stringExpression

The Expression representing the string expression.

Constructor Detail

LikeExpressionback to summary
public LikeExpression(AbstractExpression parent, AbstractExpression stringExpression)

Creates a new LikeExpression.

Parameters
parent:AbstractExpression

The parent of this expression

stringExpression:AbstractExpression

The first part of this expression, which is the string 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
acceptChildrenback to summary
public void acceptChildren(ExpressionVisitor visitor)

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

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

Visits the children of this Expression. This method can be used to optimize traversing the children since a new list is not created every time children() is called.

This does not traverse the Expression sub-hierarchy, use a subclass of AbstractTraverseChildrenVisitor in order to traverse the entire sub-hierarchy.

Parameters
visitor:ExpressionVisitor

The visitor to visit the children of this object.

Annotations
@Override
addChildrenToback to summary
protected void addChildrenTo(Collection<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.

Parameters
children:Collection<Expression>

The collection used to store the children

Annotations
@Override
addOrderedChildrenToback to summary
protected void addOrderedChildrenTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.

Parameters
children:List<Expression>

The list used to store the string representation of this AbstractExpression

Annotations
@Override
findQueryBNFback to summary
public JPQLQueryBNF findQueryBNF(Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

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

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

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.

Parameters
expression:Expression

The Expression that is a descendant of this one

Returns:JPQLQueryBNF

The JPQLQueryBNF that was used to parse the given expression

Annotations
@Override
getActualEscapeIdentifierback to summary
public String getActualEscapeIdentifier()

Returns the actual ESCAPE found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The ESCAPE identifier that was actually parsed, or an empty string if it was not parsed

getActualLikeIdentifierback to summary
public String getActualLikeIdentifier()

Returns the actual LIKE found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The LIKE identifier that was actually parsed

getActualNotIdentifierback to summary
public String getActualNotIdentifier()

Returns the actual NOT found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The NOT identifier that was actually parsed, or an empty string if it was not parsed

getEscapeCharacterback to summary
public Expression getEscapeCharacter()

Returns the Expression that represents the escape character, which is either a single character or an input parameter.

Returns:Expression

The expression that was parsed representing the escape character

getIdentifierback to summary
public String getIdentifier()

Returns the enum constant that represents the identifier.

Returns:String

Either LIKE or NOT LIKE

getPatternValueback to summary
public Expression getPatternValue()

Returns the Expression that represents the pattern value.

Returns:Expression

The expression that was parsed representing the pattern value

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
getStringExpressionback to summary
public Expression getStringExpression()

Returns the Expression that represents the string expression.

Returns:Expression

The expression that was parsed representing the string expression

hasEscapeback to summary
public boolean hasEscape()

Determines whether the identifier ESCAPE was parsed.

Returns:boolean

true if the identifier ESCAPE was parsed; false otherwise

hasEscapeCharacterback to summary
public boolean hasEscapeCharacter()

Determines whether the escape character was parsed, which is either a single character or an input parameter.

Returns:boolean

true if the escape character was parsed; false otherwise

hasNotback to summary
public boolean hasNot()

Determines whether the identifier NOT was parsed.

Returns:boolean

true if the identifier NOT was parsed; false otherwise

hasPatternValueback to summary
public boolean hasPatternValue()

Determines whether the pattern value was parsed.

Returns:boolean

true if the pattern value was parsed; false otherwise

hasSpaceAfterEscapeback to summary
public boolean hasSpaceAfterEscape()

Determines whether a whitespace was parsed after ESCAPE.

Returns:boolean

true if there was a whitespace after ESCAPE; false otherwise

hasSpaceAfterLikeback to summary
public boolean hasSpaceAfterLike()

Determines whether a whitespace was parsed after LIKE.

Returns:boolean

true if there was a whitespace after LIKE; false otherwise

hasSpaceAfterPatternValueback to summary
public boolean hasSpaceAfterPatternValue()

Determines whether a whitespace was parsed after the pattern value.

Returns:boolean

true if there was a whitespace after the pattern value; false otherwise

hasSpaceAfterStringExpressionback to summary
public boolean hasSpaceAfterStringExpression()

Determines whether a whitespace was parsed after the string expression.

Returns:boolean

true if there was a whitespace after the string expression; false otherwise

hasStringExpressionback to summary
public boolean hasStringExpression()

Determines whether the string expression was parsed.

Returns:boolean

true if the string expression was parsed; false otherwise

isParsingCompleteback to summary
protected boolean isParsingComplete(WordParser wordParser, String word, Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text. The text is never empty.

Parameters
wordParser:WordParser

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

word:String

The word that was retrieved from the given text, which is the first word in the text

expression:Expression

The Expression that has already been parsed

Returns:boolean

true if the text no longer can't be parsed by the current expression; false if more can be parsed

Annotations
@Override
parseback to summary
protected void parse(WordParser wordParser, boolean tolerant)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query 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

tolerant:boolean

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

Annotations
@Override
toParsedTextback to summary
protected void toParsedText(StringBuilder writer, boolean actual)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.

Parameters
writer:StringBuilder

The buffer used to append this Expression's string representation

actual:boolean

Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers

Annotations
@Override