]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.impl/src/org/simantics/db/impl/internal/ResourceData.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / internal / ResourceData.java
1 package org.simantics.db.impl.internal;
2
3 import java.io.IOException;
4 import java.nio.ByteBuffer;
5
6 import org.simantics.databoard.util.binary.BinaryFile;
7 import org.simantics.databoard.util.binary.RandomAccessBinary;
8
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;
16     }
17     public boolean isChanged() {
18         return changed;
19     }
20         @Override
21         public void writeFully(ByteBuffer src) throws IOException {
22                 binaryFile.writeFully(src);
23                 changed = true;
24         }
25         @Override
26         public void writeFully(ByteBuffer src, int length) throws IOException {
27                 binaryFile.writeFully(src, length);
28                 changed = true;
29         }
30         @Override
31         public void write(int b) throws IOException {
32                 binaryFile.write(b);
33                 changed = true;
34         }
35         @Override
36         public void write(byte[] b) throws IOException {
37                 binaryFile.write(b);
38                 changed = true;
39         }
40         @Override
41         public void write(byte[] b, int off, int len) throws IOException {
42                 binaryFile.write(b, off, len);
43                 changed = true;
44         }
45         @Override
46         public void writeBoolean(boolean v) throws IOException {
47                 binaryFile.writeBoolean(v);
48                 changed = true;
49         }
50         @Override
51         public void writeByte(int v) throws IOException {
52                 binaryFile.writeByte(v);
53                 changed = true;
54         }
55         @Override
56         public void writeShort(int v) throws IOException {
57                 binaryFile.writeShort(v);
58                 changed = true;
59         }
60         @Override
61         public void writeChar(int v) throws IOException {
62                 binaryFile.writeChar(v);
63                 changed = true;
64         }
65         @Override
66         public void writeInt(int v) throws IOException {
67                 binaryFile.writeInt(v);
68                 changed = true;
69         }
70         @Override
71         public void writeLong(long v) throws IOException {
72                 binaryFile.writeLong(v);
73                 changed = true;
74         }
75         @Override
76         public void writeFloat(float v) throws IOException {
77                 binaryFile.writeFloat(v);
78                 changed = true;
79         }
80         @Override
81         public void writeDouble(double v) throws IOException {
82                 binaryFile.writeDouble(v);
83                 changed = true;
84         }
85         @Override
86         public void writeBytes(String s) throws IOException {
87                 binaryFile.writeBytes(s);
88                 changed = true;
89         }
90         @Override
91         public void writeChars(String s) throws IOException {
92                 binaryFile.writeChars(s);
93                 changed = true;
94         }
95         @Override
96         public void writeUTF(String s) throws IOException {
97                 binaryFile.writeUTF(s);
98                 changed = true;
99         }
100         @Override
101         public long skipBytes(long bytes) throws IOException {
102                 return binaryFile.skipBytes(bytes);
103         }
104         @Override
105         public void readFully(ByteBuffer buf) throws IOException {
106                 binaryFile.readFully(buf);
107         }
108         @Override
109         public void readFully(ByteBuffer buf, int length) throws IOException {
110                 binaryFile.readFully(buf, length);
111         }
112         @Override
113         public void readFully(byte[] b) throws IOException {
114                 binaryFile.readFully(b);
115         }
116         @Override
117         public void readFully(byte[] b, int off, int len) throws IOException {
118                 binaryFile.readFully(b, off, len);
119         }
120         @Override
121         public int skipBytes(int n) throws IOException {
122                 return binaryFile.skipBytes(n);
123         }
124         @Override
125         public boolean readBoolean() throws IOException {
126                 return binaryFile.readBoolean();
127         }
128         @Override
129         public byte readByte() throws IOException {
130                 return binaryFile.readByte();
131         }
132         @Override
133         public int readUnsignedByte() throws IOException {
134                 return binaryFile.readUnsignedByte();
135         }
136         @Override
137         public short readShort() throws IOException {
138                 return binaryFile.readShort();
139         }
140         @Override
141         public int readUnsignedShort() throws IOException {
142                 return binaryFile.readUnsignedShort();
143         }
144         @Override
145         public char readChar() throws IOException {
146                 return binaryFile.readChar();
147         }
148         @Override
149         public int readInt() throws IOException {
150                 return binaryFile.readInt();
151         }
152         @Override
153         public long readLong() throws IOException {
154                 return binaryFile.readLong();
155         }
156         @Override
157         public float readFloat() throws IOException {
158                 return binaryFile.readFloat();
159         }
160         @Override
161         public double readDouble() throws IOException {
162                 return binaryFile.readDouble();
163         }
164         @Override
165         public String readLine() throws IOException {
166                 return binaryFile.readLine();
167         }
168         @Override
169         public String readUTF() throws IOException {
170                 return binaryFile.readUTF();
171         }
172         @Override
173         public void flush() throws IOException {
174                 binaryFile.flush();
175         }
176         @Override
177         public void reset() throws IOException {
178                 binaryFile.reset();
179                 changed = true;
180         }
181         @Override
182         public void removeBytes(long bytes, ByteSide side) throws IOException {
183                 binaryFile.removeBytes(bytes, side);
184                 changed = true;
185         }
186         @Override
187         public void insertBytes(long bytes, ByteSide side) throws IOException {
188                 binaryFile.insertBytes(bytes, side);
189                 changed = true;
190         }
191         @Override
192         public void setLength(long newLength) throws IOException {
193                 binaryFile.setLength(newLength);
194                 changed = true;
195         }
196         @Override
197         public long length() throws IOException {
198                 return binaryFile.length();
199         }
200         @Override
201         public void close() throws IOException {
202                 binaryFile.close();
203         }
204         @Override
205         public boolean isOpen() {
206                 return binaryFile.isOpen();
207         }
208         @Override
209         public void position(long newPosition) throws IOException {
210                 binaryFile.position(newPosition);
211         }
212         @Override
213         public long position() throws IOException {
214                 return binaryFile.position();
215         }
216 }