KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > functions > Unordered


1 package net.sf.saxon.functions;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.expr.ExpressionTool;
4 import net.sf.saxon.expr.StaticContext;
5 import net.sf.saxon.expr.Optimizer;
6 import net.sf.saxon.trans.XPathException;
7 import net.sf.saxon.type.ItemType;
8
9 /**
10 * XPath 2.0 unordered() function
11 */

12
13 public class Unordered extends CompileTimeFunction {
14
15     public Expression typeCheck(StaticContext env, ItemType contextItemType) throws XPathException {
16         Expression exp = super.typeCheck(env, contextItemType);
17         if (exp instanceof Unordered) {
18             Optimizer opt = env.getConfiguration().getOptimizer();
19             return ExpressionTool.unsorted(opt, ((Unordered)exp).argument[0], true);
20         }
21         return exp;
22     }
23
24     public Expression optimizer(Optimizer opt, StaticContext env, ItemType contextItemType) throws XPathException {
25         Expression exp = super.optimize(opt, env, contextItemType);
26         if (exp instanceof Unordered) {
27             return ExpressionTool.unsorted(opt, ((Unordered)exp).argument[0], true);
28         }
29         return exp;
30     }
31
32     /**
33     * preEvaluate: called if the argument is constant
34     */

35
36     public Expression preEvaluate(StaticContext env) throws XPathException {
37         return argument[0];
38     }
39 }
40
41
42
43
44
45 //
46
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
47
// you may not use this file except in compliance with the License. You may obtain a copy of the
48
// License at http://www.mozilla.org/MPL/
49
//
50
// Software distributed under the License is distributed on an "AS IS" basis,
51
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
52
// See the License for the specific language governing rights and limitations under the License.
53
//
54
// The Original Code is: all this file.
55
//
56
// The Initial Developer of the Original Code is Michael H. Kay
57
//
58
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
59
//
60
// Contributor(s): none.
61
//
62
Popular Tags