JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
LEDataOutputStream.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * - Redistribution of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * Neither the name of Sun Microsystems, Inc. or the names of
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
23 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
24 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
25 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
26 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
27 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
28 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
29 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
30 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31 *
32 * You acknowledge that this software is not designed or intended for use
33 * in the design, construction, operation or maintenance of any nuclear
34 * facility.
35 *
36 * Sun gratefully acknowledges that this software was originally authored
37 * and developed by Kenneth Bradley Russell and Christopher John Kline.
38 */
39
40package com.jogamp.opengl.util.texture.spi;
41
42import java.io.DataOutput;
43import java.io.DataOutputStream;
44import java.io.FilterOutputStream;
45import java.io.OutputStream;
46import java.io.IOException;
47
48/**
49 * Little Endian Data Output Stream.
50 *
51 * This class implements an output stream filter to allow writing
52 * of java native datatypes to an output stream which has those
53 * native datatypes stored in a little endian byte order.<p>
54 *
55 * This is the sister class of the DataOutputStream which allows
56 * for writing of java native datatypes to an output stream with
57 * the datatypes stored in big endian byte order.<p>
58 *
59 * This class implements the minimum required and calls DataOutputStream
60 * for some of the required methods for DataOutput.<p>
61 *
62 * Not all methods are implemented due to lack of immediate requirement
63 * for that functionality. It is not clear if it is ever going to be
64 * functionally required to be able to read UTF data in a LittleEndianManner<p>
65 *
66 */
67public class LEDataOutputStream extends FilterOutputStream implements DataOutput
68{
69 /**
70 * To reuse some of the non endian dependent methods from
71 * DataOutputStream's methods.
72 */
73 DataOutputStream dataOut;
74
75 public LEDataOutputStream(final OutputStream out)
76 {
77 super(out);
78 dataOut = new DataOutputStream(out);
79 }
80
81 @Override
82 public void close() throws IOException
83 {
84 dataOut.close(); // better close as we create it.
85 // this will close underlying as well.
86 }
87
88 @Override
89 public synchronized final void write(final byte b[]) throws IOException
90 {
91 dataOut.write(b, 0, b.length);
92 }
93
94 @Override
95 public synchronized final void write(final byte b[], final int off, final int len) throws IOException
96 {
97 dataOut.write(b, off, len);
98 }
99
100 @Override
101 public final void write(final int b) throws IOException
102 {
103 dataOut.write(b);
104 }
105
106 @Override
107 public final void writeBoolean(final boolean v) throws IOException
108 {
109 dataOut.writeBoolean(v);
110 }
111
112 @Override
113 public final void writeByte(final int v) throws IOException
114 {
115 dataOut.writeByte(v);
116 }
117
118 /** Don't call this -- not implemented */
119 @Override
120 public final void writeBytes(final String s) throws IOException
121 {
122 throw new UnsupportedOperationException();
123 }
124
125 @Override
126 public final void writeChar(final int v) throws IOException
127 {
128 dataOut.writeChar(((v >> 8) & 0xff) |
129 ((v & 0xff) << 8));
130 }
131
132 /** Don't call this -- not implemented */
133 @Override
134 public final void writeChars(final String s) throws IOException
135 {
136 throw new UnsupportedOperationException();
137 }
138
139 @Override
140 public final void writeDouble(final double v) throws IOException
141 {
142 writeLong(Double.doubleToRawLongBits(v));
143 }
144
145 @Override
146 public final void writeFloat(final float v) throws IOException
147 {
148 writeInt(Float.floatToRawIntBits(v));
149 }
150
151 @Override
152 public final void writeInt(final int v) throws IOException
153 {
154 dataOut.writeInt((v >>> 24) |
155 ((v >>> 8) & 0xff00) |
156 ((v << 8) & 0x00ff00) |
157 (v << 24));
158 }
159
160 @Override
161 public final void writeLong(final long v) throws IOException
162 {
163 writeInt((int) v);
164 writeInt((int) (v >>> 32));
165 }
166
167 @Override
168 public final void writeShort(final int v) throws IOException
169 {
170 dataOut.writeShort(((v >> 8) & 0xff) |
171 ((v & 0xff) << 8));
172 }
173
174 /** Don't call this -- not implemented */
175 @Override
176 public final void writeUTF(final String s) throws IOException
177 {
178 throw new UnsupportedOperationException();
179 }
180}
synchronized final void write(final byte b[], final int off, final int len)
final void writeUTF(final String s)
Don't call this – not implemented.
final void writeBytes(final String s)
Don't call this – not implemented.
synchronized final void write(final byte b[])
final void writeChars(final String s)
Don't call this – not implemented.