01: // Copyright (c) 2002 Per M.A. Bothner and Brainfood Inc.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.kawa.xml;
05:
06: import gnu.mapping.*;
07: import gnu.lists.*; /* #ifdef JAVA2 */
08: import java.util.Iterator;
09: import java.util.List;
10:
11: /* #endif */
12:
13: /** A function that maps a List into the sequence of its elements. */
14:
15: public class ListItems extends MethodProc {
16: public static ListItems listItems = new ListItems();
17:
18: public void apply(CallContext ctx) {
19: Consumer out = ctx.consumer;
20: Object arg = ctx.getNextArg();
21: ctx.lastArg();
22:
23: /* #ifdef JAVA2 */
24: List list = (List) arg;
25: if (arg instanceof AbstractSequence) {
26: ((AbstractSequence) arg).consumePosRange(0, -1, out);
27: return;
28: }
29: Iterator iter = list.iterator();
30: while (iter.hasNext()) {
31: Object val = iter.next();
32: Values.writeValues(val, out);
33: }
34: /* #endif */
35: /* #ifndef JAVA2 */
36: // ((AbstractSequence) arg).consumePosRange(0, -1, out);
37: /* #endif */
38: }
39: }
|