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

public Class UpdateItemStateObject

extends AbstractStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.List, .ListIterator, org.eclipse.persistence.jpa.jpql.parser.NewValueBNF, .UpdateItem, org.eclipse.persistence.jpa.jpql.tools.model.INewValueStateObjectBuilder, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable

The new_value specified for an update operation must be compatible in type with the field to which it is assigned.

BNF: update_item ::= [identification_variable.]{state_field | single_valued_association_field} = new_value

Author
Pascal Filion
Since
2.4
Version
2.5
See Also
UpdateItem

Field Summary

Modifier and TypeField and Description
private INewValueStateObjectBuilder
builder

The builder is cached during the creation of the new value expression.

public static final String
NEW_VALUE_PROPERTY

Notifies the new value property has changed.

private StateObject
newValue

The state object representing the new value.

private StateFieldPathExpressionStateObject
stateFieldPath

The state object representing the state field path expression.

Constructor Summary

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

Creates a new UpdateItemStateObject.

public
UpdateItemStateObject(UpdateClauseStateObject
The parent of this state object, which cannot be null
parent
,
String
The state field path to receive the new value
path
,
StateObject
The actual expression representing the new value
newValue
)

Creates a new UpdateItemStateObject.

public
UpdateItemStateObject(UpdateClauseStateObject
The parent of this state object, which cannot be null
parent
,
String
The state field path to receive the new value
path
,
String
The JPQL fragment representing the new value
newValue
)

Creates a new UpdateItemStateObject.

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
appendToPath(String
The sequence of characters to append to the path expression
text
)

Appends the given sequence of characters to the path expression.

public INewValueStateObjectBuilder

Returns:

A new builder that can be used to quickly create a new value expression
getBuilder
()

Creates and returns a new INewValueStateObjectBuilder that can be used to programmatically create a new value expression and once the expression is complete, INewValueStateObjectBuilder#commit() will push the StateObject representation of that expression as this new value object.

public UpdateItem
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 new value expression or null if it's not yet defined
getNewValue
()

Returns the StateObject representing the new value.

public UpdateClauseStateObject
public String

Returns:

The path expression, which is never null
getPath
()

Returns the string representation of the path expression.

public StateFieldPathExpressionStateObject
public boolean

Returns:

true the new value exists; otherwise false
hasNewValue
()

Determines whether the StateObject representing the new value is present.

protected void
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 ListIterable<String>

Returns:

An ListIterable over the paths of the state field path
items
()

Returns the segments in the state field path in order.

public int

Returns:

The number of segments
itemsSize
()

Returns the number of segments in the path expression.

public void
parseNewValue(String
The string representation of the new value to parse and to convert into a StateObject
newValue
)

Parses the given JPQL fragment, which represents the new value.

public void
setExpression(UpdateItem
The parsed object representing an update item
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
setNewValue(StateObject
The StateObject representing the new value
newValue
)

Sets the new value to be the given StateObject.

public void
setPath(String
The new path expression
path
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setPaths(ListIterator<String>
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setPaths(String[]
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setVirtualIdentificationVariable(String
The virtual variable that was generated based on the entity name
identificationVariable
)

The state field path expression is not qualified by the identification variable.

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:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

builderback to summary
private INewValueStateObjectBuilder builder

The builder is cached during the creation of the new value expression.

NEW_VALUE_PROPERTYback to summary
public static final String NEW_VALUE_PROPERTY

Notifies the new value property has changed.

newValueback to summary
private StateObject newValue

The state object representing the new value.

stateFieldPathback to summary
private StateFieldPathExpressionStateObject stateFieldPath

The state object representing the state field path expression.

Constructor Detail

UpdateItemStateObjectback to summary
public UpdateItemStateObject(UpdateClauseStateObject parent)

Creates a new UpdateItemStateObject.

Parameters
parent:UpdateClauseStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
UpdateItemStateObjectback to summary
public UpdateItemStateObject(UpdateClauseStateObject parent, String path, StateObject newValue)

Creates a new UpdateItemStateObject.

Parameters
parent:UpdateClauseStateObject

The parent of this state object, which cannot be null

path:String

The state field path to receive the new value

newValue:StateObject

The actual expression representing the new value

Exceptions
NullPointerException:
The given parent cannot be null
UpdateItemStateObjectback to summary
public UpdateItemStateObject(UpdateClauseStateObject parent, String path, String newValue)

Creates a new UpdateItemStateObject.

Parameters
parent:UpdateClauseStateObject

The parent of this state object, which cannot be null

path:String

The state field path to receive the new value

newValue:String

The JPQL fragment representing the new value

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
appendToPathback to summary
public void appendToPath(String text)

Appends the given sequence of characters to the path expression. If the sequence does not begin with a dot, then the first segment will be appended to the last segment and then new segments will be created.

Parameters
text:String

The sequence of characters to append to the path expression

getBuilderback to summary
public INewValueStateObjectBuilder getBuilder()

Creates and returns a new INewValueStateObjectBuilder that can be used to programmatically create a new value expression and once the expression is complete, INewValueStateObjectBuilder#commit() will push the StateObject representation of that expression as this new value object.

Returns:INewValueStateObjectBuilder

A new builder that can be used to quickly create a new value expression

getExpressionback to summary
public UpdateItem 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:UpdateItem

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
getNewValueback to summary
public StateObject getNewValue()

Returns the StateObject representing the new value.

Returns:StateObject

The new value expression or null if it's not yet defined

getParentback to summary
public UpdateClauseStateObject getParent()

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

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

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

Returns the parent of this StateObject.

Returns:UpdateClauseStateObject

Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

Annotations
@Override
getPathback to summary
public String getPath()

Returns the string representation of the path expression. If the identification variable is virtual, then it is not part of the result.

Returns:String

The path expression, which is never null

getStateFieldPathback to summary
public StateFieldPathExpressionStateObject getStateFieldPath()

Returns

hasNewValueback to summary
public boolean hasNewValue()

Determines whether the StateObject representing the new value is present.

Returns:boolean

true the new value exists; otherwise false

initializeback to summary
protected void initialize()

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

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

Initializes this state object.

Annotations
@Override
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
itemsback to summary
public ListIterable<String> items()

Returns the segments in the state field path in order.

Returns:ListIterable<String>

An ListIterable over the paths of the state field path

itemsSizeback to summary
public int itemsSize()

Returns the number of segments in the path expression.

Returns:int

The number of segments

parseNewValueback to summary
public void parseNewValue(String newValue)

Parses the given JPQL fragment, which represents the new value.

Parameters
newValue:String

The string representation of the new value to parse and to convert into a StateObject

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

The parsed object representing an update item

setNewValueback to summary
public void setNewValue(StateObject newValue)

Sets the new value to be the given StateObject.

Parameters
newValue:StateObject

The StateObject representing the new value

setPathback to summary
public void setPath(String path)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
path:String

The new path expression

setPathsback to summary
public void setPaths(ListIterator<String> paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:ListIterator<String>

The new path expression

setPathsback to summary
public void setPaths(String[] paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:String[]

The new path expression

setVirtualIdentificationVariableback to summary
public void setVirtualIdentificationVariable(String identificationVariable)

The state field path expression is not qualified by the identification variable.

Parameters
identificationVariable:String

The virtual variable that was generated based on the entity name

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