KickJava   Java API By Example, From Geeks To Geeks.

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


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

4 package gnu.kawa.xml;
5 import gnu.mapping.*;
6 import gnu.lists.*;
7 /* #ifdef JAVA2 */
8 import java.util.Iterator JavaDoc;
9 import java.util.List JavaDoc;
10 /* #endif */
11
12 /** A function that maps a List into the sequence of its elements. */
13
14 public class ListItems extends MethodProc
15 {
16   public static ListItems listItems = new ListItems();
17
18   public void apply (CallContext ctx)
19   {
20     Consumer out = ctx.consumer;
21     Object JavaDoc arg = ctx.getNextArg();
22     ctx.lastArg();
23
24     /* #ifdef JAVA2 */
25     List JavaDoc list = (List JavaDoc) arg;
26     if (arg instanceof AbstractSequence)
27       {
28     ((AbstractSequence) arg).consumePosRange(0, -1, out);
29     return;
30       }
31     Iterator JavaDoc iter = list.iterator();
32     while (iter.hasNext())
33       {
34     Object JavaDoc val = iter.next();
35     Values.writeValues(val, out);
36       }
37     /* #endif */
38     /* #ifndef JAVA2 */
39     // ((AbstractSequence) arg).consumePosRange(0, -1, out);
40
/* #endif */
41   }
42 }
43
Popular Tags