com.metamatrix.query.sql.symbol
Class ScalarSubquery

java.lang.Object
  extended by com.metamatrix.query.sql.symbol.ScalarSubquery
All Implemented Interfaces:
SubqueryContainer, LanguageObject, Expression, ValueIteratorProvider, java.io.Serializable, java.lang.Cloneable

public class ScalarSubquery
extends java.lang.Object
implements Expression, SubqueryContainer, ValueIteratorProvider

This is an Expression implementation that can be used in a SELECT clause. It has a subquery Command which must only produce exactly one value (or an Exception will result during query processing). It's type will be the type of the one symbol to be produced. In theory an instance of this could be used wherever an Expression is legal, but it is specifically needed for the SELECT clause.

See Also:
Serialized Form

Constructor Summary
ScalarSubquery(Command subqueryCommand)
           
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 java.lang.Object clone()
          Returns a safe clone
 boolean equals(java.lang.Object obj)
          Compare this ScalarSubquery to another ScalarSubquery for equality.
 Command getCommand()
          Returns the subquery Command object
 java.lang.Class getType()
          Get the return type of this expression.
 ValueIterator getValueIterator()
          Returns always the same instance of a ValueIterator, but resets it each time this method is called
 int hashCode()
          Get hashcode for the object
 boolean isResolved()
          Return true if expression has been fully resolved.
 void setCommand(Command command)
          Sets the command.
 void setType(java.lang.Class type)
          Set type of ScalarSubquery
 void setValueIterator(ValueIterator valueIterator)
          Set the ValueIterator on this object (the ValueIterator will encapsulate the single-column results of the subquery processor plan).
 java.lang.String toString()
          Returns string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScalarSubquery

public ScalarSubquery(Command subqueryCommand)
Method Detail

getValueIterator

public ValueIterator getValueIterator()
Returns always the same instance of a ValueIterator, but resets it each time this method is called

Specified by:
getValueIterator in interface ValueIteratorProvider
Returns:
this object's ValueIterator instance (always the same instance)
Throws:
MetaMatrixRuntimeException - if the subquery for this set criteria has not yet been processed and no value iterator is available
See Also:
com.metamatrix.query.sql.lang.SubqueryLanguageObject#getValueIterator()

setValueIterator

public void setValueIterator(ValueIterator valueIterator)
Set the ValueIterator on this object (the ValueIterator will encapsulate the single-column results of the subquery processor plan). This ValueIterator must be set before processing (before the Criteria can be evaluated). Also, this ValueIterator should be considered transient - only available during processing - and it will not be cloned should this Criteria object be cloned.

Specified by:
setValueIterator in interface ValueIteratorProvider
Parameters:
valueIterator - encapsulating the results of the sub query

isResolved

public boolean isResolved()
Description copied from interface: Expression
Return true if expression has been fully resolved. Typically the QueryResolver component will handle resolution of an expression.

Specified by:
isResolved in interface Expression
Returns:
True if resolved
See Also:
Expression.isResolved()

getType

public java.lang.Class getType()
Description copied from interface: Expression
Get the return type of this expression. This method will not necessarily work right before resolution (Expression.isResolved() returns true).

Specified by:
getType in interface Expression
Returns:
Java class name
See Also:
Expression.getType()

setType

public void setType(java.lang.Class type)
Set type of ScalarSubquery

Parameters:
type - New type

getCommand

public Command getCommand()
Description copied from interface: SubqueryContainer
Returns the subquery Command object

Specified by:
getCommand in interface SubqueryContainer
Returns:
the subquery Command object
See Also:
com.metamatrix.query.sql.lang.SubqueryLanguageObject#getCommand()

setCommand

public void setCommand(Command command)
Sets the command. Also modifies the hash code of this object, so caution should be used in using this method.

Specified by:
setCommand in interface SubqueryContainer
Parameters:
command - the subquery Command object
See Also:
com.metamatrix.query.sql.lang.SubqueryLanguageObject#setCommand()

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.

Specified by:
acceptVisitor in interface LanguageObject
Parameters:
visitor - Visitor being used

equals

public boolean equals(java.lang.Object obj)
Compare this ScalarSubquery to another ScalarSubquery for equality.

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

hashCode

public int hashCode()
Get hashcode for the object

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

clone

public java.lang.Object clone()
Returns a safe clone

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

toString

public java.lang.String toString()
Returns string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
String representing the object


Copyright © 2009. All Rights Reserved.