EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

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

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

public class UpdateItemStateObject
extends AbstractStateObject

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

Version:
2.4
See Also:
UpdateItem
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String NEW_VALUE_PROPERTY
          Notifies the new value property has changed.
 
Constructor Summary
UpdateItemStateObject(UpdateClauseStateObject parent)
          Creates a new UpdateItemStateObject.
UpdateItemStateObject(UpdateClauseStateObject parent, java.lang.String path, StateObject newValue)
          Creates a new UpdateItemStateObject.
UpdateItemStateObject(UpdateClauseStateObject parent, java.lang.String path, java.lang.String newValue)
          Creates a new UpdateItemStateObject.
 
Method Summary
 void accept(StateObjectVisitor visitor)
          Visits this StateObject by the given visitor.
protected  void addChildren(java.util.List<StateObject> children)
          Adds the children of this StateObject to the given list.
 void appendToPath(java.lang.String text)
          Appends the given sequence of characters to the path expression.
 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.
 UpdateItem getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 StateObject getNewValue()
          Returns the StateObject representing the new value.
 UpdateClauseStateObject getParent()
          Returns the parent of this StateObject.
 java.lang.String getPath()
          Returns the string representation of the path expression.
 StateFieldPathExpressionStateObject getStateFieldPath()
          Returns
 boolean hasNewValue()
          Determines whether the StateObject representing the new value is present.
protected  void initialize()
          Initializes this state object.
 boolean isEquivalent(StateObject stateObject)
          Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
 IterableListIterator<java.lang.String> items()
          Returns the segments in the state field path in order.
 int itemsSize()
          Returns the number of segments in the path expression.
 void parseNewValue(java.lang.String newValue)
          Parses the given JPQL fragment, which represents the new value.
 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.
 void setNewValue(StateObject newValue)
          Sets the new value to be the given StateObject.
 void setPath(java.lang.String path)
          Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.
 void setPaths(java.util.ListIterator<java.lang.String> paths)
          Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.
 void setPaths(java.lang.String[] paths)
          Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.
 void setVirtualIdentificationVariable(java.lang.String identificationVariable)
          The state field path expression is not qualified by the identification variable.
protected  void toTextInternal(java.lang.Appendable writer)
          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.
 
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, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, 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

NEW_VALUE_PROPERTY

public static final java.lang.String NEW_VALUE_PROPERTY
Notifies the new value property has changed.

See Also:
Constant Field Values
Constructor Detail

UpdateItemStateObject

public UpdateItemStateObject(UpdateClauseStateObject parent)
Creates a new UpdateItemStateObject.

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

UpdateItemStateObject

public UpdateItemStateObject(UpdateClauseStateObject parent,
                             java.lang.String path,
                             StateObject newValue)
Creates a new UpdateItemStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
path - The state field path to receive the new value
newValue - The actual expression representing the new value
Throws:
java.lang.NullPointerException - The given parent cannot be null

UpdateItemStateObject

public UpdateItemStateObject(UpdateClauseStateObject parent,
                             java.lang.String path,
                             java.lang.String newValue)
Creates a new UpdateItemStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
path - The state field path to receive the new value
newValue - The JPQL fragment representing the new value
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

addChildren

protected void addChildren(java.util.List<StateObject> children)
Adds the children of this StateObject to the given list.

Overrides:
addChildren in class AbstractStateObject
Parameters:
children - The list used to store the children

appendToPath

public void appendToPath(java.lang.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 - The sequence of characters to append to the path expression

getBuilder

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:
A new builder that can be used to quickly create a new value expression

getExpression

public UpdateItem 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 AbstractStateObject
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)

getNewValue

public StateObject getNewValue()
Returns the StateObject representing the new value.

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

getParent

public UpdateClauseStateObject getParent()
Returns the parent of this StateObject.

Specified by:
getParent in interface StateObject
Overrides:
getParent in class AbstractStateObject
Returns:
Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

getPath

public java.lang.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:
The path expression, which is never null

getStateFieldPath

public StateFieldPathExpressionStateObject getStateFieldPath()
Returns

Returns:

hasNewValue

public boolean hasNewValue()
Determines whether the StateObject representing the new value is present.

Returns:
true the new value exists; otherwise false

initialize

protected void initialize()
Initializes this state object.

Overrides:
initialize in class AbstractStateObject

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 AbstractStateObject
Parameters:
stateObject - The StateObject to compare its content to this one
Returns:
true if both object are equivalent; false otherwise

items

public IterableListIterator<java.lang.String> items()
Returns the segments in the state field path in order.

Returns:
An IterableListIterator over the paths of the state field path

itemsSize

public int itemsSize()
Returns the number of segments in the path expression.

Returns:
The number of segments

parseNewValue

public void parseNewValue(java.lang.String newValue)
Parses the given JPQL fragment, which represents the new value.

Parameters:
newValue - The string representation of the new value to parse and to convert into a StateObject

setExpression

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 - The parsed object representing an update item

setNewValue

public void setNewValue(StateObject newValue)
Sets the new value to be the given StateObject.

Parameters:
newValue - The StateObject representing the new value

setPath

public void setPath(java.lang.String path)
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters:
path - The new path expression

setPaths

public void setPaths(java.util.ListIterator<java.lang.String> paths)
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters:
paths - The new path expression

setPaths

public void setPaths(java.lang.String[] paths)
Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters:
paths - The new path expression

setVirtualIdentificationVariable

public void setVirtualIdentificationVariable(java.lang.String identificationVariable)
The state field path expression is not qualified by the identification variable.

Parameters:
identificationVariable - The virtual variable that was generated based on the entity name

toTextInternal

protected void toTextInternal(java.lang.Appendable writer)
                       throws java.io.IOException
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.

Specified by:
toTextInternal in class AbstractStateObject
Parameters:
writer - The writer used to print out the string representation
Throws:
java.io.IOException - This should never happens, it is only required because Appendable is used instead of any concrete class

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference