Merge from the pain train
[official-gcc.git] / libjava / javax / imageio / stream / ImageOutputStreamImpl.java
blob2149255457d7053fcbfd03bd721782163cbead00
1 /* ImageOutputStream.java --
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.imageio.stream;
41 import java.io.IOException;
42 import java.nio.ByteOrder;
44 /**
45 * @author Michael Koch (konqueror@gmx.de)
47 public abstract class ImageOutputStreamImpl extends ImageInputStreamImpl
48 implements ImageOutputStream
50 public ImageOutputStreamImpl()
52 // Do nothing here.
55 protected void flushBits()
56 throws IOException
58 // FIXME: Implement me.
59 throw new Error("not implemented");
62 public void write(byte[] data)
63 throws IOException
65 write(data, 0, data.length);
68 public abstract void write(byte[] data, int offset, int len)
69 throws IOException;
71 public abstract void write(int value)
72 throws IOException;
74 public void writeBit(int bit)
75 throws IOException
77 // FIXME: Implement me.
78 throw new Error("not implemented");
81 public void writeBits(long bits, int numBits)
82 throws IOException
84 // FIXME: Implement me.
85 throw new Error("not implemented");
88 public void writeBoolean(boolean value)
89 throws IOException
91 writeByte(value ? 1 : 0);
94 public void writeByte(int value)
95 throws IOException
97 write(value & 0xff);
100 public void writeBytes(String data)
101 throws IOException
103 write(data.getBytes());
106 public void writeChar(int value)
107 throws IOException
109 writeShort((short) value);
112 public void writeChars(char[] data, int offset, int len)
113 throws IOException
115 for(int i = 0; i < len; ++len)
116 writeChar(data[offset + i]);
119 public void writeChars(String data)
120 throws IOException
122 // FIXME: Implement me.
123 throw new Error("not implemented");
126 public void writeDouble(double value)
127 throws IOException
129 writeLong((long) value);
132 public void writeDoubles(double[] data, int offset, int len)
133 throws IOException
135 for(int i = 0; i < len; ++len)
136 writeDouble(data[offset + i]);
139 public void writeFloat(float value)
140 throws IOException
142 writeInt((int) value);
145 public void writeFloats(float[] data, int offset, int len)
146 throws IOException
148 for(int i = 0; i < len; ++len)
149 writeFloat(data[offset + i]);
152 public void writeInt(int value)
153 throws IOException
155 if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
157 buffer[0] = ((byte) value);
158 buffer[1] = ((byte) (value >> 8));
159 buffer[2] = ((byte) (value >> 16));
160 buffer[3] = ((byte) (value >> 24));
162 else
164 buffer[0] = ((byte) (value >> 24));
165 buffer[1] = ((byte) (value >> 16));
166 buffer[2] = ((byte) (value >> 8));
167 buffer[3] = ((byte) value);
170 write(buffer, 0, 4);
173 public void writeInts(int[] data, int offset, int len)
174 throws IOException
176 for(int i = 0; i < len; ++len)
177 writeInt(data[offset + i]);
180 public void writeLong(long value)
181 throws IOException
183 if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
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));
194 else
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);
206 write(buffer, 0, 8);
209 public void writeLongs(long[] data, int offset, int len)
210 throws IOException
212 for(int i = 0; i < len; ++len)
213 writeLong(data[offset + i]);
216 public void writeShort(int value)
217 throws IOException
219 if (getByteOrder() == ByteOrder.LITTLE_ENDIAN)
221 buffer[0] = ((byte) value);
222 buffer[1] = ((byte) (value >> 8));
224 else
226 buffer[0] = ((byte) (value >> 8));
227 buffer[1] = ((byte) value);
230 write(buffer, 0, 2);
233 public void writeShorts(short[] data, int offset, int len)
234 throws IOException
236 for(int i = 0; i < len; ++len)
237 writeShort(data[offset + i]);
240 public void writeUTF(String data)
241 throws IOException
243 throw new Error("not implemented");