001: /*
002: * Copyright (c) 2007, intarsys consulting GmbH
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * - Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * - Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * - Neither the name of intarsys nor the names of its contributors may be used
015: * to endorse or promote products derived from this software without specific
016: * prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028: * POSSIBILITY OF SUCH DAMAGE.
029: */
030: package de.intarsys.tools.randomaccess;
031:
032: import java.io.IOException;
033:
034: /**
035: * Filter implementation for random access.
036: *
037: */
038: public class RandomAccessFilter extends AbstractRandomAccess {
039: protected IRandomAccess random;
040:
041: /**
042: *
043: */
044: public RandomAccessFilter(IRandomAccess random) {
045: super ();
046: this .random = random;
047: }
048:
049: /*
050: * (non-Javadoc)
051: *
052: * @see de.intarsys.tools.randomaccess.IRandomAccess#seek(long)
053: */
054: public void seek(long offset) throws IOException {
055: random.seek(offset);
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see de.intarsys.tools.randomaccess.IRandomAccess#seekBy(long)
062: */
063: public void seekBy(long delta) throws IOException {
064: random.seekBy(delta);
065: }
066:
067: /*
068: * (non-Javadoc)
069: *
070: * @see de.intarsys.tools.randomaccess.IRandomAccess#read()
071: */
072: public int read() throws IOException {
073: return random.read();
074: }
075:
076: /*
077: * (non-Javadoc)
078: *
079: * @see de.intarsys.tools.randomaccess.IRandomAccess#getOffset()
080: */
081: public long getOffset() throws IOException {
082: return random.getOffset();
083: }
084:
085: /*
086: * (non-Javadoc)
087: *
088: * @see de.intarsys.tools.randomaccess.IRandomAccess#getLength()
089: */
090: public long getLength() throws IOException {
091: return random.getLength();
092: }
093:
094: protected IRandomAccess getRandom() {
095: return random;
096: }
097:
098: /*
099: * (non-Javadoc)
100: *
101: * @see de.intarsys.tools.randomaccess.IRandomAccess#setLength(long)
102: */
103: public void setLength(long newLength) throws IOException {
104: random.setLength(newLength);
105: }
106:
107: /*
108: * (non-Javadoc)
109: *
110: * @see de.intarsys.tools.randomaccess.IRandomAccess#read(byte[])
111: */
112: public int read(byte[] buffer) throws IOException {
113: return random.read(buffer);
114: }
115:
116: /*
117: * (non-Javadoc)
118: *
119: * @see de.intarsys.tools.randomaccess.IRandomAccess#read(byte[], int, int)
120: */
121: public int read(byte[] buffer, int start, int numBytes)
122: throws IOException {
123: return random.read(buffer, start, numBytes);
124: }
125:
126: /*
127: * (non-Javadoc)
128: *
129: * @see de.intarsys.tools.randomaccess.IRandomAccess#close()
130: */
131: public void close() throws IOException {
132: random.close();
133: }
134:
135: /*
136: * (non-Javadoc)
137: *
138: * @see de.intarsys.tools.randomaccess.IRandomAccess#flush()
139: */
140: public void flush() throws IOException {
141: random.flush();
142: }
143:
144: /*
145: * (non-Javadoc)
146: *
147: * @see de.intarsys.tools.randomaccess.IRandomAccess#isReadOnly()
148: */
149: public boolean isReadOnly() {
150: return random.isReadOnly();
151: }
152:
153: /*
154: * (non-Javadoc)
155: *
156: * @see de.intarsys.tools.randomaccess.IRandomAccess#write(int)
157: */
158: public void write(int b) throws IOException {
159: random.write(b);
160: }
161:
162: /*
163: * (non-Javadoc)
164: *
165: * @see de.intarsys.tools.randomaccess.IRandomAccess#write(byte[])
166: */
167: public void write(byte[] buffer) throws IOException {
168: random.write(buffer);
169: }
170:
171: /*
172: * (non-Javadoc)
173: *
174: * @see de.intarsys.tools.randomaccess.IRandomAccess#write(byte[], int, int)
175: */
176: public void write(byte[] buffer, int start, int numBytes)
177: throws IOException {
178: random.write(buffer, start, numBytes);
179: }
180: }
|