com.metamatrix.query.sql.lang
Class Command

java.lang.Object
  extended by com.metamatrix.query.sql.lang.Command
All Implemented Interfaces:
LanguageObject, java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BatchedUpdateCommand, Create, CreateUpdateProcedureCommand, Drop, DynamicCommand, ProcedureContainer, QueryCommand, XQuery

public abstract class Command
extends java.lang.Object
implements LanguageObject

A Command is an interface for all the language objects that are at the root of a language object tree representing a SQL statement. For instance, a Query command represents a SQL select query, an Update command represents a SQL update statement, etc.

See Also:
Serialized Form

Field Summary
protected  java.util.Map tempGroupIDs
          All temporary group IDs discovered while resolving this command.
static int TYPE_BATCHED_UPDATE
          Represents a batched sequence of UPDATE statements
static int TYPE_CREATE
           
static int TYPE_DELETE
          Represents a SQL DELETE statement
static int TYPE_DROP
           
static int TYPE_DYNAMIC
           
static int TYPE_INSERT
          Represents a SQL INSERT statement
static int TYPE_QUERY
          Represents a SQL SELECT statement
static int TYPE_SQL
          Represents any SQL statement, wrapped as a string
static int TYPE_STORED_PROCEDURE
          Represents a stored procedure command
static int TYPE_UNKNOWN
          Represents an unknown type of command
static int TYPE_UPDATE
          Represents a SQL UPDATE statement
static int TYPE_UPDATE_PROCEDURE
          Represents a update stored procedure command
static int TYPE_XQUERY
          Represents an XQuery
 
Constructor Summary
Command()
           
 
Method Summary
 void addExternalGroupsToContext(java.util.Collection groups)
           
 void addExternalGroupToContext(GroupSymbol group)
           
abstract  boolean areResultsCachable()
          Whether the results are cachable.
abstract  java.lang.Object clone()
          Implement clone to make objects cloneable.
protected  void copyMetadataState(Command copy)
           
 java.util.List getAllExternalGroups()
           
 GroupContext getExternalGroupContexts()
           
 Option getOption()
          Get the option clause for the query.
abstract  java.util.List<SingleElementSymbol> getProjectedSymbols()
          Get the ordered list of all elements returned by this query.
 java.util.List getSubCommands()
          Gets the subCommands (both embedded and non-embedded) under this command.
static int getSubCommandsUpdatingModelCount(LanguageObject object, QueryMetadataInterface metadata)
           
protected  int getSubCommandsUpdatingModelCount(QueryMetadataInterface metadata)
           
 java.util.Map getTemporaryMetadata()
           
abstract  int getType()
          Return type of command to make it easier to build switch statements by command type.
static java.util.List getUpdateCommandSymbol()
           
static java.util.List getUpdatesCommandSymbol()
           
 java.util.Map getVariableValues()
           
 GroupSymbol getVirtualGroup()
           
 boolean isResolved()
          Indicates whether this command has been resolved or not - attempting to resolve a command that has already been resolved has undefined results.
 java.lang.String printCommandTree()
          Print the full tree of commands with indentation - useful for debugging
protected  void printCommandTree(java.lang.StringBuffer str, int tabLevel)
          Helper method to print command tree at given tab level
 void pushNewResolvingContext(java.util.Collection groups)
           
 void setExternalGroupContexts(GroupContext root)
           
 void setIsResolved(boolean isResolved)
          This command is intended to only be used by the QueryResolver.
 void setOption(Option option)
          Set the option clause for the query.
 void setTemporaryMetadata(java.util.Map metadata)
           
 void setVariableValues(java.util.Map parameters)
           
 void setVirtualGroup(GroupSymbol virtualGroup)
           
 java.lang.String toString()
          Returns a string representation of an instance of this class.
abstract  int updatingModelCount(QueryMetadataInterface metadata)
          Return the number of updates on physical sources by this command.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.metamatrix.query.sql.LanguageObject
acceptVisitor
 

Field Detail

TYPE_UNKNOWN

public static final int TYPE_UNKNOWN
Represents an unknown type of command

See Also:
Constant Field Values

TYPE_QUERY

public static final int TYPE_QUERY
Represents a SQL SELECT statement

See Also:
Constant Field Values

TYPE_INSERT

public static final int TYPE_INSERT
Represents a SQL INSERT statement

See Also:
Constant Field Values

TYPE_UPDATE

public static final int TYPE_UPDATE
Represents a SQL UPDATE statement

See Also:
Constant Field Values

TYPE_DELETE

public static final int TYPE_DELETE
Represents a SQL DELETE statement

See Also:
Constant Field Values

TYPE_SQL

public static final int TYPE_SQL
Represents any SQL statement, wrapped as a string

See Also:
Constant Field Values

TYPE_STORED_PROCEDURE

public static final int TYPE_STORED_PROCEDURE
Represents a stored procedure command

See Also:
Constant Field Values

TYPE_UPDATE_PROCEDURE

