01: // JigsawServletInputStream.java
02: // $Id: JigsawServletInputStream.java,v 1.7 2000/08/16 21:37:45 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigsaw.servlet;
07:
08: import java.io.IOException;
09: import java.io.InputStream;
10:
11: import javax.servlet.ServletInputStream;
12:
13: /**
14: * @author Alexandre Rafalovitch <alex@access.com.au>
15: * @author Anselm Baird-Smith <abaird@w3.org>
16: */
17:
18: class JigsawServletInputStream extends ServletInputStream {
19: InputStream in = null;
20:
21: public int read() throws IOException {
22: return in.read();
23: }
24:
25: public int read(byte b[]) throws IOException {
26: return in.read(b, 0, b.length);
27: }
28:
29: public int read(byte b[], int off, int len) throws IOException {
30: return in.read(b, off, len);
31: }
32:
33: public long skip(long n) throws IOException {
34: return in.skip(n);
35: }
36:
37: public int available() throws IOException {
38: return in.available();
39: }
40:
41: public void close() throws IOException {
42: in.close();
43: }
44:
45: public synchronized void mark(int readlimit) {
46: in.mark(readlimit);
47: }
48:
49: public synchronized void reset() throws IOException {
50: in.reset();
51: }
52:
53: public boolean markSupported() {
54: return in.markSupported();
55: }
56:
57: public int readLine(byte b[], int off, int len) throws IOException {
58: int got = 0;
59: while (got < len) {
60: int ch = in.read();
61: switch (ch) {
62: case -1:
63: return -1;
64: // case '\r':
65: case '\n':
66: b[off + got] = (byte) (ch & 0xff);
67: got++;
68: // in.mark(1);
69: // if ((ch = in.read()) != '\n' )
70: // in.reset();
71: return got;
72: default:
73: b[off + got] = (byte) (ch & 0xff);
74: got++;
75: }
76: }
77: return got;
78: }
79:
80: JigsawServletInputStream(InputStream in) {
81: this.in = in;
82: }
83:
84: }
|