View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.vfs.provider;
18  
19  import org.apache.commons.vfs.RandomAccessContent;
20  import org.apache.commons.vfs.util.RandomAccessMode;
21  
22  import java.io.IOException;
23  import java.io.InputStream;
24  import java.io.DataInputStream;
25  
26  /***
27   * Implements the part usable for all stream base random access implementations
28   *
29   * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
30   * @version $Revision: 485638 $ $Date: 2006-12-11 13:20:55 +0100 (Mo, 11 Dez 2006) $
31   */
32  public abstract class AbstractRandomAccessStreamContent extends AbstractRandomAccessContent
33  {
34      protected AbstractRandomAccessStreamContent(final RandomAccessMode mode)
35      {
36  		super(mode);
37      }
38  
39  	protected abstract DataInputStream getDataInputStream() throws IOException;
40  
41  	public byte readByte() throws IOException
42  	{
43  		byte data = getDataInputStream().readByte();
44  		return data;
45  	}
46  
47  	public char readChar() throws IOException
48  	{
49  		char data = getDataInputStream().readChar();
50  		return data;
51  	}
52  
53  	public double readDouble() throws IOException
54  	{
55  		double data = getDataInputStream().readDouble();
56  		return data;
57  	}
58  
59  	public float readFloat() throws IOException
60  	{
61  		float data = getDataInputStream().readFloat();
62  		return data;
63  	}
64  
65  	public int readInt() throws IOException
66  	{
67  		int data = getDataInputStream().readInt();
68  		return data;
69  	}
70  
71  	public int readUnsignedByte() throws IOException
72  	{
73  		int data = getDataInputStream().readUnsignedByte();
74  		return data;
75  	}
76  
77  	public int readUnsignedShort() throws IOException
78  	{
79  		int data = getDataInputStream().readUnsignedShort();
80  		return data;
81  	}
82  
83  	public long readLong() throws IOException
84  	{
85  		long data = getDataInputStream().readLong();
86  		return data;
87  	}
88  
89  	public short readShort() throws IOException
90  	{
91  		short data = getDataInputStream().readShort();
92  		return data;
93  	}
94  
95  	public boolean readBoolean() throws IOException
96  	{
97  		boolean data = getDataInputStream().readBoolean();
98  		return data;
99  	}
100 
101 	public int skipBytes(int n) throws IOException
102 	{
103 		int data = getDataInputStream().skipBytes(n);
104 		return data;
105 	}
106 
107 	public void readFully(byte b[]) throws IOException
108 	{
109 		getDataInputStream().readFully(b);
110 	}
111 
112 	public void readFully(byte b[], int off, int len) throws IOException
113 	{
114 		getDataInputStream().readFully(b, off, len);
115 	}
116 
117 	public String readUTF() throws IOException
118 	{
119 		String data = getDataInputStream().readUTF();
120 		return data;
121 	}
122 
123 	public InputStream getInputStream() throws IOException
124 	{
125 		return getDataInputStream();
126 	}
127 }