1 4 package gnu.kawa.xml; 5 import gnu.mapping.*; 6 import gnu.lists.*; 7 import gnu.xml.TextUtils; 8 9 public class CommentConstructor extends MethodProc { 11 public static final CommentConstructor commentConstructor 12 = new CommentConstructor(); 13 14 public int numArgs() { return 0x1001; } 15 16 public void apply (CallContext ctx) 17 { 18 Consumer saved = ctx.consumer; 19 XConsumer out = NodeConstructor.pushNodeContext(ctx); 20 try 21 { 22 StringBuffer sbuf = new StringBuffer (); 23 Object endMarker = Location.UNBOUND; 24 boolean first = true; 25 for (int i = 0; ; i++) 26 { 27 Object arg = ctx.getNextArg(endMarker); 28 if (arg == endMarker) 29 break; 30 if (arg instanceof Values) 31 { 32 Values vals = (Values) arg; 33 for (int it = 0; (it = vals.nextPos(it)) != 0; ) 34 { 35 if (! first) 36 sbuf.append(' '); 37 first = false; 38 TextUtils.stringValue(vals.getPosPrevious(it), sbuf); 39 } 40 } 41 else 42 { 43 if (! first) 44 sbuf.append(' '); 45 first = false; 46 TextUtils.stringValue(arg, sbuf); 47 } 48 } 49 int len = sbuf.length(); 50 char[] buf = new char[len]; 51 sbuf.getChars(0, len, buf, 0); 52 out.writeComment(buf, 0, len); 53 } 54 finally 55 { 56 NodeConstructor.popNodeContext(saved, ctx); 57 } 58 } 59 } 60 | Popular Tags |