public class Transaction extends Object
Note: All "synchronization" calls are now removed for performance reasons, so threaded access to a transaction instance should be synchronized by the calling threads.
WriteCache
Constructor and Description |
---|
Transaction()
Creates a new empty transaction that will be filled with streamed data
using the append methods.
|
Transaction(byte[] data)
Creates a new transaction that has been received from another part.
|
Transaction(byte[] data,
Map<Integer,String> readCache)
Creates a transaction with a read cache.
|
Transaction(InputStream in,
Map<Integer,String> readCache,
DefaultCrypto crypto)
Creates a transaction from the input stream, supporting
InterruptedIOException (from socket.setSoTimeout),
supporting a read cache.
|
Transaction(WriteCache writeCache)
Creates a new empty transaction that will be filled with streamed data
using the append methods.
|
Modifier and Type | Method and Description |
---|---|
void |
append(byte[] appendData)
Appends a byte array to the outgoing transaction.
|
void |
append(byte[] appendData,
int len)
Appends a byte array of a certain length to the outgoing transaction.
|
void |
append(byte[] appendData,
int offset,
int len)
Appends a byte array of a certain length to the outgoing transaction.
|
void |
append(Document document)
Appends an XML document to the transaction.
|
void |
append(Transaction t)
Appends a sub-transaction to the outgoing transaction.
|
void |
appendBoolean(boolean b)
Appends a boolean.
|
void |
appendByte(int val)
Appends an unsigned byte to the outgoing transaction.
|
void |
appendChar(char ch)
Appends a character to the outgoing transaction.
|
void |
appendDataFromTransaction(Transaction t)
Appends a byte array from an existing transaction.
|
void |
appendDouble(double val)
Appends a 64 bit double value to the outgoing transaction.
|
void |
appendFloat(float val)
Appends a float value to the outgoing transaction.
|
void |
appendLong(int val)
Appends a 32 bit signed value to the outgoing transaction.
|
void |
appendLong64(long val)
Appends a 64 bit signed value to the outgoing transaction.
|
void |
appendLongString(String str)
Deprecated.
since NetPhantom 4.0, use appendString instead.
|
void |
appendLongUnicodeString(String str)
Deprecated.
since NetPhantom 4.0, use appendString instead.
|
void |
appendShort(int val)
Appends a 16 bit signed value to the outgoing transaction.
|
void |
appendSigned(int val)
Appends an signed integer with the range -0x1FFFFFFF to 0x1FFFFFFF.
|
void |
appendString(String str)
Appends a String to the outgoing transaction.
|
void |
appendString(String str,
boolean useStringCache)
Appends a String to the outgoing transaction.
|
void |
appendSubTransaction(Transaction t)
Appends a sub transaction to the current transaction.
|
void |
appendUnicodeString(String str)
Deprecated.
since NetPhantom 4.0, use appendString instead.
|
void |
appendUnicodeString(String str,
boolean useStringCache)
Deprecated.
since NetPhantom 4.0, use appendString instead.
|
void |
appendUnsigned(int val)
Appends an unsigned integer with the range 0x00000000 to 0x3FFFFFFF.
|
void |
appendUShort(int val)
Appends a 16 bit unsigned value to the outgoing transaction.
|
Transaction |
createTransaction()
Create and return a new transaction with the same
write cache as the previous transaction.
|
int |
getByte()
Get an unsigned byte from the incoming data without moving the read position.
|
byte[] |
getData()
Gets the byte data of the transaction.
|
byte[] |
getData0()
Gets the byte data of the transaction.
|
static byte[] |
getLongData(int val)
Static helper method to get the 4-byte representation of a
32 bit signed value.
|
int |
getRemainingReadSize()
Gets the remaining size in bytes for read methods in the transaction.
|
int |
getSize()
Gets the size of the transaction.
|
int |
getSizeNoHeader()
Gets the size of the transaction without the header.
|
boolean |
hasAppendedData()
Checks if this transaction has any data in it.
|
void |
makeUnsent()
Called when a transaction's data has been retrieved using
getData()
and the transaction failed to be sent and must be reinitialized for appending
more data or sending again later. |
boolean |
readBoolean()
Reads a boolean from incoming data.
|
int |
readByte()
Reads an unsigned byte from the incoming data.
|
byte[] |
readBytes(int count)
Reads a byte array from the incoming data.
|
char |
readChar()
Reads an encoded character in a byte from the incoming data.
|
byte[] |
readData(int count)
Reads a set of bytes from the incoming data.
|
Document |
readDocument()
Reads an XML document from the transaction.
|
double |
readDouble()
Reads a 64 bit double value from the incoming data.
|
float |
readFloat()
Reads a float value from the incoming data.
|
int |
readIntelLong()
Reads an Intel format encoded 32 bit signed value from the incoming data.
|
int |
readIntelUShort()
Reads an Intel format encoded 16 bit unsigned value from the incoming data.
|
int |
readLong()
Reads a 32 bit signed value from the incoming data.
|
long |
readLong64()
Reads a 64 bit signed value from the incoming data.
|
String |
readLongString()
Deprecated.
since NetPhantom 4.0, use readString instead.
|
String |
readNullTerminatedString()
Reads a null character Ansi string (typically a C string) from the incoming data.
|
int |
readShort()
Reads a 16 bit signed value from the incoming data.
|
int |
readSigned()
Reads a signed integer of the range -0x1FFFFFFF to 0x1FFFFFFF.
|
String |
readString()
Reads a string from the incoming data.
|
Transaction |
readSubTransaction()
Retrieves a sub-transaction from an incoming transaction.
|
Transaction |
readTransaction()
Retrieves a sub-transaction from an incoming transaction.
|
int |
readUnsigned()
Reads an unsigned integer of the range 0x00000000 to 0x3FFFFFFF.
|
int |
readUShort()
Reads a 16 bit unsigned value from the incoming data.
|
void |
send(OutputStream out,
DefaultCrypto crypto)
Sends the transaction on the output stream using a possible
encryption (if not null).
|
void |
setLong(int val,
int pos)
Sets a 32 bit signed value to the outgoing transaction at
the specified position.
|
static int |
setLongData(int val,
int pos,
byte[] data)
Fills an array with the long data (4 bytes).
|
void |
skipBytes(int count)
Skips a number of bytes for reading.
|
void |
unreadBytes(int count)
Unreads a count of bytes.
|
public Transaction(byte[] data)
public Transaction(byte[] data, Map<Integer,String> readCache)
public Transaction(InputStream in, Map<Integer,String> readCache, DefaultCrypto crypto) throws IOException
IOException
- for read errors, or
InterruptedIOException for timeout.public Transaction()
This method does not use a write cache.
public Transaction(WriteCache writeCache)
The writeCache parameter can be null.
public static int setLongData(int val, int pos, byte[] data)
public static byte[] getLongData(int val)
public Transaction readTransaction()
public Transaction readSubTransaction()
Note: Use this method to read sub-transactions added to a send transaction using appendSubTransaction.
public int getRemainingReadSize()
public void skipBytes(int count)
public int readByte()
public char readChar()
public boolean readBoolean()
public byte[] readBytes(int count)
public byte[] readData(int count)
public void unreadBytes(int count)
public int readUnsigned()
public int readSigned()
public int readShort()
public int readUShort()
public int readLong()
public long readLong64()
public float readFloat()
public double readDouble()
public String readString()
@Deprecated public String readLongString()
public int readIntelUShort()
public int readIntelLong()
public String readNullTerminatedString()
public int getByte()
public Document readDocument() throws IOException
IOException
- for document read errors.public Transaction createTransaction()
public int getSize()
public int getSizeNoHeader()
public boolean hasAppendedData()
public byte[] getData()
public byte[] getData0()
public void appendByte(int val)
public void send(OutputStream out, DefaultCrypto crypto) throws IOException
IOException
- for write errors.public void appendChar(char ch)
public void appendBoolean(boolean b)
public void appendUnsigned(int val)
IllegalArgumentException
is thrown.val
- the unsigned integer to append.public void appendSigned(int val)
IllegalArgumentException
is thrown.val
- the signed integer to append.public void appendShort(int val)
public void appendUShort(int val)
public void appendLong(int val)
public void setLong(int val, int pos)
getSize()
in an outgoing transaction when
the long value is used for skipping a transaction on the other
end (the long value is the size of data to skip, but the size
is not known until all sub-transactions are appended).val
- the long value.pos
- position to write the long value.public void appendLong64(long val)
public void appendFloat(float val)
public void appendDouble(double val)
public void appendString(String str)
public void appendString(String str, boolean useStringCache)
@Deprecated public void appendUnicodeString(String str)
@Deprecated public void appendUnicodeString(String str, boolean useStringCache)
@Deprecated public void appendLongString(String str)
@Deprecated public void appendLongUnicodeString(String str)
public void append(Document document) throws TransformerException
document
- the Document to append to the transaction.TransformerException
- When there is a error in the transformation.public void append(Transaction t)
public void appendSubTransaction(Transaction t)
Note: Use the method readSubTransaction to extract a transaction appended using appendDataFromTransaction, not readTransaction.
public void appendDataFromTransaction(Transaction t)
public void append(byte[] appendData)
public void append(byte[] appendData, int len)
public void append(byte[] appendData, int offset, int len)
public void makeUnsent()
getData()
and the transaction failed to be sent and must be reinitialized for appending
more data or sending again later.Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.