Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public Class TrimExpressionStateObject

extends AbstractSingleEncapsulatedExpressionStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, org.eclipse.persistence.jpa.jpql.Assert, org.eclipse.persistence.jpa.jpql.parser.FunctionsReturningStringsBNF, .JPQLExpression, .LiteralBNF, .StringPrimaryBNF, .TrimExpression, .TrimExpression.Specification

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)

Author
Pascal Filion
Since
2.4
Version
2.5
See Also
TrimExpression

Field Summary

Modifier and TypeField and Description
public static final String
HAS_FROM_PROPERTY

Notifies the visibility of the FROM identifier has changed.

private TrimExpression.Specification
specification

Defines the way the string is trimmed.

public static final String
SPECIFICATION_PROPERTY

Notifies the specification property has changed.

public static final String
TRIM_CHARACTER_PROPERTY

Notify the state object representing the trim character has changed.

private StateObject
trimCharacter

The trim character, if specified.

Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject:
STATE_OBJECT_PROPERTY

Constructor Summary

AccessConstructor and Description
public
TrimExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
)

Creates a new TrimExpressionStateObject.

public
TrimExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
TrimExpression.Specification
Defines the way the string is trimmed, or Specification.DEFAULT when it is not present
specification
,
StateObject
The StateObject representing the encapsulated expression
stateObject
)

Creates a new TrimExpressionStateObject.

public
TrimExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
TrimExpression.Specification
Defines the way the string is trimmed, or Specification.DEFAULT when it is not present
specification
,
StateObject
The trim character
trimCharacter
,
StateObject
The StateObject representing the encapsulated expression
stateObject
)

Creates a new TrimExpressionStateObject.

public
TrimExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
String
The portion of the query representing the encapsulated expression
jpqlFragment
)

Creates a new TrimExpressionStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public TrimExpression
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

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

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.getQueryBNFId.

Returns the unique identifier of the JPQLQueryBNF that will determine how to parse the encapsulated expression.
public TrimExpression.Specification

Returns:

The new trim specification; which is never null
getSpecification
()

Returns the new trim specification.

public StateObject

Returns:

The StateObject representing the trim character or null if it is not present
getTrimCharacter
()

Returns the StateObject representing the trim character.

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.

