com.informix.asf

## Class IfxDataOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FilterOutputStream
    - - com.informix.asf.IfxDataOutputStream

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

Direct Known Subclasses:
  IfxDebugDataOutputStream

    public class IfxDataOutputStream
    extends java.io.FilterOutputStream

This class is the Informix OutputStream class to write the informix datatypes to an OutputStream, throws an IOException in case of error.

### Field Summary

Fields
`protected int` `written` The number of bytes written to the outputstream. Make sure that variable byteCountAtEOT remains of same type as that of written

### Fields inherited from class java.io.FilterOutputStream

`out`

### Constructor Summary

Constructors
Constructor and Description
`IfxDataOutputStream(java.io.OutputStream s)` Constructs an IfxDataOutputStream
`IfxDataOutputStream(java.io.OutputStream s, boolean encoption)`

### Method Summary

Methods
`protected void` `clearTrace()`
`void` `flush()` flushes the outputstream.
`int` `getBytesSentSinceLastEOT()`
`byte[]` `getJavaToIfx4BytesChar(java.lang.String s)` returns a byte array of the given string, conversion routine should be used for servers that have removed 64K Limit, default db local will be used for encoding.
`byte[]` `getJavaToIfx4BytesChar(java.lang.String s, java.lang.String dbenc)` returns a byte array of the given string, conversion routine should be used for servers that have removed 64K Limit, conversion is done based on given dbencoding option.
`byte[]` `getJavaToIfxChar(java.lang.String s)` Returns a byte array after converting given string using default encoding.
`byte[]` `getJavaToIfxChar(java.lang.String s, java.lang.String dbEnc)` Returns a byte array after converting given string using db encoding given.
`void` `setByteCntAtEOT()` This is to be called after SQ_EOT is sent every time .
`void` `write(byte[] b)` writes a byte array to the outputstream.
`void` `write(byte[] b, int offset, int length)` writes a byte array to the outputstream.
`void` `write(int i)` writes a byte to the outputstream.
`void` `writeByte(int i)` writes a byte to the outputstream.
`void` `writeBytes(byte[] b)` Writes the given sequence of bytes to the outputstream
`void` `writeBytesConstant(java.lang.String s)` Strictly to be used by constants that are guaranteed not to throw any UnsupportedEncodingException, for all variables please use writeBytes(byte) method by doing the conversion upfront.
`void` `writeChar(byte[] b)`
`void` `writeDate(java.sql.Date d)` Converts a java date to an Informix date and writes it to the stream
`void` `writeDateTime(java.sql.Timestamp t)` Converts a java datetime to an Informix datetime and writes it to the stream
`void` `writeDecimal(java.math.BigDecimal n)` Converts a java numeric to an Informix decimal and writes it to the stream.
`void` `writeDouble(double d)` Converts a java double to an Informix double precision and writes it to the stream.
`void` `writeInt(int i)` converts an integer to an Informix int and writes it to the outputstream.
`void` `writeInterval(IntervalDF i)` Converts a java interval to an Informix interval and writes it to the stream
`void` `writeInterval(IntervalYM i)` Converts a java interval to an Informix interval and writes it to the stream
`void` `writeLong(long s)` Converts a java long to an Informix int8 and writes it to the stream.
`void` `writeLongBigint(long s)` Converts a java long to an Informix int8 and writes it to the stream.
`void` `writeLongInt(long s)` Converts a java long to an Informix int8 and writes it to the stream.
`void` `writePadded(byte[] b)` writes a byte array to the outputstream.
`void` `writePadded(byte[] b, int offset, int length)` writes a byte array to the outputstream.
`void` `writeReal(float f)` Converts a java real to an Informix real and writes it to the stream.
`void` `writeShort(int i)` Converts a java short to an Informix smallint and writes it to the stream.
`void` `writeShort(short s)`
`void` `writeSmallInt(short s)` Converts a java short to an Informix smallint and writes it to the stream.
`void` `writeWithMangledTrace(byte[] b)` In this class , the implementation is same as Same as write (byte b []) method.
`void` `writeWithoutTrace(byte[] b, int offset, int length)`

### Methods inherited from class java.io.FilterOutputStream

`close`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### written

    protected int written

