01: /*
02: * @(#)CallbackLineHandler.java 1.2 04/12/06
03: *
04: * Copyright (c) 2002-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.text;
10:
11: import pnuts.lang.*;
12: import java.lang.reflect.*;
13:
14: /**
15: * A LineHandler implementation that calls a PnutsFunction.
16: */
17: class CallbackLineHandler implements LineHandler {
18:
19: protected PnutsFunction func;
20: protected Context context;
21: protected AbstractLineReader lineReader;
22:
23: public CallbackLineHandler(PnutsFunction func, Context context) {
24: this .func = func;
25: this .context = context;
26: }
27:
28: public void process(char[] cb, int offset, int length) {
29: func.call(new Object[] { new String(cb, offset, length) },
30: context);
31: }
32: }
|