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

public Class ArithmeticFactorStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.parser.ArithmeticFactor, .ArithmeticFactorBNF

This state object simply adds a plus or minus sign to the arithmetic primary expression.

BNF: arithmetic_factor ::= [{+|-}] arithmetic_primary

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
ArithmeticFactor

Field Summary

Modifier and TypeField and Description
public static final String
ARITHMETIC_SIGN_PROPERTY

Notifies the arithmetic sign property has changed.

private boolean
plusSign

true if the arithmetic sign is the plus sign; false otherwise.

public static final String
STATE_OBJECT_PROPERTY

Notifies the state object property has changed.

private StateObject
stateObject

The StateObject that represents the arithmetic primary expression.

Constructor Summary

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

Creates a new ArithmeticFactorStateObject.

public
ArithmeticFactorStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
boolean plusSign, StateObject
The StateObject that represents the arithmetic primary expression
stateObject
)

Creates a new ArithmeticFactorStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
protected void
addChildren(List<StateObject>
The list used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.
public void
addMinus()

Makes sure the - sign is used.

public void
addPlus()

Makes sure the + sign is used.

public String

Returns:

The single character value of the arithmetic sign: '+' or '-'
getArithmeticSign
()

Returns the arithmetic sign this expression is actually representing.

public ArithmeticFactor
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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 StateObject

Returns:

The StateObject that represents the arithmetic primary expression or null if none was specified
getStateObject
()

Returns the StateObject that represents the arithmetic primary expression.

public boolean

Returns:

true if the arithmetic sign is the minus sign; false if it is the plus sign
hasMinusSign
()

Determines whether the arithmetic sign is the minus sign.

public boolean

Returns:

true if the arithmetic sign is the plus sign; false if it is the minus sign
hasPlusSign
()

Determines whether the arithmetic sign is the plus sign.

public boolean

Returns:

true if there is the arithmetic primary expression exists; false otherwise
hasStateObject
()

Determines whether an StateObject representing the arithmetic primary expression exists.

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

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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
A portion of a query that will be parsed and the StateObject that was created will become the new arithmetic primary of this ArithmeticFactorStateObject
jpqlFragment
)

Parses the given JPQL fragment to become the new arithmetic primary.

public void
setArithmeticSign(boolean
The single character value of the arithmetic sign: '+' (true) or '-' (false)
plusSign
)

Sets the arithmetic sign this expression is actually representing.

public void
setExpression(ArithmeticFactor
The parsed object representing an arithmetic factor 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
setStateObject(StateObject
The StateObject that represents the arithmetic primary expression or null if none was specified
stateObject
)

Returns the StateObject that represents the arithmetic primary expression.

public void
toggleArithmeticSign()

Toggles the arithmetic sign, plus becomes minus and vice versa.

protected void
toTextInternal(Appendable
The writer used to print out the string representation
writer
)

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Prints out a string representation of this StateObject, 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.AbstractStateObject:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetParentgetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeinitializeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

ARITHMETIC_SIGN_PROPERTYback to summary
public static final String ARITHMETIC_SIGN_PROPERTY

Notifies the arithmetic sign property has changed.

plusSignback to summary
private boolean plusSign

true if the arithmetic sign is the plus sign; false otherwise.

STATE_OBJECT_PROPERTYback to summary
public static final String STATE_OBJECT_PROPERTY

Notifies the state object property has changed.

stateObjectback to summary
private StateObject stateObject

The StateObject that represents the arithmetic primary expression.

Constructor Detail

ArithmeticFactorStateObjectback to summary
public ArithmeticFactorStateObject(StateObject parent)

Creates a new ArithmeticFactorStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
ArithmeticFactorStateObjectback to summary
public ArithmeticFactorStateObject(StateObject parent, boolean plusSign, StateObject stateObject)

Creates a new ArithmeticFactorStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

stateObject:StateObject

The StateObject that represents the arithmetic primary 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
addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.

Parameters
children:List<StateObject>

The list used to store the children

Annotations
@Override
addMinusback to summary
public void addMinus()

Makes sure the - sign is used.

addPlusback to summary
public void addPlus()

Makes sure the + sign is used.

getArithmeticSignback to summary
public String getArithmeticSign()

Returns the arithmetic sign this expression is actually representing.

Returns:String

The single character value of the arithmetic sign: '+' or '-'

getExpressionback to summary
public ArithmeticFactor getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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:ArithmeticFactor

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
getStateObjectback to summary
public StateObject getStateObject()

Returns the StateObject that represents the arithmetic primary expression.

Returns:StateObject

The StateObject that represents the arithmetic primary expression or null if none was specified

hasMinusSignback to summary
public boolean hasMinusSign()

Determines whether the arithmetic sign is the minus sign.

Returns:boolean

true if the arithmetic sign is the minus sign; false if it is the plus sign

hasPlusSignback to summary
public boolean hasPlusSign()

Determines whether the arithmetic sign is the plus sign.

Returns:boolean

true if the arithmetic sign is the plus sign; false if it is the minus sign

hasStateObjectback to summary
public boolean hasStateObject()

Determines whether an StateObject representing the arithmetic primary expression exists.

Returns:boolean

true if there is the arithmetic primary expression exists; false otherwise

isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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)

Parses the given JPQL fragment to become the new arithmetic primary.

Parameters
jpqlFragment:String

A portion of a query that will be parsed and the StateObject that was created will become the new arithmetic primary of this ArithmeticFactorStateObject

setArithmeticSignback to summary
public void setArithmeticSign(boolean plusSign)

Sets the arithmetic sign this expression is actually representing.

Parameters
plusSign:boolean

The single character value of the arithmetic sign: '+' (true) or '-' (false)

setExpressionback to summary
public void setExpression(ArithmeticFactor 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:ArithmeticFactor

The parsed object representing an arithmetic factor expression

setStateObjectback to summary
public void setStateObject(StateObject stateObject)

Returns the StateObject that represents the arithmetic primary expression.

Parameters
stateObject:StateObject

The StateObject that represents the arithmetic primary expression or null if none was specified

toggleArithmeticSignback to summary
public void toggleArithmeticSign()

Toggles the arithmetic sign, plus becomes minus and vice versa.

toTextInternalback to summary
protected void toTextInternal(Appendable writer) throws IOException

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Prints out a string representation of this StateObject, 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

Annotations
@Override
Exceptions
IOException:
This should never happens, it is only required because Appendable is used instead of any concrete class