rdf4j-postgis  Version 0.1.0.0
LEDataOutputStream Class Reference

Little endian Data output stream. More...

Inheritance diagram for LEDataOutputStream:
Collaboration diagram for LEDataOutputStream:

Public Member Functions

 LEDataOutputStream (OutputStream out)
 
long getPosition ()
 Get current stream position from the first written byte. More...
 
void write (int b) throws IOException
 
void write (byte[] data, int offset, int length) throws IOException
 
void writeBoolean (boolean b) throws IOException
 
void writeByte (int b) throws IOException
 
void writeShort (int s) throws IOException
 
final void writeShorts (short[] values) throws IOException
 Write multiple values in one call. More...
 
void writeUnsignedShort (int s) throws IOException
 
final void writeUnsignedShorts (int[] values) throws IOException
 Write multiple values in one call. More...
 
void writeChar (int c) throws IOException
 
void writeInt (int i) throws IOException
 
final void writeInts (int[] values) throws IOException
 Write multiple values in one call. More...
 
void writeLong (long l) throws IOException
 
final void writeLongs (long[] values) throws IOException
 Write multiple values in one call. More...
 
final void writeFloat (float f) throws IOException
 
final void writeFloats (float[] values) throws IOException
 Write multiple values in one call. More...
 
final void writeDouble (double d) throws IOException
 
final void writeDoubles (double[] values) throws IOException
 Write multiple values in one call. More...
 
void writeBytes (String s) throws IOException
 
void writeChars (String s) throws IOException
 
void writeUTF (String s) throws IOException
 
void realign (int padding) throws IOException
 Align byte stream to a padding value, 0 bytes will be added until padding value is reached. More...
 

Private Attributes

long position = 0
 

Detailed Description

Little endian Data output stream.

Author
Johann Sorel (Geomatys)

Constructor & Destructor Documentation

◆ LEDataOutputStream()

LEDataOutputStream ( OutputStream  out)
33  {
34  super(out);
35  }

Member Function Documentation

◆ getPosition()

long getPosition ( )

Get current stream position from the first written byte.

Returns
stream position
41  {
42  return position;
43  }
long position
Definition: LEDataOutputStream.java:31

References LEDataOutputStream.position.

◆ realign()

void realign ( int  padding) throws IOException

Align byte stream to a padding value, 0 bytes will be added until padding value is reached.

Padding values are usually very small, 2, 4 or 8 bytes to ensure primitive types such as Short, Integer, Float are aligned in memory.

Parameters
paddingvalue to realign.
Exceptions
IOException
222  {
223  while ((position%padding) != 0) {
224  write(0);
225  }
226  }
void write(int b)
Definition: LEDataOutputStream.java:46

References LEDataOutputStream.position, and LEDataOutputStream.write().

◆ write() [1/2]

void write ( byte[]  data,
int  offset,
int  length 
) throws IOException
52  {
53  out.write(data, offset, length);
54  position+=length;
55  }

References LEDataOutputStream.position.

◆ write() [2/2]

void write ( int  b) throws IOException
46  {
47  out.write(b);
48  position++;
49  }

References LEDataOutputStream.position.

Referenced by LEDataOutputStream.realign(), and LEDataOutputStream.writeBoolean().

◆ writeBoolean()

void writeBoolean ( boolean  b) throws IOException
58  {
59  this.write( b ? 1 : 0 );
60  }

References LEDataOutputStream.write().

◆ writeByte()

void writeByte ( int  b) throws IOException
63  {
64  out.write(b);
65  position++;
66  }

References LEDataOutputStream.position.

◆ writeBytes()

void writeBytes ( String  s) throws IOException
191  {
192  for (int i=0,n=s.length(); i<n; i++) {
193  out.write((byte) s.charAt(i));
194  }
195  position+=s.length();
196  }

References LEDataOutputStream.position.

◆ writeChar()

void writeChar ( int  c) throws IOException
104  {
105  out.write((c ) & 0xFF);
106  out.write((c >>> 8) & 0xFF);
107  position+=2;
108  }

References LEDataOutputStream.position.

◆ writeChars()

void writeChars ( String  s) throws IOException
199  {
200  for (int i=0,n=s.length(); i<n; i++) {
201  final char c = s.charAt(i);
202  out.write((c ) & 0xFF);
203  out.write((c >>> 8) & 0xFF);
204  }
205  position+=s.length()*2;
206  }

References LEDataOutputStream.position.

◆ writeDouble()