The number of bytes written to the outputstream.
Make sure that variable byteCountAtEOT remains of same type as that of written

### Constructor Detail

#### IfxDataOutputStream

    public IfxDataOutputStream(java.io.OutputStream s)

Constructs an IfxDataOutputStream

#### IfxDataOutputStream

    public IfxDataOutputStream(java.io.OutputStream s,
                       boolean encoption)

### Method Detail

#### write

    public void write(int i)
               throws java.io.IOException

writes a byte to the outputstream.

Overrides:
  `write` in class `java.io.FilterOutputStream`
Parameters:
  `i` - the byte to write to the outputstream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### write

    public void write(byte[] b,
             int offset,
             int length)
               throws java.io.IOException

writes a byte array to the outputstream.

Overrides:
  `write` in class `java.io.FilterOutputStream`
Parameters:
  `b` - the byte array to write to the outputstream.
  `offset` - the offset of the data.
  `length` - the maximum number of bytes to write to the outputstream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeWithoutTrace

    public void writeWithoutTrace(byte[] b,
                         int offset,
                         int length)
                           throws java.io.IOException

Throws:
  `java.io.IOException`

#### writePadded

    public void writePadded(byte[] b,
                   int offset,
                   int length)
                     throws java.io.IOException

writes a byte array to the outputstream. Writes pad byte if needed.

Parameters:
  `b` - the byte array to write to the outputstream.
  `offset` - the offset of the data.
  `length` - the maximum number of bytes to write to the outputstream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### write

    public void write(byte[] b)
               throws java.io.IOException

writes a byte array to the outputstream.

Overrides:
  `write` in class `java.io.FilterOutputStream`
Parameters:
  `b` - the byte array to write to the outputstream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeWithMangledTrace

    public void writeWithMangledTrace(byte[] b)
                               throws java.io.IOException

In this class , the implementation is same as Same as write (byte b []) method. Used to write bytes which we don't want to log in trace file. such as password bytes. See implementation of this method in IfxDebugDataOutputStream which mangles bytes before writing to trace file.

Parameters:
  `b` -
Throws:
  `java.io.IOException`

#### writePadded

    public void writePadded(byte[] b)
                     throws java.io.IOException

writes a byte array to the outputstream. Adds a pad byte if the length is odd.

Parameters:
  `b` - the byte array to write to the outputstream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeInt

    public void writeInt(int i)
                  throws java.io.IOException

converts an integer to an Informix int and writes it to the outputstream.

Parameters:
  `i` - the java integer to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### flush

    public void flush()
               throws java.io.IOException

flushes the outputstream.

Specified by:
  `flush` in interface `java.io.Flushable`
Overrides:
  `flush` in class `java.io.FilterOutputStream`
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeByte

    public void writeByte(int i)
                   throws java.io.IOException

writes a byte to the outputstream.

Parameters:
  `i` - byte to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeBytes

    public void writeBytes(byte[] b)
                    throws java.io.IOException

Writes the given sequence of bytes to the outputstream

Parameters:
  `b` - byte to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeBytesConstant

    public void writeBytesConstant(java.lang.String s)
                            throws java.io.IOException,
                                   java.sql.SQLException

Strictly to be used by constants that are guaranteed not to throw any UnsupportedEncodingException, for all variables please use writeBytes(byte) method by doing the conversion upfront.

Parameters:
  `s` -
Throws:
  `java.io.IOException`
  `java.sql.SQLException`

#### getJavaToIfxChar

    public byte[] getJavaToIfxChar(java.lang.String s,
                          java.lang.String dbEnc)
                            throws java.io.IOException,
                                   java.sql.SQLException

Returns a byte array after converting given string using db encoding given. IFX_USE_STRENC connection property if set would be used by this method during conversion.

Parameters:
  `s` -
  `dbEnc` -
Returns:
Throws:
  `java.io.IOException`
  `java.sql.SQLException`

#### getJavaToIfxChar

    public byte[] getJavaToIfxChar(java.lang.String s)
                            throws java.io.IOException,
                                   java.sql.SQLException

Returns a byte array after converting given string using default encoding. IFX_USE_STRENC connection property if set would be used by this method during conversion.

Parameters:
  `s` -
