01: /*
02: * $Id: ByteInputStream.java,v 1.6 2006/01/27 12:49:51 vj135062 Exp $ $Revision:
03: * 1.3 $ $Date: 2006/01/27 12:49:51 $
04: */
05:
06: /*
07: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
08: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
09: *
10: * This code is free software; you can redistribute it and/or modify it
11: * under the terms of the GNU General Public License version 2 only, as
12: * published by the Free Software Foundation. Sun designates this
13: * particular file as subject to the "Classpath" exception as provided
14: * by Sun in the LICENSE file that accompanied this code.
15: *
16: * This code is distributed in the hope that it will be useful, but WITHOUT
17: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19: * version 2 for more details (a copy is included in the LICENSE file that
20: * accompanied this code).
21: *
22: * You should have received a copy of the GNU General Public License version
23: * 2 along with this work; if not, write to the Free Software Foundation,
24: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25: *
26: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
27: * CA 95054 USA or visit www.sun.com if you need additional information or
28: * have any questions.
29: */
30: package com.sun.xml.internal.messaging.saaj.util;
31:
32: import java.io.ByteArrayInputStream;
33: import java.io.IOException;
34:
35: // This class just gives access to the underlying buffer without copying.
36:
37: public class ByteInputStream extends ByteArrayInputStream {
38: private static final byte[] EMPTY_ARRAY = new byte[0];
39:
40: public ByteInputStream() {
41: this (EMPTY_ARRAY, 0);
42: }
43:
44: public ByteInputStream(byte buf[], int length) {
45: super (buf, 0, length);
46: }
47:
48: public ByteInputStream(byte buf[], int offset, int length) {
49: super (buf, offset, length);
50: }
51:
52: public byte[] getBytes() {
53: return buf;
54: }
55:
56: public int getCount() {
57: return count;
58: }
59:
60: public void close() throws IOException {
61: reset();
62: }
63:
64: public void setBuf(byte[] buf) {
65: this .buf = buf;
66: this .pos = 0;
67: this.count = buf.length;
68: }
69: }
|