39
39
package javax.imageio.stream;
41
import gnu.classpath.NotImplementedException;
41
43
import java.io.IOException;
44
import java.io.UTFDataFormatException;
42
45
import java.nio.ByteOrder;
52
55
// Do nothing here.
55
protected void flushBits()
58
protected final void flushBits()
59
throws IOException, NotImplementedException
58
61
// FIXME: Implement me.
59
62
throw new Error("not implemented");
72
75
throws IOException;
74
77
public void writeBit(int bit)
78
throws IOException, NotImplementedException
77
80
// FIXME: Implement me.
78
81
throw new Error("not implemented");
81
84
public void writeBits(long bits, int numBits)
85
throws IOException, NotImplementedException
84
87
// FIXME: Implement me.
85
88
throw new Error("not implemented");
100
103
public void writeBytes(String data)
101
104
throws IOException
103
write(data.getBytes());
106
// This is bogus, but it is how the method is specified.
107
// Sun ought to deprecate this method.
108
int len = data.length();
109
for (int i = 0; i < len; ++i)
110
writeByte(data.charAt(i));
106
113
public void writeChar(int value)
107
114
throws IOException
109
writeShort((short) value);
112
119
public void writeChars(char[] data, int offset, int len)
119
126
public void writeChars(String data)
120
127
throws IOException
122
// FIXME: Implement me.
123
throw new Error("not implemented");
129
int len = data.length();
130
for (int i = 0; i < len; ++i)
131
writeChar(data.charAt(i));
126
134
public void writeDouble(double value)
127
135
throws IOException
129
writeLong((long) value);
137
writeLong(Double.doubleToLongBits(value));
132
140
public void writeDoubles(double[] data, int offset, int len)
237
245
writeShort(data[offset + i]);
240
public void writeUTF(String data)
248
public void writeUTF(String value)
241
249
throws IOException
243
throw new Error("not implemented");
251
// NOTE: this code comes directly from DataOutputStream.
252
int len = value.length();
255
for (int i = 0; i < len && sum <= 65535; ++i)
257
char c = value.charAt(i);
258
if (c >= '\u0001' && c <= '\u007f')
260
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
267
throw new UTFDataFormatException ();
270
byte[] buf = new byte[sum];
272
for (int i = 0; i < len; ++i)
274
char c = value.charAt(i);
275
if (c >= '\u0001' && c <= '\u007f')
276
buf[pos++] = (byte) c;
277
else if (c == '\u0000' || (c >= '\u0080' && c <= '\u07ff'))
279
buf[pos++] = (byte) (0xc0 | (0x1f & (c >> 6)));
280
buf[pos++] = (byte) (0x80 | (0x3f & c));
284
// JSL says the first byte should be or'd with 0xc0, but
285
// that is a typo. Unicode says 0xe0, and that is what is
286
// consistent with DataInputStream.
287
buf[pos++] = (byte) (0xe0 | (0x0f & (c >> 12)));
288
buf[pos++] = (byte) (0x80 | (0x3f & (c >> 6)));
289
buf[pos++] = (byte) (0x80 | (0x3f & c));