Class TrimExpressionStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractEncapsulatedExpressionStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.TrimExpressionStateObject
- All Implemented Interfaces:
StateObject
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.
BNF: expression ::= TRIM([[trim_specification] [trim_character] FROM] string_primary)
- Since:
- 2.4
- Version:
- 2.5
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notifies the visibility of theFROM
identifier has changed.static final String
Notifies the specification property has changed.static final String
Notify the state object representing the trim character has changed.Fields inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject
STATE_OBJECT_PROPERTY
-
Constructor Summary
ConstructorDescriptionTrimExpressionStateObject
(StateObject parent) Creates a newTrimExpressionStateObject
.TrimExpressionStateObject
(StateObject parent, String jpqlFragment) Creates a newTrimExpressionStateObject
.TrimExpressionStateObject
(StateObject parent, TrimExpression.Specification specification, StateObject stateObject) Creates a newTrimExpressionStateObject
.TrimExpressionStateObject
(StateObject parent, TrimExpression.Specification specification, StateObject trimCharacter, StateObject stateObject) Creates a newTrimExpressionStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(StateObjectVisitor visitor) Visits thisStateObject
by the givenvisitor
.Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.Returns the JPQL identifier of the expression represented by thisAbstractSingleEncapsulatedExpressionStateObject
.protected String
Returns the unique identifier of theJPQLQueryBNF
that will determine how to parse the encapsulated expression.Returns the new trim specification.Returns theStateObject
representing the trim character.boolean
Determines whether the way the trim is trimmed was parsed.boolean
Determines whether the character used to trim the string was specified.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.void
Parses the given JPQL fragment, which represents the encapsulated expression, and creates theStateObject
.void
parseTrimCharacter
(CharSequence jpqlFragment) Parses the given JPQL fragment, which represents either a single-character string literal or a character-valued input parameter, the fragment will be parsed and converted into aStateObject
.void
Removes the trim specification.void
Removes the trim character if it is defined.void
setExpression
(TrimExpression expression) Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.void
setSpecification
(TrimExpression.Specification specification) Sets the new trim specification.void
setStateObject
(StateObject stateObject) Sets the givenStateObject
to represent the new encapsulated expression.void
setTrimCharacter
(StateObject trimCharacter) Sets the character to trim from the string.protected void
Prints out a string representation of this encapsulated information, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject
addChildren, getStateObject, hasStateObject
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractEncapsulatedExpressionStateObject
toTextInternal
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Field Details
-
HAS_FROM_PROPERTY
Notifies the visibility of theFROM
identifier has changed.- See Also:
-
SPECIFICATION_PROPERTY
Notifies the specification property has changed.- See Also:
-
TRIM_CHARACTER_PROPERTY
Notify the state object representing the trim character has changed.- See Also:
-
-
Constructor Details
-
TrimExpressionStateObject
Creates a newTrimExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
NullPointerException
- The given parent cannot benull
-
TrimExpressionStateObject
public TrimExpressionStateObject(StateObject parent, TrimExpression.Specification specification, StateObject stateObject) Creates a newTrimExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
specification
- Defines the way the string is trimmed, orSpecification.DEFAULT
when it is not presentstateObject
- TheStateObject
representing the encapsulated expression- Throws:
NullPointerException
- The given parent cannot benull
-
TrimExpressionStateObject
public TrimExpressionStateObject(StateObject parent, TrimExpression.Specification specification, StateObject trimCharacter, StateObject stateObject) Creates a newTrimExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
specification
- Defines the way the string is trimmed, orSpecification.DEFAULT
when it is not presenttrimCharacter
- The trim characterstateObject
- TheStateObject
representing the encapsulated expression- Throws:
NullPointerException
- The given parent cannot benull
-
TrimExpressionStateObject
Creates a newTrimExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
jpqlFragment
- The portion of the query representing the encapsulated expression- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObject
Visits thisStateObject
by the givenvisitor
.- Parameters:
visitor
- Thevisitor
to visit this object
-
getExpression
Description copied from interface:StateObject
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpression
in interfaceStateObject
- Overrides:
getExpression
in classAbstractSingleEncapsulatedExpressionStateObject
- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObject
ornull
when the JPQL query is manually created (i.e. not from a string)
-
getIdentifier
Description copied from class:AbstractEncapsulatedExpressionStateObject
Returns the JPQL identifier of the expression represented by thisAbstractSingleEncapsulatedExpressionStateObject
.- Specified by:
getIdentifier
in classAbstractEncapsulatedExpressionStateObject
- Returns:
- The JPQL identifier that is shown before the left parenthesis
-
getQueryBNFId
Description copied from class:AbstractSingleEncapsulatedExpressionStateObject
Returns the unique identifier of theJPQLQueryBNF
that will determine how to parse the encapsulated expression.- Specified by:
getQueryBNFId
in classAbstractSingleEncapsulatedExpressionStateObject
- Returns:
- The non-
null
ID of the BNF
-
getSpecification
Returns the new trim specification.- Returns:
- The new trim specification; which is never
null
-
getTrimCharacter
Returns theStateObject
representing the trim character.- Returns:
- The
StateObject
representing the trim character ornull
if it is not present
-
hasSpecification
public boolean hasSpecification()Determines whether the way the trim is trimmed was parsed.- Returns:
true
if the query contained the way the trim needs to be trimmed;false
otherwise
-
hasTrimCharacter
public boolean hasTrimCharacter()Determines whether the character used to trim the string was specified.- Returns:
true
if the character used for trimming was specified;false
otherwise
-
isEquivalent
Description copied from interface:StateObject
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.- Specified by:
isEquivalent
in interfaceStateObject
- Overrides:
isEquivalent
in classAbstractSingleEncapsulatedExpressionStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
parse
Description copied from class:AbstractSingleEncapsulatedExpressionStateObject
Parses the given JPQL fragment, which represents the encapsulated expression, and creates theStateObject
.- Overrides:
parse
in classAbstractSingleEncapsulatedExpressionStateObject
- Parameters:
jpqlFragment
- The portion of the query representing the encapsulated expression
-
parseTrimCharacter
Parses the given JPQL fragment, which represents either a single-character string literal or a character-valued input parameter, the fragment will be parsed and converted into aStateObject
.- Parameters:
jpqlFragment
- The portion of the query to parse
-
removeSpecification
public void removeSpecification()Removes the trim specification. -
removeTrimCharacter
public void removeTrimCharacter()Removes the trim character if it is defined. -
setExpression
Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.- Parameters:
expression
- Theparsed object
representing aTRIM
expression
-
setSpecification
Sets the new trim specification.- Parameters:
specification
- The new trim specification;null
is not valid
-
setStateObject
Description copied from class:AbstractSingleEncapsulatedExpressionStateObject
Sets the givenStateObject
to represent the new encapsulated expression.- Overrides:
setStateObject
in classAbstractSingleEncapsulatedExpressionStateObject
- Parameters:
stateObject
- The new encapsulatedStateObject
-
setTrimCharacter
Sets the character to trim from the string. If the character to be trimmed is not specified, it is assumed to be space (or blank). It is a single-character string literal or a character- valued input parameter (i.e., char orCharacter
).- Parameters:
trimCharacter
- The trim character ornull
to remove it
-
toTextEncapsulatedExpression
Description copied from class:AbstractEncapsulatedExpressionStateObject
Prints out a string representation of this encapsulated information, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.- Overrides:
toTextEncapsulatedExpression
in classAbstractSingleEncapsulatedExpressionStateObject
- Parameters:
writer
- The writer used to print out the string representation of the encapsulated information- Throws:
IOException
- This should never happens, only required becauseAppendable
is used instead ofStringBuilder
for instance
-