1 package org.simantics.db.impl.internal;
\r
3 import java.io.IOException;
\r
4 import java.nio.ByteBuffer;
\r
6 import org.simantics.databoard.util.binary.BinaryFile;
\r
7 import org.simantics.databoard.util.binary.RandomAccessBinary;
\r
9 public class ResourceData implements RandomAccessBinary {
\r
10 private boolean changed = false;
\r
11 public final BinaryFile binaryFile;
\r
12 public final boolean oldExternalValue;
\r
13 public ResourceData(BinaryFile binaryFile, boolean oldExternalValue) {
\r
14 this.binaryFile = binaryFile;
\r
15 this.oldExternalValue = oldExternalValue;
\r
17 public boolean isChanged() {
\r
21 public void writeFully(ByteBuffer src) throws IOException {
\r
22 binaryFile.writeFully(src);
\r
26 public void writeFully(ByteBuffer src, int length) throws IOException {
\r
27 binaryFile.writeFully(src, length);
\r
31 public void write(int b) throws IOException {
\r
32 binaryFile.write(b);
\r
36 public void write(byte[] b) throws IOException {
\r
37 binaryFile.write(b);
\r
41 public void write(byte[] b, int off, int len) throws IOException {
\r
42 binaryFile.write(b, off, len);
\r
46 public void writeBoolean(boolean v) throws IOException {
\r
47 binaryFile.writeBoolean(v);
\r
51 public void writeByte(int v) throws IOException {
\r
52 binaryFile.writeByte(v);
\r
56 public void writeShort(int v) throws IOException {
\r
57 binaryFile.writeShort(v);
\r
61 public void writeChar(int v) throws IOException {
\r
62 binaryFile.writeChar(v);
\r
66 public void writeInt(int v) throws IOException {
\r
67 binaryFile.writeInt(v);
\r
71 public void writeLong(long v) throws IOException {
\r
72 binaryFile.writeLong(v);
\r
76 public void writeFloat(float v) throws IOException {
\r
77 binaryFile.writeFloat(v);
\r
81 public void writeDouble(double v) throws IOException {
\r
82 binaryFile.writeDouble(v);
\r
86 public void writeBytes(String s) throws IOException {
\r
87 binaryFile.writeBytes(s);
\r
91 public void writeChars(String s) throws IOException {
\r
92 binaryFile.writeChars(s);
\r
96 public void writeUTF(String s) throws IOException {
\r
97 binaryFile.writeUTF(s);
\r
101 public long skipBytes(long bytes) throws IOException {
\r
102 return binaryFile.skipBytes(bytes);
\r
105 public void readFully(ByteBuffer buf) throws IOException {
\r
106 binaryFile.readFully(buf);
\r
109 public void readFully(ByteBuffer buf, int length) throws IOException {
\r
110 binaryFile.readFully(buf, length);
\r
113 public void readFully(byte[] b) throws IOException {
\r
114 binaryFile.readFully(b);
\r
117 public void readFully(byte[] b, int off, int len) throws IOException {
\r
118 binaryFile.readFully(b, off, len);
\r
121 public int skipBytes(int n) throws IOException {
\r
122 return binaryFile.skipBytes(n);
\r
125 public boolean readBoolean() throws IOException {
\r
126 return binaryFile.readBoolean();
\r
129 public byte readByte() throws IOException {
\r
130 return binaryFile.readByte();
\r
133 public int readUnsignedByte() throws IOException {
\r
134 return binaryFile.readUnsignedByte();
\r
137 public short readShort() throws IOException {
\r
138 return binaryFile.readShort();
\r
141 public int readUnsignedShort() throws IOException {
\r
142 return binaryFile.readUnsignedShort();
\r
145 public char readChar() throws IOException {
\r
146 return binaryFile.readChar();
\r
149 public int readInt() throws IOException {
\r
150 return binaryFile.readInt();
\r
153 public long readLong() throws IOException {
\r
154 return binaryFile.readLong();
\r
157 public float readFloat() throws IOException {
\r
158 return binaryFile.readFloat();
\r
161 public double readDouble() throws IOException {
\r
162 return binaryFile.readDouble();
\r
165 public String readLine() throws IOException {
\r
166 return binaryFile.readLine();
\r
169 public String readUTF() throws IOException {
\r
170 return binaryFile.readUTF();
\r
173 public void flush() throws IOException {
\r
174 binaryFile.flush();
\r
177 public void reset() throws IOException {
\r
178 binaryFile.reset();
\r
182 public void removeBytes(long bytes, ByteSide side) throws IOException {
\r
183 binaryFile.removeBytes(bytes, side);
\r
187 public void insertBytes(long bytes, ByteSide side) throws IOException {
\r
188 binaryFile.insertBytes(bytes, side);
\r
192 public void setLength(long newLength) throws IOException {
\r
193 binaryFile.setLength(newLength);
\r
197 public long length() throws IOException {
\r
198 return binaryFile.length();
\r
201 public void close() throws IOException {
\r
202 binaryFile.close();
\r
205 public boolean isOpen() {
\r
206 return binaryFile.isOpen();
\r
209 public void position(long newPosition) throws IOException {
\r
210 binaryFile.position(newPosition);
\r
213 public long position() throws IOException {
\r
214 return binaryFile.position();
\r