01: /*
02: * @(#)CallbackLineHandler.java 1.2 04/12/06
03: *
04: * Copyright (c) 2001-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.nio;
10:
11: import pnuts.lang.*;
12: import org.pnuts.text.*;
13: import java.nio.*;
14:
15: class CallbackLineHandler implements LineHandler {
16:
17: protected PnutsFunction func;
18: protected Context context;
19:
20: public CallbackLineHandler(PnutsFunction func, Context context) {
21: this .func = func;
22: this .context = context;
23: }
24:
25: public void process(char[] cb, int offset, int length) {
26: func.call(new Object[] { CharBuffer.wrap(cb, offset, length) },
27: context);
28: }
29:
30: public void process(byte[] bb, int offset, int length) {
31: func.call(new Object[] { new ByteArrayCharSequence(bb, offset,
32: length) }, context);
33: }
34: }
|