TinyLine 2.1

com.tinyline.util
Class TinyOutputStream

java.lang.Object
  extended bycom.tinyline.util.TinyOutputStream

public final class TinyOutputStream
extends java.lang.Object

A data output stream lets an application write primitive TinyLine 2D data types to an output stream.

Version:
2.1

Constructor Summary
TinyOutputStream(java.io.OutputStream out)
          Creates a new output stream to write data to the specified underlying output stream.
 
Method Summary
 void align()
          Aligns the stream
 void close()
          Closes this output stream and releases any system resources associated with this stream.
 void flush()
          Flushes this output stream and forces any buffered output bytes to be written out.
static int getSBLen(int v)
          Calculates how many bits are needed to store the specified signed value.
static int getUBLen(int v)
          Calculates how many bits are needed to store the specified unsigned value.
 void writeBoolean(boolean v)
          Writes a boolean to the underlying output stream.
 void writeBytes(byte[] buffer)
          Writes buffer.length bytes from the specified byte array to this output stream.
 void writeSB(int v, int n)
          Writes a signed n-bit value.
 void writeSI16(short v)
          Writes a signed integer 16-bit value.
 void writeSI32(int v)
          Writes a signed integer 32-bit value.
 void writeSI8(byte v)
          Writes a signed integer 8-bit value.
 void writeTinyColor(TinyColor tc)
          Writes a TinyColor to the underlying output stream.
 void writeTinyFont(TinyFont tfont)
          Writes a TinyFont to the underlying output stream.
 void writeTinyMatrix(TinyMatrix tmat)
          Writes a TinyMatrix to the underlying output stream.
 void writeTinyPaint(TinyPaint paint)
          Writes a TinyPaint to the underlying output stream.
 void writeTinyPath(TinyPath path)
          Writes a TinyPath to the underlying output stream.
 void writeTinyRect(TinyRect rect)
          Writes a TinyRect to the underlying output stream.
 void writeTinyString(TinyString str)
          Writes a TinyString to the underlying output stream.
 void writeUB(int v, int n)
          Writes an unsigned n-bit value.
 void writeUI16(int v)
          Writes an unsigned integer 16-bit value.
 void writeUI32(int v)
          Writes an unsigned integer 32-bit value.
 void writeUI8(short v)
          Writes an unsigned integer 8-bit value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TinyOutputStream

public TinyOutputStream(java.io.OutputStream out)
Creates a new output stream to write data to the specified underlying output stream.

Parameters:
out - the underlying output stream.
Method Detail

getSBLen

public static int getSBLen(int v)
Calculates how many bits are needed to store the specified signed value. Signed values are stored using at least 2 bits, so the function returns numbers from 2 to 32.

Parameters:
v - a signed integer value
Returns:
how many bits the specified value needs to be stored

getUBLen

public static int getUBLen(int v)
Calculates how many bits are needed to store the specified unsigned value. Unsigned values are stored using from 1 to 32 bits. For negative values, it returns 0.

Parameters:
v - a unsigned integer value
Returns:
how many bits the specified value needs to be stored

align

public void align()
           throws java.io.IOException
Aligns the stream

Throws:
java.io.IOException - if an I/O error has occurred

close

public void close()
           throws java.io.IOException
Closes this output stream and releases any system resources associated with this stream. A closed stream cannot perform output operations and cannot be reopened.

Throws:
java.io.IOException - if an I/O error occurs.

flush

public void flush()
           throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out.

Throws:
java.io.IOException - if an I/O error has occurred

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Writes a boolean to the underlying output stream.

Parameters:
v - a boolean value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeBytes

public void writeBytes(byte[] buffer)
                throws java.io.IOException
Writes buffer.length bytes from the specified byte array to this output stream.

Parameters:
buffer - buffer as byte array
Throws:
java.io.IOException - if an I/O error has occurred

writeSI16

public void writeSI16(short v)
               throws java.io.IOException
Writes a signed integer 16-bit value.

Parameters:
v - signed integer 16-bit value
Throws:
java.io.IOException - if an I/O error has occurred

writeSI32

public void writeSI32(int v)
               throws java.io.IOException
Writes a signed integer 32-bit value.

Parameters:
v - signed integer 32-bit value
Throws:
java.io.IOException - if an I/O error has occurred

writeSI8

public void writeSI8(byte v)
              throws java.io.IOException
Writes a signed integer 8-bit value.

Parameters:
v - signed integer 8-bit value
Throws:
java.io.IOException - if an I/O error has occurred

writeSB

public void writeSB(int v,
                    int n)
             throws java.io.IOException
Writes a signed n-bit value.

Parameters:
n - the number of bits to be written
Returns:
v the signed n-bit value.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyString

public void writeTinyString(TinyString str)
                     throws java.io.IOException
Writes a TinyString to the underlying output stream.

Parameters:
str - the TinyString value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

writeUI16

public void writeUI16(int v)
               throws java.io.IOException
Writes an unsigned integer 16-bit value.

Parameters:
v - the unsigned integer 16-bit value
Throws:
java.io.IOException - if an I/O error has occurred

writeUI32

public void writeUI32(int v)
               throws java.io.IOException
Writes an unsigned integer 32-bit value.

Parameters:
v - the unsigned integer 32-bit value
Throws:
java.io.IOException - if an I/O error has occurred

writeUI8

public void writeUI8(short v)
              throws java.io.IOException
Writes an unsigned integer 8-bit value.

Parameters:
v - the unsigned integer 8-bit value
Throws:
java.io.IOException - if an I/O error has occurred

writeUB

public void writeUB(int v,
                    int n)
             throws java.io.IOException
Writes an unsigned n-bit value.

Parameters:
n - the number of bits to be written
Returns:
v the unsigned n-bit value.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyColor

public void writeTinyColor(TinyColor tc)
                    throws java.io.IOException
Writes a TinyColor to the underlying output stream.

Parameters:
tc - the TinyColor value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyPaint

public void writeTinyPaint(TinyPaint paint)
                    throws java.io.IOException
Writes a TinyPaint to the underlying output stream.

Parameters:
paint - the TinyPaint value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyMatrix

public void writeTinyMatrix(TinyMatrix tmat)
                     throws java.io.IOException
Writes a TinyMatrix to the underlying output stream.

Parameters:
tmat - the TinyMatrix value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyRect

public void writeTinyRect(TinyRect rect)
                   throws java.io.IOException
Writes a TinyRect to the underlying output stream.

Parameters:
rect - the TinyRect value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyFont

public void writeTinyFont(TinyFont tfont)
                   throws java.io.IOException
Writes a TinyFont to the underlying output stream.

Parameters:
tfont - the TinyFont value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

writeTinyPath

public void writeTinyPath(TinyPath path)
                   throws java.io.IOException
Writes a TinyPath to the underlying output stream.

Parameters:
path - the TinyPath value to be written.
Throws:
java.io.IOException - if an I/O error has occurred

TinyLine 2.1

Provided under the terms of the TinyLine License Agreement that has been included with this distribution.