com.metamatrix.query.sql.lang
Class Insert

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.Insert
All Implemented Interfaces:
CommandContainer, LanguageObject, java.io.Serializable, java.lang.Cloneable

public class Insert
extends ProcedureContainer

Represents a SQL Insert statement of the form: "INSERT INTO () VALUES ".

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
Insert()
          Constructs a default instance of this class.
Insert(GroupSymbol group, java.util.List variables, java.util.List values)
          Construct an instance with group, variable list (may be null), and values
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 void addValue(Expression value)
          Adds a value to the list of values
 void addVariable(ElementSymbol var)
          Add a variable to end of list
 void addVariables(java.util.Collection vars)
          Add a collection of variables to end of list
 boolean areResultsCachable()
          Whether the results are cachable.
 java.lang.Object clone()
          Return a deep copy of this Insert.
 boolean equals(java.lang.Object obj)
          Compare two Insert commands for equality.
 GroupSymbol getGroup()
          Returns the group being inserted into
 java.util.Map getProcedureParameters()
           
 java.util.List getProjectedSymbols()
          Get the ordered list of all elements returned by this query.
 QueryCommand getQueryExpression()
           
 int getType()
          Return type of command.
 java.util.List getValues()
          Returns a list of values to insert to be inserted.
 java.util.List getVariables()
          Return an ordered List of variables, may be null if no columns were specified
 int hashCode()
          Get hashcode for command.
 boolean isBulk()
           
 void setGroup(GroupSymbol group)
          Set the group for this insert statement
 void setQueryExpression(QueryCommand query)
           
 void setValues(java.util.List values)
          Sets the values to be inserted.
 void setVariables(java.util.Collection vars)
          Set a collection of variables that replace the existing variables
 
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, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Insert

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


Insert

public Insert(GroupSymbol group,
              java.util.List variables,
              java.util.List values)
Construct an instance with group, variable list (may be null), and values

Parameters:
group - Group associated with this insert
variables - List of ElementSymbols that represent columns for the values, null implies all columns
values - List of Expression values to be inserted
Method Detail

getType

public int getType()
Return type of command.

Specified by:
getType in class Command
Returns:
TYPE_INSERT

getGroup

public GroupSymbol getGroup()
Returns the group being inserted into

Specified by:
getGroup in class ProcedureContainer
Returns:
Group being inserted into

setGroup

public void setGroup(GroupSymbol group)
Set the group for this insert statement

Parameters:
group - Group to be inserted into

isBulk

public boolean isBulk()

getVariables

public java.util.List getVariables()
Return an ordered List of variables, may be null if no columns were specified

Returns:
List of ElementSymbol

addVariable

public void addVariable(ElementSymbol var)
Add a variable to end of list

Parameters:
var - Variable to add to the list

addVariables

public void addVariables(java.util.Collection vars)
Add a collection of variables to end of list

Parameters:
vars - Variables to add to the list - collection of ElementSymbol

getValues

public java.util.List getValues()
Returns a list of values to insert to be inserted.

Returns:
List of Expressions

setValues

public void setValues(java.util.List values)
Sets the values to be inserted.

Parameters:
values - List of Expressions

setVariables

public void setVariables(java.util.Collection vars)
Set a collection of variables that replace the existing variables

Parameters:
vars - Variables to be set on this object (ElementSymbols)

addValue

public void addValue(Expression value)
Adds a value to the list of values

Parameters:
value - Expression to be added to the list of values

setQueryExpression

public void setQueryExpression(QueryCommand query)

getQueryExpression

public QueryCommand getQueryExpression()

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, variables. 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 for object

equals

public boolean equals(java.lang.Object obj)
Compare two Insert commands for equality. Will only evaluate to equal if they are IDENTICAL: group is equal, value is equal and variables are equal.

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

getProcedureParameters

public java.util.Map getProcedureParameters()
Specified by:
getProcedureParameters in class ProcedureContainer
Since:
5.0
See Also:
com.metamatrix.query.sql.lang.ProcedureContainer#getParameters()

clone

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

Specified by:
clone in interface LanguageObject
Specified by:
clone in class Command
Returns:
Deep copy of Insert

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()


Copyright © 2009. All Rights Reserved.