public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
public void
parse(String
The portion of the query representing the encapsulated expression
jpqlFragment
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.parse.

Parses the given JPQL fragment, which represents the encapsulated expression, and creates the StateObject.
public void
parseTrimCharacter(CharSequence
The portion of the query to parse
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.

public void
removeSpecification()

Removes the trim specification.

public void
removeTrimCharacter()

Removes the trim character if it is defined.

public void
setExpression(TrimExpression
The parsed object representing a TRIM expression
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.

public void
setSpecification(TrimExpression.Specification
The new trim specification; null is not valid
specification
)

Sets the new trim specification.

public void
setStateObject(StateObject
The new encapsulated StateObject
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.setStateObject.

Sets the given StateObject to represent the new encapsulated expression.
public void
setTrimCharacter(StateObject
The trim character or null to remove it
trimCharacter
)

Sets the character to trim from the string.

protected void
toTextEncapsulatedExpression(Appendable
The writer used to print out the string representation of the encapsulated information
writer
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.toTextEncapsulatedExpression.

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.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject:
addChildrengetStateObjecthasStateObject

Field Detail

HAS_FROM_PROPERTYback to summary
public static final String HAS_FROM_PROPERTY

Notifies the visibility of the FROM identifier has changed.

specificationback to summary
private TrimExpression.Specification specification

Defines the way the string is trimmed.

SPECIFICATION_PROPERTYback to summary
public static final String SPECIFICATION_PROPERTY

Notifies the specification property has changed.

TRIM_CHARACTER_PROPERTYback to summary
public static final String TRIM_CHARACTER_PROPERTY

Notify the state object representing the trim character has changed.

trimCharacterback to summary
private StateObject trimCharacter

The trim character, if specified.

Constructor Detail

TrimExpressionStateObjectback to summary
public TrimExpressionStateObject(StateObject parent)

Creates a new TrimExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
TrimExpressionStateObjectback to summary
public TrimExpressionStateObject(StateObject parent, TrimExpression.Specification specification, StateObject stateObject)

Creates a new TrimExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

specification:TrimExpression.Specification

Defines the way the string is trimmed, or Specification.DEFAULT when it is not present

stateObject:StateObject

The StateObject representing the encapsulated expression

Exceptions
NullPointerException:
The given parent cannot be null
TrimExpressionStateObjectback to summary
public TrimExpressionStateObject(StateObject parent, TrimExpression.Specification specification, StateObject trimCharacter, StateObject stateObject)

Creates a new TrimExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

specification:TrimExpression.Specification

Defines the way the string is trimmed, or Specification.DEFAULT when it is not present

trimCharacter:StateObject

The trim character

stateObject:StateObject

The StateObject representing the encapsulated expression

Exceptions
NullPointerException:
The given parent cannot be null
TrimExpressionStateObjectback to summary
public TrimExpressionStateObject(StateObject parent, String jpqlFragment)

Creates a new TrimExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

jpqlFragment:String

The portion of the query representing the encapsulated expression

Exceptions
NullPointerException:
The given parent cannot be null

Method Detail

acceptback to summary
public void accept(StateObjectVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Visits this StateObject by the given visitor.

Parameters
visitor:StateObjectVisitor

The visitor to visit this object

Annotations
@Override
getExpressionback to summary
public TrimExpression getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Returns:TrimExpression

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)

Annotations
@Override
getIdentifierback to summary
public String getIdentifier()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractEncapsulatedExpressionStateObject.getIdentifier.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractEncapsulatedExpressionStateObject.getIdentifier.

Returns the JPQL identifier of the expression represented by this AbstractSingleEncapsulatedExpressionStateObject.

Returns:String

The JPQL identifier that is shown before the left parenthesis

Annotations
@Override
getQueryBNFIdback to summary
protected String getQueryBNFId()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.getQueryBNFId.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.getQueryBNFId.

Returns the unique identifier of the JPQLQueryBNF that will determine how to parse the encapsulated expression.

Returns:String

The non-null ID of the BNF

Annotations
@Override
getSpecificationback to summary
public TrimExpression.Specification getSpecification()

Returns the new trim specification.

Returns:TrimExpression.Specification

The new trim specification; which is never null

getTrimCharacterback to summary
public StateObject getTrimCharacter()

Returns the StateObject representing the trim character.

Returns:StateObject

The StateObject representing the trim character or null if it is not present

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

isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Parameters
stateObject:StateObject

The StateObject to compare its content to this one

Returns:boolean

true if both object are equivalent; false otherwise

Annotations
@Override
parseback to summary
public void parse(String jpqlFragment)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.parse.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.parse.

Parses the given JPQL fragment, which represents the encapsulated expression, and creates the StateObject.

Parameters
jpqlFragment:String

The portion of the query representing the encapsulated expression

Annotations
@Override
parseTrimCharacterback to summary
public 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 a StateObject.

Parameters
jpqlFragment:CharSequence

The portion of the query to parse

removeSpecificationback to summary
public void removeSpecification()

Removes the trim specification.

removeTrimCharacterback to summary
public void removeTrimCharacter()

Removes the trim character if it is defined.

setExpressionback to summary
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:TrimExpression

The parsed object representing a TRIM expression

setSpecificationback to summary
public void setSpecification(TrimExpression.Specification specification)

Sets the new trim specification.

Parameters
specification:TrimExpression.Specification

The new trim specification; null is not valid

setStateObjectback to summary
public void setStateObject(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.setStateObject.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.setStateObject.

Sets the given StateObject to represent the new encapsulated expression.

Parameters
stateObject:StateObject

The new encapsulated StateObject

Annotations
@Override
setTrimCharacterback to summary
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:StateObject

The trim character or null to remove it

toTextEncapsulatedExpressionback to summary
protected void toTextEncapsulatedExpression(Appendable writer) throws IOException

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSingleEncapsulatedExpressionStateObject.toTextEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractEncapsulatedExpressionStateObject.toTextEncapsulatedExpression.

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.

Parameters
writer:Appendable

The writer used to print out the string representation of the encapsulated information

Annotations
@Override
Exceptions
IOException:
This should never happens, only required because Appendable is used instead of StringBuilder for instance