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

public final Class TrimExpression

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

The TRIM function trims the specified character from a string. If the character to be trimmed is not specified, it is assumed to be space (or blank). The optional trim_character is a single-character string literal or a character-valued input parameter (i.e., char or Character). If a trim specification is not provided, BOTH is assumed. The TRIM function returns the trimmed string.

JPA 1.0, 2.0:

BNF: expression ::= TRIM([[trim_specification] [trim_character] FROM] string_primary)
BNF: trim_character ::= string_literal | input_parameter

JPA 2.1:
BNF: expression ::= TRIM([[trim_specification] [trim_character] FROM] string_expression)
BNF: trim_character ::= string_literal | input_parameter
Example: UPDATE Student st SET st.sname=TRIM(st.sname)
Author
Pascal Filion
Since
2.3
Version
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TrimExpression.Specification

The possible ways to trim the string.

Field Summary

Modifier and TypeField and Description
private String
fromIdentifier

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

private boolean
hasFrom

Determines whether the identifier FROM was part of the query.

private boolean
hasSpaceAfterFrom

Determines whether a space was parsed after the identifier FROM.

private boolean
hasSpaceAfterSpecification

Determines whether a space was parsed after the trim specification.

private boolean
hasSpaceAfterTrimCharacter

Determines whether a space was parsed after the trim character.

private TrimExpression.Specification
specification

The specification specifies how to trim the string.

private String
specificationIdentifier

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

private AbstractExpression
trimCharacter

The character used for trimming the string.

Constructor Summary

AccessConstructor and Description
public
TrimExpression(AbstractExpression
The parent of this expression
parent
)

Creates a new TrimExpression.

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
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

Returns:

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

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

public String

Returns:

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

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

public String
public JPQLQueryBNF
public TrimExpression.Specification

Returns:

One of the available choices for trimming the string
getSpecification
()

Returns the specification which specifies how to trim the string.

public Expression

Returns:

The character, if one was parsed, that will be used to trim the string. If the character was not specified, then '\0' is the character
getTrimCharacter
()

Returns the character used for trimming the string.

public boolean
public boolean

Returns:

true if the identifier FROM was parsed; false otherwise
hasFrom
()

Determines whether the identifier FROM was part of the query.

public boolean

Returns:

true if there was a whitespace after FROM; false otherwise
hasSpaceAfterFrom
()

Determines whether a whitespace was found after FROM.

public boolean

Returns:

true if there was a whitespace after the trim specification; false otherwise
hasSpaceAfterSpecification
()

Determines whether a whitespace was found after the way the string is trimmed.

public boolean

Returns:

true if there was a whitespace after the trim character; false otherwise
hasSpaceAfterTrimCharacter
()

Determines whether a whitespace was found after the character used to trim the string.

public boolean

Returns:

true if the query contained the way the trim needs to be trimmed; false otherwise
hasSpecification
()

Determines whether the way the trim is trimmed was parsed.

public boolean

Returns:

true if the character used for trimming was specified; false otherwise
hasTrimCharacter
()

Determines whether the character used to trim the string was specified.

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.
private TrimExpression.Specification
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:
addChildrenTofindQueryBNFgetExpressionhasExpressionremoveEncapsulatedExpressionsetExpression

Field Detail

fromIdentifierback to summary
private String fromIdentifier

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

hasFromback to summary
private boolean hasFrom

Determines whether the identifier FROM was part of the query.

hasSpaceAfterFromback to summary
private boolean hasSpaceAfterFrom

Determines whether a space was parsed after the identifier FROM.

hasSpaceAfterSpecificationback to summary
private boolean hasSpaceAfterSpecification

Determines whether a space was parsed after the trim specification.

hasSpaceAfterTrimCharacterback to summary
private boolean hasSpaceAfterTrimCharacter

Determines whether a space was parsed after the trim character.

specificationback to summary
private TrimExpression.Specification specification

The specification specifies how to trim the string.

specificationIdentifierback to summary
private String specificationIdentifier

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

trimCharacterback to summary
private AbstractExpression trimCharacter

