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
public class TrimExpressionStateObject extends AbstractSingleEncapsulatedExpressionStateObject
TheTRIMfunction 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 optionaltrim_characteris a single-character string literal or a character-valued input parameter (i.e., char orCharacter). If a trim specification is not provided,BOTHis assumed. TheTRIMfunction returns the trimmed string.BNF:expression ::= TRIM([[trim_specification] [trim_character] FROM] string_primary)- Version:
- 2.5
- See Also:
TrimExpression- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringHAS_FROM_PROPERTYNotifies the visibility of theFROMidentifier has changed.static java.lang.StringSPECIFICATION_PROPERTYNotifies the specification property has changed.static java.lang.StringTRIM_CHARACTER_PROPERTYNotify 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
Constructors Constructor Description TrimExpressionStateObject(StateObject parent)Creates a newTrimExpressionStateObject.TrimExpressionStateObject(StateObject parent, java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.TrimExpressiongetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.java.lang.StringgetIdentifier()Returns the JPQL identifier of the expression represented by thisAbstractSingleEncapsulatedExpressionStateObject.protected java.lang.StringgetQueryBNFId()Returns the unique identifier of theJPQLQueryBNFthat will determine how to parse the encapsulated expression.TrimExpression.SpecificationgetSpecification()Returns the new trim specification.StateObjectgetTrimCharacter()Returns theStateObjectrepresenting the trim character.booleanhasSpecification()Determines whether the way the trim is trimmed was parsed.booleanhasTrimCharacter()Determines whether the character used to trim the string was specified.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.voidparse(java.lang.String jpqlFragment)Parses the given JPQL fragment, which represents the encapsulated expression, and creates theStateObject.voidparseTrimCharacter(java.lang.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.voidremoveSpecification()Removes the trim specification.voidremoveTrimCharacter()Removes the trim character if it is defined.voidsetExpression(TrimExpression expression)Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.voidsetSpecification(TrimExpression.Specification specification)Sets the new trim specification.voidsetStateObject(StateObject stateObject)Sets the givenStateObjectto represent the new encapsulated expression.voidsetTrimCharacter(StateObject trimCharacter)Sets the character to trim from the string.protected voidtoTextEncapsulatedExpression(java.lang.Appendable writer)Prints out a string representation of this encapsulated information, which should not be used to define atruestring 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 Detail
-
HAS_FROM_PROPERTY
public static final java.lang.String HAS_FROM_PROPERTY
Notifies the visibility of theFROMidentifier has changed.- See Also:
- Constant Field Values
-
SPECIFICATION_PROPERTY
public static final java.lang.String SPECIFICATION_PROPERTY
Notifies the specification property has changed.- See Also:
- Constant Field Values
-
TRIM_CHARACTER_PROPERTY
public static final java.lang.String TRIM_CHARACTER_PROPERTY
Notify the state object representing the trim character has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TrimExpressionStateObject
public TrimExpressionStateObject(StateObject parent)
Creates a newTrimExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
java.lang.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 benullstateObject- TheStateObjectrepresenting the encapsulated expressionspecification- Defines the way the string is trimmed, orSpecification.DEFAULTwhen it is not present- Throws:
java.lang.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 benullspecification- Defines the way the string is trimmed, orSpecification.DEFAULTwhen it is not presenttrimCharacter- The trim characterstateObject- TheStateObjectrepresenting the encapsulated expression- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
TrimExpressionStateObject
public TrimExpressionStateObject(StateObject parent, java.lang.String jpqlFragment)
Creates a newTrimExpressionStateObject.- Parameters:
parent- The parent of this state object, which cannot benulljpqlFragment- The portion of the query representing the encapsulated expression- Throws:
java.lang.NullPointerException- The given parent cannot benull
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
getExpression
public TrimExpression getExpression()
Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractSingleEncapsulatedExpressionStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getIdentifier
public java.lang.String getIdentifier()
Returns the JPQL identifier of the expression represented by thisAbstractSingleEncapsulatedExpressionStateObject.- Specified by:
getIdentifierin classAbstractEncapsulatedExpressionStateObject- Returns:
- The JPQL identifier that is shown before the left parenthesis
-
getQueryBNFId
protected java.lang.String getQueryBNFId()
Returns the unique identifier of theJPQLQueryBNFthat will determine how to parse the encapsulated expression.- Specified by:
getQueryBNFIdin classAbstractSingleEncapsulatedExpressionStateObject- Returns:
- The non-
nullID of the BNF
-
getSpecification
public TrimExpression.Specification getSpecification()
Returns the new trim specification.- Returns:
- The new trim specification; which is never
null
-
getTrimCharacter
public StateObject getTrimCharacter()
Returns theStateObjectrepresenting the trim character.- Returns:
- The
StateObjectrepresenting the trim character ornullif it is not present
-
hasSpecification
public boolean hasSpecification()
Determines whether the way the trim is trimmed was parsed.- Returns:
trueif the query contained the way the trim needs to be trimmed;falseotherwise
-
hasTrimCharacter
public boolean hasTrimCharacter()
Determines whether the character used to trim the string was specified.- Returns:
trueif the character used for trimming was specified;falseotherwise
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractSingleEncapsulatedExpressionStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
parse
public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents the encapsulated expression, and creates theStateObject.- Overrides:
parsein classAbstractSingleEncapsulatedExpressionStateObject- Parameters:
jpqlFragment- The portion of the query representing the encapsulated expression
-
parseTrimCharacter
public void parseTrimCharacter(java.lang.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.- 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
public void setExpression(TrimExpression expression)
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting aTRIMexpression
-
setSpecification
public void setSpecification(TrimExpression.Specification specification)
Sets the new trim specification.- Parameters:
specification- The new trim specification;nullis not valid
-
setStateObject
public void setStateObject(StateObject stateObject)
Sets the givenStateObjectto represent the new encapsulated expression.- Overrides:
setStateObjectin classAbstractSingleEncapsulatedExpressionStateObject- Parameters:
stateObject- The new encapsulatedStateObject
-
setTrimCharacter
public void setTrimCharacter(StateObject trimCharacter)
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 ornullto remove it
-
toTextEncapsulatedExpression
protected void toTextEncapsulatedExpression(java.lang.Appendable writer) throws java.io.IOExceptionPrints out a string representation of this encapsulated information, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Overrides:
toTextEncapsulatedExpressionin classAbstractSingleEncapsulatedExpressionStateObject- Parameters:
writer- The writer used to print out the string representation of the encapsulated information- Throws:
java.io.IOException- This should never happens, only required becauseAppendableis used instead ofStringBuilderfor instance
-
-