1 4 package gnu.xquery.util; 5 import gnu.lists.*; 6 import gnu.mapping.*; 7 8 13 14 public class ValuesEvery extends MethodProc 15 { 16 public static final ValuesEvery every = new ValuesEvery(true); 17 public static final ValuesEvery some = new ValuesEvery(false); 18 19 public ValuesEvery(boolean matchAll) {this.matchAll = matchAll; } 20 21 22 boolean matchAll; 23 24 public int numArgs() { return 0x2002; } 25 26 public void apply (CallContext ctx) throws Throwable 27 { 28 Procedure proc = (Procedure) ctx.getNextArg(); 29 Consumer out = ctx.consumer; 30 Object val = ctx.getNextArg(); 31 boolean ok = matchAll; 32 Procedure.checkArgCount(proc, 1); 33 if (val instanceof Values) 34 { 35 int ipos = 0; 36 Values values = (Values) val; 37 while ((ipos = values.nextPos(ipos)) != 0) 38 { 39 proc.check1(values.getPosPrevious(ipos), ctx); 40 ok = BooleanValue.booleanValue(ctx.runUntilValue()); 41 if (ok != matchAll) 42 break; 43 } 44 } 45 else 46 { 47 proc.check1(val, ctx); 48 ok = BooleanValue.booleanValue(ctx.runUntilValue()); 49 } 50 ctx.consumer.writeBoolean(ok); 51 } 52 53 } 54 | Popular Tags |