The character used for trimming the string.

Constructor Detail

TrimExpressionback to summary
public TrimExpression(AbstractExpression parent)

Creates a new TrimExpression.

Parameters
parent:AbstractExpression

The parent of this 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)

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

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
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
getActualFromIdentifierback to summary
public String getActualFromIdentifier()

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

Returns:String

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

getActualSpecificationIdentifierback to summary
public String getActualSpecificationIdentifier()

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

Returns:String

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

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
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
getSpecificationback to summary
public TrimExpression.Specification getSpecification()

Returns the specification which specifies how to trim the string.

Returns:TrimExpression.Specification

One of the available choices for trimming the string

getTrimCharacterback to summary
public Expression getTrimCharacter()

Returns the character used for trimming the string.

Returns:Expression

The character, if one was parsed, that will be used to trim the string. If the character was not specified, then '\0' is the character

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
hasFromback to summary
public boolean hasFrom()

Determines whether the identifier FROM was part of the query.

Returns:boolean

true if the identifier FROM was parsed; false otherwise

hasSpaceAfterFromback to summary
public boolean hasSpaceAfterFrom()

Determines whether a whitespace was found after FROM.

Returns:boolean

true if there was a whitespace after FROM; false otherwise

hasSpaceAfterSpecificationback to summary
public boolean hasSpaceAfterSpecification()

Determines whether a whitespace was found after the way the string is trimmed.

Returns:boolean

true if there was a whitespace after the trim specification; false otherwise

hasSpaceAfterTrimCharacterback to summary
public boolean hasSpaceAfterTrimCharacter()

Determines whether a whitespace was found after the character used to trim the string.

Returns:boolean

true if there was a whitespace after the trim character; false otherwise

hasSpecificationback to summary
public boolean hasSpecification()

Determines whether the way the trim is trimmed was parsed.

Returns:boolean

true if the query contained the way the trim needs to be trimmed; false otherwise

hasTrimCharacterback to summary
public boolean hasTrimCharacter()

Determines whether the character used to trim the string was specified.

Returns:boolean

true if the character used for trimming was specified; 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
parseTrimSpecificationback to summary
private TrimExpression.Specification parseTrimSpecification(WordParser wordParser)
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
org.eclipse.persistence.jpa.jpql.parser back to summary

public final Enum TrimExpression.Specification

extends Enum<TrimExpression.Specification>
Class Inheritance

The possible ways to trim the string.

Field Summary

Modifier and TypeField and Description
public static final TrimExpression.Specification
BOTH

The leading and trailing parts of the string will be trimmed.

public static final TrimExpression.Specification
DEFAULT

Used when the trim specification is not specified, by default it means the leading and trailing parts of the string will be trimmed.

public static final TrimExpression.Specification
LEADING

Only the leading part of the string will be trimmed.

public static final TrimExpression.Specification
TRAILING

Only the trailing part of the string will be trimmed.

private String
value

The actual constant associated with the constant.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The identifier associated with the constant or an empty string for DEFAULT
getValue
()

Returns the actual identifier associated with the constant.

public static TrimExpression.Specification
public static TrimExpression.Specification[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOTHback to summary
public static final TrimExpression.Specification BOTH

The leading and trailing parts of the string will be trimmed.

DEFAULTback to summary
public static final TrimExpression.Specification DEFAULT

Used when the trim specification is not specified, by default it means the leading and trailing parts of the string will be trimmed.

LEADINGback to summary
public static final TrimExpression.Specification LEADING

Only the leading part of the string will be trimmed.

TRAILINGback to summary
public static final TrimExpression.Specification TRAILING

Only the trailing part of the string will be trimmed.

valueback to summary
private String value

The actual constant associated with the constant.

Constructor Detail

Specificationback to summary
private Specification(String value)

Method Detail

getValueback to summary
public String getValue()

Returns the actual identifier associated with the constant.

Returns:String

The identifier associated with the constant or an empty string for DEFAULT

valueOfback to summary
public static TrimExpression.Specification valueOf(String name)
valuesback to summary
public static TrimExpression.Specification[] values()