39 |
package javax.imageio.stream; |
package javax.imageio.stream; |
40 |
|
|
41 |
import java.io.IOException; |
import java.io.IOException; |
42 |
|
import java.nio.ByteOrder; |
43 |
|
|
44 |
/** |
/** |
45 |
* @author Michael Koch (konqueror@gmx.de) |
* @author Michael Koch (konqueror@gmx.de) |
52 |
// Do nothing here. |
// Do nothing here. |
53 |
} |
} |
54 |
|
|
55 |
|
protected void flushBits() |
56 |
|
throws IOException |
57 |
|
{ |
58 |
|
// FIXME: Implement me. |
59 |
|
throw new Error("not implemented"); |
60 |
|
} |
61 |
|
|
62 |
public void write(byte[] data) |
public void write(byte[] data) |
63 |
throws IOException |
throws IOException |
64 |
{ |
{ |
70 |
|
|
71 |
public abstract void write(int value) |
public abstract void write(int value) |
72 |
throws IOException; |
throws IOException; |
73 |
|
|
74 |
|
public void writeBit(int bit) |
75 |
|
throws IOException |
76 |
|
{ |
77 |
|
// FIXME: Implement me. |
78 |
|
throw new Error("not implemented"); |
79 |
|
} |
80 |
|
|
81 |
|
public void writeBits(long bits, int numBits) |
82 |
|
throws IOException |
83 |
|
{ |
84 |
|
// FIXME: Implement me. |
85 |
|
throw new Error("not implemented"); |
86 |
|
} |
87 |
|
|
88 |
|
public void writeBoolean(boolean value) |
89 |
|
throws IOException |
90 |
|
{ |
91 |
|
writeByte(value ? 1 : 0); |
92 |
|
} |
93 |
|
|
94 |
|
public void writeByte(int value) |
95 |
|
throws IOException |
96 |
|
{ |
97 |
|
write(value & 0xff); |
98 |
|
} |
99 |
|
|
100 |
|
public void writeBytes(String data) |
101 |
|
throws IOException |
102 |
|
{ |
103 |
|
write(data.getBytes()); |
104 |
|
} |
105 |
|
|
106 |
|
public void writeChar(int value) |
107 |
|
throws IOException |
108 |
|
{ |
109 |
|
writeShort((short) value); |
110 |
|
} |
111 |
|
|
112 |
|
public void writeChars(char[] data, int offset, int len) |
113 |
|
throws IOException |
114 |
|
{ |
115 |
|
for(int i = 0; i < len; ++len) |
116 |
|
writeChar(data[offset + i]); |
117 |
|
} |
118 |
|
|
119 |
|
public void writeChars(String data) |
120 |
|
throws IOException |
121 |
|
{ |
122 |
|
// FIXME: Implement me. |
123 |
|
throw new Error("not implemented"); |
124 |
|
} |
125 |
|
|
126 |
|
public void writeDouble(double value) |
127 |
|
throws IOException |
128 |
|
{ |
129 |
|
writeLong((long) value); |
130 |
|
} |
131 |
|
|
132 |
|
public void writeDoubles(double[] data, int offset, int len) |
133 |
|
throws IOException |
134 |
|
{ |
135 |
|
for(int i = 0; i < len; ++len) |
136 |
|
writeDouble(data[offset + i]); |
137 |
|
} |
138 |
|
|
139 |
|
public void writeFloat(float value) |
140 |
|
throws IOException |
141 |
|
{ |
142 |
|
writeInt((int) value); |
143 |
|
} |
144 |
|
|
145 |
|
public void writeFloats(float[] data, int offset, int len) |
146 |
|
throws IOException |
147 |
|
{ |
148 |
|
for(int i = 0; i < len; ++len) |
149 |
|
writeFloat(data[offset + i]); |
150 |
|
} |
151 |
|
|
152 |
|
public void writeInt(int value) |
153 |
|
throws IOException |
154 |
|
{ |
155 |
|
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN) |
156 |
|
{ |
157 |
|
buffer[0] = ((byte) value); |
158 |
|
buffer[1] = ((byte) (value >> 8)); |
159 |
|
buffer[2] = ((byte) (value >> 16)); |
160 |
|
buffer[3] = ((byte) (value >> 24)); |
161 |
|
} |
162 |
|
else |
163 |
|
{ |
164 |
|
buffer[0] = ((byte) (value >> 24)); |
165 |
|
buffer[1] = ((byte) (value >> 16)); |
166 |
|
buffer[2] = ((byte) (value >> 8)); |
167 |
|
buffer[3] = ((byte) value); |
168 |
|
} |
169 |
|
|
170 |
|
write(buffer, 0, 4); |
171 |
|
} |
172 |
|
|
173 |
|
public void writeInts(int[] data, int offset, int len) |
174 |
|
throws IOException |
175 |
|
{ |
176 |
|
for(int i = 0; i < len; ++len) |
177 |
|
writeInt(data[offset + i]); |
178 |
|
} |
179 |
|
|
180 |
|
public void writeLong(long value) |
181 |
|
throws IOException |
182 |
|
{ |
183 |
|
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN) |
184 |
|
{ |
185 |
|
buffer[0] = ((byte) value); |
186 |
|
buffer[1] = ((byte) (value >> 8)); |
187 |
|
buffer[2] = ((byte) (value >> 16)); |
188 |
|
buffer[3] = ((byte) (value >> 24)); |
189 |
|
buffer[4] = ((byte) (value >> 32)); |
190 |
|
buffer[5] = ((byte) (value >> 40)); |
191 |
|
buffer[6] = ((byte) (value >> 48)); |
192 |
|
buffer[7] = ((byte) (value >> 56)); |
193 |
|
} |
194 |
|
else |
195 |
|
{ |
196 |
|
buffer[0] = ((byte) (value >> 56)); |
197 |
|
buffer[1] = ((byte) (value >> 48)); |
198 |
|
buffer[2] = ((byte) (value >> 40)); |
199 |
|
buffer[3] = ((byte) (value >> 32)); |
200 |
|
buffer[4] = ((byte) (value >> 24)); |
201 |
|
buffer[5] = ((byte) (value >> 16)); |
202 |
|
buffer[6] = ((byte) (value >> 8)); |
203 |
|
buffer[7] = ((byte) value); |
204 |
|
} |
205 |
|
|
206 |
|
write(buffer, 0, 8); |
207 |
|
} |
208 |
|
|
209 |
|
public void writeLongs(long[] data, int offset, int len) |
210 |
|
throws IOException |
211 |
|
{ |
212 |
|
for(int i = 0; i < len; ++len) |
213 |
|
writeLong(data[offset + i]); |
214 |
|
} |
215 |
|
|
216 |
|
public void writeShort(int value) |
217 |
|
throws IOException |
218 |
|
{ |
219 |
|
if (getByteOrder() == ByteOrder.LITTLE_ENDIAN) |
220 |
|
{ |
221 |
|
buffer[0] = ((byte) value); |
222 |
|
buffer[1] = ((byte) (value >> 8)); |
223 |
|
} |
224 |
|
else |
225 |
|
{ |
226 |
|
buffer[0] = ((byte) (value >> 8)); |
227 |
|
buffer[1] = ((byte) value); |
228 |
|
} |
229 |
|
|
230 |
|
write(buffer, 0, 2); |
231 |
|
} |
232 |
|
|
233 |
|
public void writeShorts(short[] data, int offset, int len) |
234 |
|
throws IOException |
235 |
|
{ |
236 |
|
for(int i = 0; i < len; ++len) |
237 |
|
writeShort(data[offset + i]); |
238 |
|
} |
239 |
|
|
240 |
|
public void writeUTF(String data) |
241 |
|
throws IOException |
242 |
|
{ |
243 |
|
throw new Error("not implemented"); |
244 |
|
} |
245 |
} |
} |