KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > kawa > xml > UnionNodes


1 // Copyright (c) 2003 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.kawa.xml;
5 import gnu.bytecode.*;
6 import gnu.mapping.*;
7 import gnu.expr.*;
8 import gnu.kawa.functions.AppendValues;
9
10 /** Get the union of two node lists.
11  * Implements the XQuery '|' or 'union' operator.
12  */

13
14 public class UnionNodes extends Procedure2 implements Inlineable
15 {
16   public static final UnionNodes unionNodes = new UnionNodes();
17
18   public Object JavaDoc apply2 (Object JavaDoc vals1, Object JavaDoc vals2)
19   {
20     SortedNodes nodes = new SortedNodes();
21     Values.writeValues(vals1, nodes);
22     Values.writeValues(vals2, nodes);
23     return nodes;
24   }
25
26   public void compile (ApplyExp exp, Compilation comp, Target target)
27   {
28     exp = new ApplyExp(AppendValues.appendValues, exp.getArgs());
29     ConsumerTarget.compileUsingConsumer(exp, comp, target,
30                     SortNodes.makeSortedNodesMethod, null);
31   }
32
33   public Type getReturnType (Expression[] args)
34   {
35     return Compilation.typeObject;
36   }
37
38 }
39
Popular Tags