OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

com.gemplus.opencard.terminal
Class APDUDataOutputStream

java.lang.Object
  |
  +--com.gemplus.opencard.terminal.APDUDataOutputStream

public class APDUDataOutputStream
extends java.lang.Object

Class APDUDataOutputStream provides facilities to encode an APDU command field. An output stream stream can be build from a byte array or directly a ResponseAPDU object. Stream can be read as byte, short or int or arrays of those types.

Version:
$Id: APDUDataOutputStream.java,v 1.1 1999/12/02 16:05:58 damke Exp $
See Also:
ResponseAPDU, APDUDataOutputStream

Constructor Summary
APDUDataOutputStream()
          Constructs an APDUDataOutputStream object.
 
Method Summary
 void close()
          Close the stream (release attached resources)
protected  void finalize()
          Close the stream (release attached resources)
 void reset()
          Reset the stream
 void setBigEndian(boolean bigEndian)
          Sets big endian or little endian mode.
 int size()
          Returns total number of bytes entered in the stream.
 byte[] toByteArray()
          Convert the data entered in the stream as a byte array
 void write(boolean value)
          Writes a boolean at current position in the stream.
 void write(boolean[] value)
          Writes a boolean array at the current position in the stream.
 void write(boolean[] value, int offset, int length)
          Writes a boolean array at the current position in the stream.
 void write(byte value)
          Writes a byte at current position in the stream.
 void write(byte[] value)
          Writes a byte array at current position in the stream.
 void write(byte[] value, int offset, int length)
          Writes a byte array at current position in the stream.
 void write(int value)
          Writes an int at current position in the stream.
 void write(int[] value)
          Writes an int array at the current position in the stream.
 void write(int[] value, int offset, int length)
          Writes an int array at the current position in the stream.
 void write(short value)
          Writes a short at current position in the stream.
 void write(short[] value)
          Writes a short array at the current position in the stream.
 void write(short[] value, int offset, int length)
          Writes a short array at the current position in the stream.
 void write(java.lang.String value)
          Writes a String at the current position in the stream.
 void write(java.lang.String value, int offset, int length)
          Writes a String at the current position in the stream.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

APDUDataOutputStream

public APDUDataOutputStream()
Constructs an APDUDataOutputStream object. This stream lets an application write primitive Java data types into an underlying APDU data.
Data entered are then accessible as a byte array (using method toByteArray())
Method Detail

size

public int size()
Returns total number of bytes entered in the stream.
Returns:
the size of data entered

setBigEndian

public void setBigEndian(boolean bigEndian)
Sets big endian or little endian mode.
Parameters:
bigEndian
- if true, big endian mode is set (default mose)
if false, little endian mode is set

write

public void write(boolean value)
Writes a boolean at current position in the stream.
Parameters:
value - value of the boolean to be written

write

public void write(boolean[] value)
Writes a boolean array at the current position in the stream.
Parameters:
value - value of the array to be written

write

public void write(boolean[] value,
                  int offset,
                  int length)
Writes a boolean array at the current position in the stream.
Parameters:
value - value of the array to be written
offset - offset from which the array will be written in the stream
length - number of booleans to write

write

public void write(byte value)
Writes a byte at current position in the stream.
Parameters:
value - value of the byte to be written

write

public void write(byte[] value)
Writes a byte array at current position in the stream.
Parameters:
value - value of the byte array to be written

write

public void write(byte[] value,
                  int offset,
                  int length)
Writes a byte array at current position in the stream.
Parameters:
value - value of the byte array to be written
offset - offset from which the array will be written in the stream
length - number of bytes to write

write

public void write(short value)
Writes a short at current position in the stream.
Parameters:
value - value of the short tobe written

write

public void write(short[] value)
Writes a short array at the current position in the stream.
Parameters:
value - value of the array to be written

write

public void write(short[] value,
                  int offset,
                  int length)
Writes a short array at the current position in the stream.
Parameters:
value - value of the array to be written
offset - offset from which the array will be written in the stream
length - number of shorts to write

write

public void write(int value)
Writes an int at current position in the stream.
Parameters:
value - value of the int to be written

write

public void write(int[] value)
Writes an int array at the current position in the stream.
Parameters:
value - value of the array to be written

write

public void write(int[] value,
                  int offset,
                  int length)
Writes an int array at the current position in the stream.
Parameters:
value - value of the array to be written
offset - offset from which the array will be written in the stream
length - number of ints to write

write

public void write(java.lang.String value)
Writes a String at the current position in the stream.
Parameters:
value - value of the String to be written

write

public void write(java.lang.String value,
                  int offset,
                  int length)
Writes a String at the current position in the stream.
Parameters:
value - value of the String to be written
offset - offset from which the string will be written in the stream
length - number of characters to write

toByteArray

public byte[] toByteArray()
                   throws APDUDataStreamException
Convert the data entered in the stream as a byte array
Returns:
the byte array

reset

public void reset()
Reset the stream
Returns:
void

close

public void close()
           throws APDUDataStreamException
Close the stream (release attached resources)
Returns:
void

finalize

protected void finalize()
Close the stream (release attached resources)
Returns:
void
Overrides:
finalize in class java.lang.Object