final void writeDouble ( double  d) throws IOException
174  {
175  this.writeLong(Double.doubleToLongBits(d));
176  }
void writeLong(long l)
Definition: LEDataOutputStream.java:132

References LEDataOutputStream.writeLong().

Referenced by LEDataOutputStream.writeDoubles().

◆ writeDoubles()

final void writeDoubles ( double[]  values) throws IOException

Write multiple values in one call.

Parameters
valuesvalues to write
Exceptions
IOException
184  {
185  for (double value : values) {
186  writeDouble(value);
187  }
188  }
final void writeDouble(double d)
Definition: LEDataOutputStream.java:174

References LEDataOutputStream.writeDouble().

◆ writeFloat()

final void writeFloat ( float  f) throws IOException
157  {
158  this.writeInt(Float.floatToIntBits(f));
159  }
void writeInt(int i)
Definition: LEDataOutputStream.java:111

References LEDataOutputStream.writeInt().

Referenced by LEDataOutputStream.writeFloats().

◆ writeFloats()

final void writeFloats ( float[]  values) throws IOException

Write multiple values in one call.

Parameters
valuesvalues to write
Exceptions
IOException
167  {
168  for (float value : values) {
169  writeFloat(value);
170  }
171  }
final void writeFloat(float f)
Definition: LEDataOutputStream.java:157

References LEDataOutputStream.writeFloat().

◆ writeInt()

void writeInt ( int  i) throws IOException
111  {
112  out.write((i ) & 0xFF);
113  out.write((i >>> 8) & 0xFF);
114  out.write((i >>> 16) & 0xFF);
115  out.write((i >>> 24) & 0xFF);
116  position+=4;
117  }

References LEDataOutputStream.position.

Referenced by LEDataOutputStream.writeFloat(), and LEDataOutputStream.writeInts().

◆ writeInts()

final void writeInts ( int[]  values) throws IOException

Write multiple values in one call.

Parameters
valuesvalues to write
Exceptions
IOException
125  {
126  for (int value : values) {
127  writeInt(value);
128  }
129  }

References LEDataOutputStream.writeInt().

◆ writeLong()

void writeLong ( long  l) throws IOException
132  {
133  out.write((int) (l ) & 0xFF);
134  out.write((int) (l >>> 8 ) & 0xFF);
135  out.write((int) (l >>> 16) & 0xFF);
136  out.write((int) (l >>> 24) & 0xFF);
137  out.write((int) (l >>> 32) & 0xFF);
138  out.write((int) (l >>> 40) & 0xFF);
139  out.write((int) (l >>> 48) & 0xFF);
140  out.write((int) (l >>> 56) & 0xFF);
141  position+=8;
142  }

References LEDataOutputStream.position.

Referenced by LEDataOutputStream.writeDouble(), and LEDataOutputStream.writeLongs().

◆ writeLongs()

final void writeLongs ( long[]  values) throws IOException

Write multiple values in one call.

Parameters
valuesvalues to write
Exceptions
IOException
150  {
151  for (long value : values) {
152  writeLong(value);
153  }
154  }

References LEDataOutputStream.writeLong().

◆ writeShort()

void writeShort ( int  s) throws IOException
69  {
70  out.write((s ) & 0xFF);
71  out.write((s >>> 8) & 0xFF);
72  position+=2;
73  }

References LEDataOutputStream.position.

Referenced by LEDataOutputStream.writeShorts(), and LEDataOutputStream.writeUnsignedShort().

◆ writeShorts()

final void writeShorts ( short[]  values) throws IOException

Write multiple values in one call.

Parameters
valuesvalues to write
Exceptions
IOException
81  {
82  for (short value : values) {
83  writeShort(value);
84  }
85  }
void writeShort(int s)
Definition: LEDataOutputStream.java:69

References LEDataOutputStream.writeShort().

◆ writeUnsignedShort()

void writeUnsignedShort ( int  s) throws IOException
87  {
88  writeShort(s);
89  }

References LEDataOutputStream.writeShort().

Referenced by LEDataOutputStream.writeUnsignedShorts().

◆ writeUnsignedShorts()

final void writeUnsignedShorts ( int[]  values) throws IOException

Write multiple values in one call.

Parameters
valuesvalues to write
Exceptions
IOException
97  {
98  for (int value : values) {
99  writeUnsignedShort(value);
100  }
101  }
void writeUnsignedShort(int s)
Definition: LEDataOutputStream.java:87

References LEDataOutputStream.writeUnsignedShort().

◆ writeUTF()

void writeUTF ( String  s) throws IOException
209  {
210  throw new IOException("Not supported");
211  }

Member Data Documentation

◆ position