001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.vfs.provider;
018:
019: import org.apache.commons.vfs.RandomAccessContent;
020: import org.apache.commons.vfs.util.RandomAccessMode;
021:
022: import java.io.IOException;
023: import java.io.InputStream;
024: import java.io.DataInputStream;
025:
026: /**
027: * Implements the part usable for all stream base random access implementations
028: *
029: * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
030: * @version $Revision: 485638 $ $Date: 2006-12-11 04:20:55 -0800 (Mon, 11 Dec 2006) $
031: */
032: public abstract class AbstractRandomAccessStreamContent extends
033: AbstractRandomAccessContent {
034: protected AbstractRandomAccessStreamContent(
035: final RandomAccessMode mode) {
036: super (mode);
037: }
038:
039: protected abstract DataInputStream getDataInputStream()
040: throws IOException;
041:
042: public byte readByte() throws IOException {
043: byte data = getDataInputStream().readByte();
044: return data;
045: }
046:
047: public char readChar() throws IOException {
048: char data = getDataInputStream().readChar();
049: return data;
050: }
051:
052: public double readDouble() throws IOException {
053: double data = getDataInputStream().readDouble();
054: return data;
055: }
056:
057: public float readFloat() throws IOException {
058: float data = getDataInputStream().readFloat();
059: return data;
060: }
061:
062: public int readInt() throws IOException {
063: int data = getDataInputStream().readInt();
064: return data;
065: }
066:
067: public int readUnsignedByte() throws IOException {
068: int data = getDataInputStream().readUnsignedByte();
069: return data;
070: }
071:
072: public int readUnsignedShort() throws IOException {
073: int data = getDataInputStream().readUnsignedShort();
074: return data;
075: }
076:
077: public long readLong() throws IOException {
078: long data = getDataInputStream().readLong();
079: return data;
080: }
081:
082: public short readShort() throws IOException {
083: short data = getDataInputStream().readShort();
084: return data;
085: }
086:
087: public boolean readBoolean() throws IOException {
088: boolean data = getDataInputStream().readBoolean();
089: return data;
090: }
091:
092: public int skipBytes(int n) throws IOException {
093: int data = getDataInputStream().skipBytes(n);
094: return data;
095: }
096:
097: public void readFully(byte b[]) throws IOException {
098: getDataInputStream().readFully(b);
099: }
100:
101: public void readFully(byte b[], int off, int len)
102: throws IOException {
103: getDataInputStream().readFully(b, off, len);
104: }
105:
106: public String readUTF() throws IOException {
107: String data = getDataInputStream().readUTF();
108: return data;
109: }
110:
111: public InputStream getInputStream() throws IOException {
112: return getDataInputStream();
113: }
114: }
|