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