01: package net.sf.saxon.functions;
02:
03: import net.sf.saxon.expr.Expression;
04: import net.sf.saxon.expr.ExpressionTool;
05: import net.sf.saxon.expr.StaticContext;
06: import net.sf.saxon.expr.Optimizer;
07: import net.sf.saxon.trans.XPathException;
08: import net.sf.saxon.type.ItemType;
09:
10: /**
11: * XPath 2.0 unordered() function
12: */
13:
14: public class Unordered extends CompileTimeFunction {
15:
16: public Expression typeCheck(StaticContext env,
17: ItemType contextItemType) throws XPathException {
18: Expression exp = super .typeCheck(env, contextItemType);
19: if (exp instanceof Unordered) {
20: Optimizer opt = env.getConfiguration().getOptimizer();
21: return ExpressionTool.unsorted(opt,
22: ((Unordered) exp).argument[0], true);
23: }
24: return exp;
25: }
26:
27: public Expression optimizer(Optimizer opt, StaticContext env,
28: ItemType contextItemType) throws XPathException {
29: Expression exp = super .optimize(opt, env, contextItemType);
30: if (exp instanceof Unordered) {
31: return ExpressionTool.unsorted(opt,
32: ((Unordered) exp).argument[0], true);
33: }
34: return exp;
35: }
36:
37: /**
38: * preEvaluate: called if the argument is constant
39: */
40:
41: public Expression preEvaluate(StaticContext env)
42: throws XPathException {
43: return argument[0];
44: }
45: }
46:
47: //
48: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
49: // you may not use this file except in compliance with the License. You may obtain a copy of the
50: // License at http://www.mozilla.org/MPL/
51: //
52: // Software distributed under the License is distributed on an "AS IS" basis,
53: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
54: // See the License for the specific language governing rights and limitations under the License.
55: //
56: // The Original Code is: all this file.
57: //
58: // The Initial Developer of the Original Code is Michael H. Kay
59: //
60: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
61: //
62: // Contributor(s): none.
63: //
|