com.metamatrix.query.sql.lang
Class Update

java.lang.Object
  extended by com.metamatrix.query.sql.lang.Command
      extended by com.metamatrix.query.sql.lang.ProcedureContainer
          extended by com.metamatrix.query.sql.lang.Update
All Implemented Interfaces:
CommandContainer, LanguageObject, java.io.Serializable, java.lang.Cloneable

public class Update
extends ProcedureContainer

Represents a SQL Update statement of the form: "UPDATE SET = , ... [WHERE ]".

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.metamatrix.query.sql.lang.Command
tempGroupIDs, TYPE_BATCHED_UPDATE, TYPE_CREATE, TYPE_DELETE, TYPE_DROP, TYPE_DYNAMIC, TYPE_INSERT, TYPE_QUERY, TYPE_SQL, TYPE_STORED_PROCEDURE, TYPE_UNKNOWN, TYPE_UPDATE, TYPE_UPDATE_PROCEDURE, TYPE_XQUERY
 
Constructor Summary
Update()
          Constructs a default instance of this class.
Update(GroupSymbol group, SetClauseList changeList)
          Construct with group and change list
Update(GroupSymbol group, SetClauseList changeList, Criteria criteria)
          Construct with group, change list, and criteria
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 void addChange(ElementSymbol id, Expression value)
          Add change to change list - a change is represented by a CompareCriteria internally but can be added here as an element and an expression
 boolean areResultsCachable()
          Whether the results are cachable.
 java.lang.Object clone()
          Return a copy of this Update.
 boolean equals(java.lang.Object obj)
          Compare two update commands for equality.
 SetClauseList getChangeList()
          Return the list of CompareCriteria representing updates being made
 Criteria getCriteria()
          Returns the criteria object for this command, may be null
 GroupSymbol getGroup()
          Returns the group being updated
 java.util.Map getProcedureParameters()
           
 java.util.List getProjectedSymbols()
          Get the ordered list of all elements returned by this query.
 int getType()
          Return type of command.
 int hashCode()
          Get hashcode for command.
 void setChangeList(SetClauseList changeList)
          Set the list of CompareCriteria representing updates being made
 void setCriteria(Criteria criteria)
          Set the criteria for this Update command
 void setGroup(GroupSymbol group)
          Set the group being updated
 java.lang.String toString()
          Returns a string representation of an instance of this class.
 
Methods inherited from class com.metamatrix.query.sql.lang.ProcedureContainer
copyMetadataState, getContainedCommands, getSubCommand, getUpdateCount, setSubCommand, setUpdateCount, updatingModelCount
 
Methods inherited from class com.metamatrix.query.sql.lang.Command
addExternalGroupsToContext, addExternalGroupToContext, getAllExternalGroups, getCorrelatedReferences, getExternalGroupContexts, getOption, getProcessorPlan, getSubCommands, getSubCommandsUpdatingModelCount, getSubCommandsUpdatingModelCount, getTemporaryMetadata, getUpdateCommandSymbol, getVirtualGroup, isResolved, printCommandTree, printCommandTree, pushNewResolvingContext, setCorrelatedReferences, setExternalGroupContexts, setIsResolved, setOption, setProcessorPlan, setTemporaryMetadata, setVirtualGroup
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Update

public Update()
Constructs a default instance of this class.


Update

public Update(GroupSymbol group,
              SetClauseList changeList)
Construct with group and change list

Parameters:
group - Group to by updated
changeList - List of CompareCriteria that represent Element->expression updates

Update

public Update(GroupSymbol group,
              SetClauseList changeList,
              Criteria criteria)
Construct with group, change list, and criteria

Parameters:
group - DataGroupID that represents the group being updated
List - of changeCriteria that represent Element->value pairings
criteria - Criteria that defines what rows get updated
Method Detail

getType

public int getType()
Return type of command.

Specified by:
getType in class Command
Returns:
TYPE_UPDATE

getGroup

public GroupSymbol getGroup()
Returns the group being updated

Specified by:
getGroup in class ProcedureContainer
Returns:
Group being updated

setGroup

public void setGroup(GroupSymbol group)
Set the group being updated

Parameters:
group - Group being updated

setChangeList

public void setChangeList(SetClauseList changeList)
Set the list of CompareCriteria representing updates being made

Parameters:
changeList - List of CompareCriteria

getChangeList

public SetClauseList getChangeList()
Return the list of CompareCriteria representing updates being made

Returns:
List of CompareCriteria

addChange

public void addChange(ElementSymbol id,
                      Expression value)
Add change to change list - a change is represented by a CompareCriteria internally but can be added here as an element and an expression

Parameters:
id - Element to be changed
value - Expression, often a value, being set

getCriteria

public Criteria getCriteria()
Returns the criteria object for this command, may be null

Returns:
Criteria, may be null

setCriteria

public void setCriteria(Criteria criteria)
Set the criteria for this Update command

Parameters:
criteria - Criteria to be associated with this command

acceptVisitor

public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface: LanguageObject
Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.

Parameters:
visitor - Visitor being used

hashCode

public int hashCode()
Get hashcode for command. WARNING: This hash code relies on the hash codes of the Group, changeList and Criteria clause. If the command changes, it's hash code will change and it can be lost from collections. Hash code is only valid after command has been completely constructed.

Overrides:
hashCode in class java.lang.Object
Returns:
Hash code

toString

public java.lang.String toString()
Returns a string representation of an instance of this class.

Overrides:
toString in class Command
Returns:
String representation of object

equals

public boolean equals(java.lang.Object obj)
Compare two update commands for equality. Will only evaluate to equal if they are IDENTICAL: group is equal, changeList contains same compareCriteria, criteria are in the same exact structure.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Other object
Returns:
True if equal

clone

public java.lang.Object clone()
Return a copy of this Update.

Specified by:
clone in interface LanguageObject
Specified by:
clone in class Command
Returns:
Deep clone

getProjectedSymbols

public java.util.List getProjectedSymbols()
Get the ordered list of all elements returned by this query. These elements may be ElementSymbols or ExpressionSymbols but in all cases each represents a single column.

Specified by:
getProjectedSymbols in class Command
Returns:
Ordered list of SingleElementSymbol

areResultsCachable

public boolean areResultsCachable()
Description copied from class: Command
Whether the results are cachable.

Specified by:
areResultsCachable in class Command
Returns:
True if the results are cachable; false otherwise.
See Also:
Command.areResultsCachable()

getProcedureParameters

public java.util.Map getProcedureParameters()
Specified by:
getProcedureParameters in class ProcedureContainer
Since:
5.0
See Also:
ProcedureContainer.getProcedureParameters()


Copyright © 2009. All Rights Reserved.