EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.model.query
Class TrimExpressionStateObject

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractEncapsulatedExpressionStateObject
          extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractSingleEncapsulatedExpressionStateObject
              extended by org.eclipse.persistence.jpa.jpql.model.query.TrimExpressionStateObject
All Implemented Interfaces:
StateObject

public class TrimExpressionStateObject
extends AbstractSingleEncapsulatedExpressionStateObject

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)

Version:
2.4.2
See Also:
TrimExpression
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String HAS_FROM_PROPERTY
          Notifies the visibility of the FROM identifier has changed.
static java.lang.String SPECIFICATION_PROPERTY
          Notifies the specification property has changed.
static java.lang.String TRIM_CHARACTER_PROPERTY
          Notify the state object representing the trim character has changed.
 
Fields inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractSingleEncapsulatedExpressionStateObject
STATE_OBJECT_PROPERTY
 
Constructor Summary
TrimExpressionStateObject(StateObject parent)
          Creates a new TrimExpressionStateObject.
TrimExpressionStateObject(StateObject parent, java.lang.String jpqlFragment)
          Creates a new TrimExpressionStateObject.
TrimExpressionStateObject(StateObject parent, TrimExpression.Specification specification, StateObject stateObject)
          Creates a new TrimExpressionStateObject.
TrimExpressionStateObject(StateObject parent, TrimExpression.Specification specification, StateObject trimCharacter, StateObject stateObject)
          Creates a new TrimExpressionStateObject.
 
Method Summary
 void accept(StateObjectVisitor visitor)
          Visits this StateObject by the given visitor.
 TrimExpression getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 java.lang.String getIdentifier()
          Returns the JPQL identifier of the expression represented by this AbstractSingleEncapsulatedExpressionStateObject.
protected  java.lang.String getQueryBNFId()
          Returns the unique identifier of the JPQLQueryBNF that will determine how to parse the encapsulated expression.
 TrimExpression.Specification getSpecification()
          Returns the new trim specification.
 StateObject getTrimCharacter()
          Returns the StateObject representing the trim character.
 boolean hasSpecification()
          Determines whether the way the trim is trimmed was parsed.
 boolean hasTrimCharacter()
          Determines whether the character used to trim the string was specified.
 boolean isEquivalent(StateObject stateObject)
          Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
 void parse(java.lang.String jpqlFragment)
          Parses the given JPQL fragment, which represents the encapsulated expression, and creates the StateObject.
 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 a StateObject.
 void removeSpecification()
          Removes the trim specification.
 void removeTrimCharacter()
          Removes the trim character if it is defined.
 void setExpression(TrimExpression expression)
          Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.
 void setSpecification(TrimExpression.Specification specification)
          Sets the new trim specification.
 void setStateObject(StateObject stateObject)
          Sets the given StateObject to represent the new encapsulated expression.
 void setTrimCharacter(StateObject trimCharacter)
          Sets the character to trim from the string.
protected  void toTextEncapsulatedExpression(java.lang.Appendable writer)
          Prints out a string representation of this encapsulated information, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractSingleEncapsulatedExpressionStateObject
addChildren, getStateObject, hasStateObject
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractEncapsulatedExpressionStateObject
toTextInternal
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HAS_FROM_PROPERTY

public static final java.lang.String HAS_FROM_PROPERTY
Notifies the visibility of the FROM identifier 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 new TrimExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
Throws:
java.lang.NullPointerException - The given parent cannot be null

TrimExpressionStateObject

public TrimExpressionStateObject(StateObject parent,
                                 TrimExpression.Specification specification,
                                 StateObject stateObject)
Creates a new TrimExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
stateObject - The StateObject representing the encapsulated expression
specification - Defines the way the string is trimmed, or jpa.jpql.parser.TrimExpression.Specification#DEFAULT Specification.DEFAULT when it is not present
Throws:
java.lang.NullPointerException - The given parent cannot be null

TrimExpressionStateObject

public TrimExpressionStateObject(StateObject parent,
                                 TrimExpression.Specification specification,
                                 StateObject trimCharacter,
                                 StateObject stateObject)
Creates a new TrimExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
specification - Defines the way the string is trimmed, or jpa.jpql.parser.TrimExpression.Specification#DEFAULT Specification.DEFAULT when it is not present
trimCharacter - The trim character
stateObject - The StateObject representing the encapsulated expression
Throws:
java.lang.NullPointerException - The given parent cannot be null

TrimExpressionStateObject

public TrimExpressionStateObject(StateObject parent,
                                 java.lang.String jpqlFragment)
Creates a new TrimExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
jpqlFragment - The portion of the query representing the encapsulated expression
Throws:
java.lang.NullPointerException - The given parent cannot be null
Method Detail

accept

public void accept(StateObjectVisitor visitor)
Visits this StateObject by the given visitor.

Parameters:
visitor - The visitor to visit this object

getExpression

public TrimExpression getExpression()
Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Specified by:
getExpression in interface StateObject
Overrides:
getExpression in class AbstractSingleEncapsulatedExpressionStateObject
Returns:
The parsed object when a JPQL query is parsed and converted into a StateObject or null when 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 this AbstractSingleEncapsulatedExpressionStateObject.

Specified by:
getIdentifier in class AbstractEncapsulatedExpressionStateObject
Returns:
The JPQL identifier that is shown before the left parenthesis

getQueryBNFId

protected java.lang.String getQueryBNFId()
Returns the unique identifier of the JPQLQueryBNF that will determine how to parse the encapsulated expression.

Specified by:
getQueryBNFId in class AbstractSingleEncapsulatedExpressionStateObject
Returns:
The non-null ID 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 the StateObject representing the trim character.

Returns:
The StateObject representing the trim character or null 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

public boolean isEquivalent(StateObject stateObject)
Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Specified by:
isEquivalent in interface StateObject
Overrides:
isEquivalent in class AbstractSingleEncapsulatedExpressionStateObject
Parameters:
stateObject - The StateObject to compare its content to this one
Returns:
true if both object are equivalent; false otherwise

parse

public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents the encapsulated expression, and creates the StateObject.

Overrides:
parse in class AbstractSingleEncapsulatedExpressionStateObject
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 a StateObject.

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 the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.

Parameters:
expression - The parsed object representing a TRIM expression

setSpecification

public void setSpecification(TrimExpression.Specification specification)
Sets the new trim specification.

Parameters:
specification - The new trim specification; null is not valid

setStateObject

public void setStateObject(StateObject stateObject)
Sets the given StateObject to represent the new encapsulated expression.

Overrides:
setStateObject in class AbstractSingleEncapsulatedExpressionStateObject
Parameters:
stateObject - The new encapsulated StateObject

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 or Character).

Parameters:
trimCharacter - The trim character or null to remove it

toTextEncapsulatedExpression

protected void toTextEncapsulatedExpression(java.lang.Appendable writer)
                                     throws java.io.IOException
Prints out a string representation of this encapsulated information, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.

Overrides:
toTextEncapsulatedExpression in class AbstractSingleEncapsulatedExpressionStateObject
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 because Appendable is used instead of StringBuilder for instance

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference