Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow JPivot to set the slicer axis of a query; * Rename FunCall to ResolvedFunCall, and add FunCall as common interface for it and UnresolvedFunCall. [git-p4: depot-paths = "//open/mondrian/": change = 4994]
- Loading branch information
1 parent
5aca340
commit 674aeb1
Showing
35 changed files
with
434 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
// $Id$ | ||
// This software is subject to the terms of the Common Public License | ||
// Agreement, available at the following URL: | ||
// http://www.opensource.org/licenses/cpl.html. | ||
// (C) Copyright 1998-2006 Kana Software, Inc. and others. | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
|
||
package mondrian.mdx; | ||
import mondrian.calc.Calc; | ||
import mondrian.calc.ExpCompiler; | ||
import mondrian.olap.type.Type; | ||
import mondrian.olap.*; | ||
|
||
import java.io.PrintWriter; | ||
|
||
/** | ||
* A <code>ResolvedFunCall</code> is a function applied to a list of operands, | ||
* which has been validated and resolved to a | ||
* {@link FunDef function definition}. | ||
* | ||
* @author jhyde | ||
* @version $Id$ | ||
* @since Jan 6, 2006 | ||
*/ | ||
public class ResolvedFunCall extends ExpBase implements FunCall { | ||
|
||
/** | ||
* The arguments to the function call. Note that for methods, 0-th arg is | ||
* 'this'. | ||
*/ | ||
private final Exp[] args; | ||
|
||
/** | ||
* Return type of this function call. | ||
*/ | ||
private final Type returnType; | ||
|
||
/** | ||
* Function definition. | ||
*/ | ||
private final FunDef funDef; | ||
|
||
/** | ||
* Creates a function call. | ||
* | ||
* @param funDef Function definition | ||
* @param args Arguments | ||
* @param returnType Return type | ||
*/ | ||
public ResolvedFunCall(FunDef funDef, Exp[] args, Type returnType) { | ||
assert funDef != null; | ||
assert args != null; | ||
assert returnType != null; | ||
this.funDef = funDef; | ||
this.args = args; | ||
this.returnType = returnType; | ||
} | ||
|
||
public String toString() { | ||
return toMdx(); | ||
} | ||
|
||
public Object clone() { | ||
return new ResolvedFunCall(funDef, ExpBase.cloneArray(args), returnType); | ||
} | ||
|
||
/** | ||
* Returns the Exp argument at the specified index. | ||
* | ||
* @param index the index of the Exp. | ||
* @return the Exp at the specified index of this array of Exp. | ||
* The first Exp is at index <code>0</code>. | ||
* @see #getArgs() | ||
*/ | ||
public Exp getArg(int index) { | ||
return args[index]; | ||
} | ||
|
||
/** | ||
* Returns the internal array of Exp arguments. | ||
* | ||
* <p>Note: this does NOT do a copy. | ||
* | ||
* @return the array of expressions | ||
*/ | ||
public Exp[] getArgs() { | ||
return args; | ||
} | ||
|
||
/** | ||
* Returns the number of arguments. | ||
* | ||
* @return number of arguments. | ||
* @see #getArgs() | ||
*/ | ||
public final int getArgCount() { | ||
return args.length; | ||
} | ||
|
||
public String getFunName() { | ||
return funDef.getName(); | ||
} | ||
|
||
public Syntax getSyntax() { | ||
return funDef.getSyntax(); | ||
} | ||
|
||
public Object[] getChildren() { | ||
return args; | ||
} | ||
|
||
public void replaceChild(int i, QueryPart with) { | ||
args[i] = (Exp) with; | ||
} | ||
|
||
/** | ||
* Returns the definition of the function which is being called. | ||
* | ||
* @return function definition | ||
*/ | ||
public FunDef getFunDef() { | ||
return funDef; | ||
} | ||
|
||
public final int getCategory() { | ||
return funDef.getReturnCategory(); | ||
} | ||
|
||
public final Type getType() { | ||
return returnType; | ||
} | ||
|
||
public Exp accept(Validator validator) { | ||
return this; // already validated | ||
} | ||
|
||
public void unparse(PrintWriter pw) { | ||
funDef.unparse(args, pw); | ||
} | ||
|
||
public Calc accept(ExpCompiler compiler) { | ||
return funDef.compileCall(this, compiler); | ||
} | ||
} | ||
|
||
// End ResolvedFunCall.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.