com.metamatrix.query.sql.symbol
Class Function

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

public class Function
extends java.lang.Object
implements Expression

Represents a function in a sql statement. A function is a type of expression. Functions have a name and some arguments (0..n). Each argument is also an expression. After resolution, a function should have a type and a function descriptor.

See Also:
Serialized Form

Constructor Summary
Function(java.lang.String name, Expression[] args)
          Construct a function with function name and array of arguments.
 
Method Summary
 void acceptVisitor(LanguageVisitor visitor)
          Method for accepting a visitor.
 java.lang.Object clone()
          Return a deep copy of this object.
 boolean equals(java.lang.Object obj)
          Compare for equality
 Expression getArg(int index)
          Get argument at specified index
 Expression[] getArgs()
          Get function arguments
 FunctionDescriptor getFunctionDescriptor()
          Get the function descriptor that this function resolves to.
 java.lang.String getName()
          Get name of function
 java.lang.Class getType()
          Get type of function, if known
 int hashCode()
          Compute hash code for the object - based on name and hashcode of first arg (if there is one)
 void insertConversion(int index, FunctionDescriptor functionDescriptor)
          Insert a conversion function at specified index.
 boolean isImplicit()
          Return true if this function is implicit and should not be shown in SQL representations
 boolean isResolved()
          Return true if expression has been fully resolved.
 void makeImplicit()
          Make this function implicit / hidden.
 void setArgs(Expression[] args)
          Set the function arguments - it is assumed that the args are not null.
 void setFunctionDescriptor(FunctionDescriptor fd)
          Set the descriptor for this function.
 void setName(java.lang.String name)
           
 void setType(java.lang.Class type)
          Set type of function
 java.lang.String toString()
          Return string representation of the function.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Function

public Function(java.lang.String name,
                Expression[] args)
Construct a function with function name and array of arguments. For functions that have no args, pass empty array, not null.

Parameters:
name - Name of function
args - Function arguments
Method Detail

getName

public java.lang.String getName()
Get name of function

Returns:
Name of function

setName

public void setName(java.lang.String name)

getArgs

public Expression[] getArgs()
Get function arguments

Returns:
Get function arguments

getArg

public Expression getArg(int index)
Get argument at specified index

Parameters:
index - Index of argument

setArgs

public void setArgs(Expression[] args)
Set the function arguments - it is assumed that the args are not null. For no arg functions, use an empty Expression array.

Parameters:
args - Function arguments

makeImplicit

public void makeImplicit()
Make this function implicit / hidden.


isImplicit

public boolean isImplicit()
Return true if this function is implicit and should not be shown in SQL representations

Returns:
True if implicit

insertConversion

public void insertConversion(int index,
                             FunctionDescriptor functionDescriptor)
Insert a conversion function at specified index. This is a convenience method to insert a conversion into the function tree.

Parameters:
index - Argument index to insert conversion function at
functionDescriptor - Conversion function descriptor

getType

public java.lang.Class getType()
Get type of function, if known

Specified by:
getType in interface Expression
Returns:
Java class name of type, or null if not yet resolved

setType

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

Parameters:
type - New type

getFunctionDescriptor

public FunctionDescriptor getFunctionDescriptor()
Get the function descriptor that this function resolves to.

Returns:
Descriptor or null if resolution has not yet occurred

setFunctionDescriptor

public void setFunctionDescriptor(FunctionDescriptor fd)
Set the descriptor for this function.

Parameters:
fd - Function descriptor

isResolved

public boolean isResolved()
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

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 for equality

Overrides:
equals in class java.lang.Object
Parameters:
obj - Other object to compare
Returns:
Return true if objects are equivalent

hashCode

public int hashCode()
Compute hash code for the object - based on name and hashcode of first arg (if there is one)

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

clone

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

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

toString

public java.lang.String toString()
Return string representation of the function.

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


Copyright © 2009. All Rights Reserved.