public static final int TYPE_UPDATE_PROCEDURE
Represents a update stored procedure command

See Also:
Constant Field Values

TYPE_XQUERY

public static final int TYPE_XQUERY
Represents an XQuery

See Also:
Constant Field Values

TYPE_BATCHED_UPDATE

public static final int TYPE_BATCHED_UPDATE
Represents a batched sequence of UPDATE statements

See Also:
Constant Field Values

TYPE_DYNAMIC

public static final int TYPE_DYNAMIC
See Also:
Constant Field Values

TYPE_CREATE

public static final int TYPE_CREATE
See Also:
Constant Field Values

TYPE_DROP

public static final int TYPE_DROP
See Also:
Constant Field Values

tempGroupIDs

protected java.util.Map tempGroupIDs
All temporary group IDs discovered while resolving this command. The key is a TempMetadataID and the value is an ordered List of TempMetadataID representing the elements.

Constructor Detail

Command

public Command()
Method Detail

getType

public abstract int getType()
Return type of command to make it easier to build switch statements by command type.

Returns:
Type from TYPE constants

getSubCommands

public java.util.List getSubCommands()
Gets the subCommands (both embedded and non-embedded) under this command. In general the returned list is not safe to manipulate (see @link#CommandContainer insead)

Returns:

setTemporaryMetadata

public void setTemporaryMetadata(java.util.Map metadata)

getTemporaryMetadata

public java.util.Map getTemporaryMetadata()

addExternalGroupToContext

public void addExternalGroupToContext(GroupSymbol group)

addExternalGroupsToContext

public void addExternalGroupsToContext(java.util.Collection groups)

setExternalGroupContexts

public void setExternalGroupContexts(GroupContext root)

pushNewResolvingContext

public void pushNewResolvingContext(java.util.Collection groups)

getExternalGroupContexts

public GroupContext getExternalGroupContexts()

getAllExternalGroups

public java.util.List getAllExternalGroups()

isResolved

public boolean isResolved()
Indicates whether this command has been resolved or not - attempting to resolve a command that has already been resolved has undefined results. Also, caution should be taken in modifying a command which has already been resolved, as it could result in adding unresolved components to a supposedly resolved command.

Returns:
whether this command is resolved or not.

setIsResolved

public void setIsResolved(boolean isResolved)
This command is intended to only be used by the QueryResolver.

Parameters:
isResolved - whether this command is resolved or not

clone

public abstract java.lang.Object clone()
Description copied from interface: LanguageObject
Implement clone to make objects cloneable.

Specified by:
clone in interface LanguageObject
Overrides:
clone in class java.lang.Object
Returns:
Deep clone of this object

copyMetadataState

protected void copyMetadataState(Command copy)

printCommandTree

public java.lang.String printCommandTree()
Print the full tree of commands with indentation - useful for debugging

Returns:
String String representation of command tree

printCommandTree

protected void printCommandTree(java.lang.StringBuffer str,
                                int tabLevel)
Helper method to print command tree at given tab level

Parameters:
str - String buffer to add command sub tree to
tabLevel - Number of tabs to print this command at

getOption

public Option getOption()
Get the option clause for the query.

Returns:
option clause

setOption

public void setOption(Option option)
Set the option clause for the query.

Parameters:
option - New option clause

getProjectedSymbols

public abstract java.util.List<SingleElementSymbol> 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.

Returns:
Ordered list of SingleElementSymbol

areResultsCachable

public abstract boolean areResultsCachable()
Whether the results are cachable.

Returns:
True if the results are cachable; false otherwise.

getUpdateCommandSymbol

public static java.util.List getUpdateCommandSymbol()

getUpdatesCommandSymbol

public static java.util.List getUpdatesCommandSymbol()

updatingModelCount

public abstract int updatingModelCount(QueryMetadataInterface metadata)
                                throws MetaMatrixComponentException
Return the number of updates on physical sources by this command.

Parameters:
metadata - QueryMetadataInterface
Returns:
The number of updates on physical sources by this command.
Throws:
MetaMatrixComponentException
Since:
4.3

getSubCommandsUpdatingModelCount

protected int getSubCommandsUpdatingModelCount(QueryMetadataInterface metadata)
                                        throws MetaMatrixComponentException
Throws:
MetaMatrixComponentException

getSubCommandsUpdatingModelCount

public static int getSubCommandsUpdatingModelCount(LanguageObject object,
                                                   QueryMetadataInterface metadata)
                                            throws MetaMatrixComponentException
Throws:
MetaMatrixComponentException

getVirtualGroup

public GroupSymbol getVirtualGroup()

setVirtualGroup

public void setVirtualGroup(GroupSymbol virtualGroup)

getVariableValues

public java.util.Map getVariableValues()

setVariableValues

public void setVariableValues(java.util.Map parameters)

toString

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

Overrides:
toString in class java.lang.Object
Returns:
String representation of object


Copyright © 2009. All Rights Reserved.