Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[git-p4: depot-paths = "//open/mondrian/": change = 7596]
- Loading branch information
Showing
9 changed files
with
394 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
// $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. | ||
// Copyright (C) 2006-2006 Julian Hyde and others | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
package mondrian.udf; | ||
|
||
import mondrian.olap.*; | ||
import mondrian.olap.type.*; | ||
import mondrian.spi.UserDefinedFunction; | ||
import mondrian.util.*; | ||
|
||
import java.util.*; | ||
import java.util.regex.*; | ||
|
||
/** | ||
* User-defined function <code>IN</code>. | ||
* | ||
* @author schoi | ||
* @version $Id$ | ||
*/ | ||
public class InUdf implements UserDefinedFunction { | ||
|
||
public Object execute(Evaluator evaluator, Argument[] arguments) { | ||
|
||
Object arg0 = arguments[0].evaluate(evaluator); | ||
List arg1 = (List) arguments[1].evaluate(evaluator); | ||
|
||
for (int i = 0; i < arg1.size(); i++) { | ||
if (((Member)arg0).getUniqueName().equals( | ||
((Member)arg1.get(i)).getUniqueName())) { | ||
return Boolean.TRUE; | ||
} | ||
} | ||
return Boolean.FALSE; | ||
} | ||
|
||
public String getDescription() { | ||
return "Returns true if the member argument is contained in the set argument."; | ||
} | ||
|
||
public String getName() { | ||
return "IN"; | ||
} | ||
|
||
public Type[] getParameterTypes() { | ||
return new Type[] { | ||
MemberType.Unknown, | ||
new SetType(MemberType.Unknown) | ||
}; | ||
} | ||
|
||
public String[] getReservedWords() { | ||
// This function does not require any reserved words. | ||
return null; | ||
} | ||
|
||
public Type getReturnType(Type[] parameterTypes) { | ||
return new BooleanType(); | ||
} | ||
|
||
public Syntax getSyntax() { | ||
return Syntax.Infix; | ||
} | ||
|
||
} | ||
|
||
// End InUdf.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
// $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. | ||
// Copyright (C) 2006-2006 Julian Hyde and others | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
package mondrian.udf; | ||
|
||
import mondrian.olap.*; | ||
import mondrian.olap.type.*; | ||
import mondrian.spi.UserDefinedFunction; | ||
import mondrian.util.*; | ||
|
||
import java.util.*; | ||
import java.util.regex.*; | ||
|
||
/** | ||
* User-defined function <code>MATCHES</code>. | ||
* | ||
* @author schoi | ||
* @version $Id$ | ||
*/ | ||
public class MatchesUdf implements UserDefinedFunction { | ||
|
||
public Object execute(Evaluator evaluator, Argument[] arguments) { | ||
|
||
Object arg0 = arguments[0].evaluateScalar(evaluator); | ||
Object arg1 = arguments[1].evaluateScalar(evaluator); | ||
|
||
return Boolean.valueOf(Pattern.matches((String)arg1, (String)arg0)); | ||
} | ||
|
||
public String getDescription() { | ||
return "Returns true if the string matches the regular expression."; | ||
} | ||
|
||
public String getName() { | ||
return "MATCHES"; | ||
} | ||
|
||
public Type[] getParameterTypes() { | ||
return new Type[] { | ||
new StringType(), | ||
new StringType() | ||
}; | ||
} | ||
|
||
public String[] getReservedWords() { | ||
// This function does not require any reserved words. | ||
return null; | ||
} | ||
|
||
public Type getReturnType(Type[] parameterTypes) { | ||
return new BooleanType(); | ||
} | ||
|
||
public Syntax getSyntax() { | ||
return Syntax.Infix; | ||
} | ||
|
||
} | ||
|
||
// End MatchesUdf.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
Oops, something went wrong.