Returns:
Throws:
  `java.io.IOException`
  `java.sql.SQLException`

#### getJavaToIfx4BytesChar

    public byte[] getJavaToIfx4BytesChar(java.lang.String s)
                                  throws java.io.IOException,
                                         java.sql.SQLException

returns a byte array of the given string, conversion routine should be used for servers that have removed 64K Limit, default db local will be used for encoding. IFX_USE_STRENC connection property if set would be used by this method during conversion.

Parameters:
  `s` -
Returns:
Throws:
  `java.io.IOException`
  `java.sql.SQLException`

#### getJavaToIfx4BytesChar

    public byte[] getJavaToIfx4BytesChar(java.lang.String s,
                                java.lang.String dbenc)
                                  throws java.io.IOException,
                                         java.sql.SQLException

returns a byte array of the given string, conversion routine should be used for servers that have removed 64K Limit, conversion is done based on given dbencoding option. IFX_USE_STRENC connection property if set would be used by this method during conversion.

Parameters:
  `s` - String to convert
  `dbenc` - db locale encoding to use.
Returns:
Throws:
  `java.io.IOException`
  `java.sql.SQLException`

#### writeChar

    public void writeChar(byte[] b)
                   throws java.io.IOException

Throws:
  `java.io.IOException`

#### writeDate

    public void writeDate(java.sql.Date d)
                   throws java.io.IOException

Converts a java date to an Informix date and writes it to the stream

Parameters:
  `d` - the java.sql.Date to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeDateTime

    public void writeDateTime(java.sql.Timestamp t)
                       throws java.io.IOException

Converts a java datetime to an Informix datetime and writes it to the stream

Parameters:
  `t` - the java.sql.Timestamp to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeInterval

    public void writeInterval(IntervalDF i)
                       throws java.io.IOException

Converts a java interval to an Informix interval and writes it to the stream

Parameters:
  `t` - the IntervalDF to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeInterval

    public void writeInterval(IntervalYM i)
                       throws java.io.IOException

Converts a java interval to an Informix interval and writes it to the stream

Parameters:
  `t` - the IntervalYM to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeDecimal

    public void writeDecimal(java.math.BigDecimal n)
                      throws java.io.IOException

Converts a java numeric to an Informix decimal and writes it to the stream.

Parameters:
  `n` - the java.lang.Bignum to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeDouble

    public void writeDouble(double d)
                     throws java.io.IOException

Converts a java double to an Informix double precision and writes it to the stream.

Parameters:
  `d` - the java double to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeReal

    public void writeReal(float f)
                   throws java.io.IOException

Converts a java real to an Informix real and writes it to the stream.

Parameters:
  `f` - the java float to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeSmallInt

    public void writeSmallInt(short s)
                       throws java.io.IOException

Converts a java short to an Informix smallint and writes it to the stream.

Parameters:
  `s` - the java short to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeShort

    public void writeShort(int i)
                    throws java.io.IOException

Converts a java short to an Informix smallint and writes it to the stream.

Parameters:
  `s` - the java short to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeShort

    public void writeShort(short s)
                    throws java.io.IOException

Throws:
  `java.io.IOException`

#### writeLongInt

    public void writeLongInt(long s)
                      throws java.io.IOException

Converts a java long to an Informix int8 and writes it to the stream.

Parameters:
  `s` - the java long to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeLongBigint

    public void writeLongBigint(long s)
                         throws java.io.IOException

Converts a java long to an Informix int8 and writes it to the stream.

Parameters:
  `s` - the java long to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### writeLong

    public void writeLong(long s)
                   throws java.io.IOException

Converts a java long to an Informix int8 and writes it to the stream.

Parameters:
  `s` - the java long to write to the stream.
Throws:
  `java.io.IOException` - In case an I/O error occurs.

#### setByteCntAtEOT

    public void setByteCntAtEOT()

This is to be called after SQ_EOT is sent every time . This stores number of bytes written at time this method was called in an integer variable byteCountAtEOT

#### getBytesSentSinceLastEOT

    public int getBytesSentSinceLastEOT()

Returns:
  int giving number of bytes written to stream since last SQ_EOT was sent to the server

#### clearTrace

    protected void clearTrace()