KickJava   Java API By Example, From Geeks To Geeks.

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


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
9 /** Coerces an item sequence to a node sequence.
10  * Uses the Nodes class to do the actual work. */

11
12 public class CoerceNodes extends Procedure1 implements Inlineable
13 {
14   public static final CoerceNodes coerceNodes = new CoerceNodes();
15
16   public Object JavaDoc apply1 (Object JavaDoc values)
17   {
18     Nodes nodes = new Nodes();
19     Values.writeValues(values, nodes);
20     return nodes;
21   }
22
23   public void compile (ApplyExp exp, Compilation comp, Target target)
24   {
25     Expression[] args = exp.getArgs();
26     if (args.length != 1)
27       ApplyExp.compile(exp, comp, target);
28     else
29       ConsumerTarget.compileUsingConsumer(args[0], comp, target,
30                       makeNodesMethod, null);
31   }
32
33   public Type getReturnType (Expression[] args)
34   {
35     return typeNodes;
36   }
37
38   public static final ClassType typeNodes
39     = ClassType.make("gnu.kawa.xml.Nodes");
40   public static final Method makeNodesMethod
41     = typeNodes.getDeclaredMethod("<init>", 0);
42
43 }
44
Popular Tags