org.xbill.DNS.utils
Class DataByteOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.ByteArrayOutputStream
          extended byorg.xbill.DNS.utils.DataByteOutputStream

public class DataByteOutputStream
extends ByteArrayOutputStream

An extension of ByteArrayOutputStream to support directly writing types used by DNS routines.

Author:
Brian Wellington
See Also:
DataByteInputStream

Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
DataByteOutputStream()
          Create a new DataByteOutputStream with the default initial size
DataByteOutputStream(int size)
          Create a new DataByteOutputStream with a specified initial size
 
Method Summary
 int getPos()
          Get the current position in the stream
 void setPos(int pos)
          Set the current position in the stream
 void writeArray(byte[] b)
          Writes a full byte array to the stream.
 void writeArray(byte[] b, boolean writeLength)
          Writes a full byte array to the stream.
 void writeBigInteger(BigInteger i)
          Writes a BigInteger to the stream, encoded as binary data.
 void writeByte(int i)
          Writes a byte to the stream
 void writeInt(int i)
          Writes an int to the stream
 void writeLong(long l)
          Writes a long to the stream
 void writeShort(int i)
          Writes a short to the stream
 void writeShortAt(int i, int pos)
          Writes a short to the stream at a specific location
 void writeString(byte[] s, int start)
          Writes a string represented by a byte array to the stream, encoded as a length byte followed by data
 void writeString(String s)
          Writes a String to the stream, encoded as a length byte followed by data
 void writeUnsignedInt(long i)
          Writes an unsigned int to the stream
 void writeUnsignedShort(int i)
          Writes an unsigned short to the stream
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataByteOutputStream

public DataByteOutputStream(int size)
Create a new DataByteOutputStream with a specified initial size

Parameters:
size - The initial size

DataByteOutputStream

public DataByteOutputStream()
Create a new DataByteOutputStream with the default initial size

Method Detail

writeByte

public void writeByte(int i)
Writes a byte to the stream

Parameters:
i - The byte to be written

writeShort

public void writeShort(int i)
Writes a short to the stream

Parameters:
i - The short to be written

writeUnsignedShort

public void writeUnsignedShort(int i)
Writes an unsigned short to the stream

Parameters:
i - The unsigned short to be written

writeInt

public void writeInt(int i)
Writes an int to the stream

Parameters:
i - The int to be written

writeUnsignedInt

public void writeUnsignedInt(long i)
Writes an unsigned int to the stream

Parameters:
i - The unsigned int to be written

writeLong

public void writeLong(long l)
Writes a long to the stream

Parameters:
l - The long to be written

writeString

public void writeString(String s)
Writes a String to the stream, encoded as a length byte followed by data

Parameters:
s - The String to be written

writeString

public void writeString(byte[] s,
                        int start)
Writes a string represented by a byte array to the stream, encoded as a length byte followed by data

Parameters:
s - The byte array containing the string to be written
start - The start of the string withing the byte array.

writeArray

public void writeArray(byte[] b,
                       boolean writeLength)
Writes a full byte array to the stream.

Parameters:
b - The byte array to be written.

writeArray

public void writeArray(byte[] b)
Writes a full byte array to the stream.

Parameters:
b - The byte array to be written.

writeBigInteger

public void writeBigInteger(BigInteger i)
Writes a BigInteger to the stream, encoded as binary data. If present, the leading 0 byte is removed.

Parameters:
i - The BigInteger to be written

writeShortAt

public void writeShortAt(int i,
                         int pos)
Writes a short to the stream at a specific location

Parameters:
i - The short to be written
pos - The position at which the write occurs

setPos

public void setPos(int pos)
Set the current position in the stream

Parameters:
pos - The current position

getPos

public int getPos()
Get the current position in the stream

Returns:
The current position