public class CellImpl extends Object implements Cell
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
cellBuffer |
ADDRESS_TYPE_HOSTNAME, ADDRESS_TYPE_IPV4, ADRESS_TYPE_IPV6, AUTH_CHALLENGE, AUTHENTICATE, AUTHORIZE, CELL_HEADER_LEN, CELL_LEN, CELL_PAYLOAD_LEN, CELL_VAR_HEADER_LEN, CERTS, CREATE, CREATE_FAST, CREATED, CREATED_FAST, DESTROY, ERROR_CONNECTFAILED, ERROR_DESTROYED, ERROR_FINISHED, ERROR_HIBERNATING, ERROR_INTERNAL, ERROR_NONE, ERROR_NOSUCHSERVICE, ERROR_OR_CONN_CLOSED, ERROR_OR_IDENTITY, ERROR_PROTOCOL, ERROR_REQUESTED, ERROR_RESOURCELIMIT, ERROR_TIMEOUT, NETINFO, PADDING, RELAY, RELAY_EARLY, VERSIONS, VPADDING| Modifier | Constructor and Description |
|---|---|
protected |
CellImpl(byte[] rawCell) |
protected |
CellImpl(int circuitId,
int command) |
| Modifier and Type | Method and Description |
|---|---|
int |
cellBytesConsumed()
Return the number of bytes already packed (for outgoing cells) or unpacked (for incoming cells).
|
int |
cellBytesRemaining()
Return the number of bytes remaining between the current internal pointer and the end of the cell.
|
static CellImpl |
createCell(int circuitId,
int command) |
static CellImpl |
createVarCell(int circuitId,
int command,
int payloadLength) |
static String |
errorToDescription(int errorCode) |
int |
getByte()
Return the next byte from the cell and increment the internal pointer by one byte.
|
void |
getByteArray(byte[] buffer)
Copy
buffer.length bytes from the cell into buffer. |
int |
getByteAt(int index)
Return the byte at the specified offset into the cell.
|
byte[] |
getCellBytes()
Return the entire cell data as a raw array of bytes.
|
int |
getCircuitId()
Return the circuit id field from this cell.
|
int |
getCommand()
Return the command field from this cell.
|
int |
getInt()
Return the next 32-bit big endian value from the cell and increment the internal pointer by four bytes.
|
int |
getShort()
Return the next 16-bit big endian value from the cell and increment the internal pointer by two bytes.
|
int |
getShortAt(int index)
Return the 16-bit big endian value at the specified offset into the cell.
|
void |
putByte(int value)
Store a byte at the current pointer location and increment the pointer by one byte.
|
void |
putByteArray(byte[] data)
Store the entire array
data at the current pointer location and increment
the pointer by data.length bytes. |
void |
putByteArray(byte[] data,
int offset,
int length)
Store
length bytes of the byte array data starting from
offset into the array at the current pointer location and increment
the pointer by length bytes. |
void |
putByteAt(int index,
int value)
Store a byte at the specified offset into the cell.
|
void |
putInt(int value)
Store a 32-bit integer value in big endian order at the current pointer location and
increment the pointer by 4 bytes.
|
void |
putShort(int value)
Store a 16-bit short value in big endian order at the current pointer location and
increment the pointer by two bytes.
|
void |
putShortAt(int index,
int value)
Store a 16-bit short value in big endian byte order at the specified offset into the cell
and increment the pointer by two bytes.
|
void |
putString(String string) |
static CellImpl |
readFromInputStream(InputStream input) |
void |
resetToPayload()
Set the internal pointer to the first byte after the cell header.
|
String |
toString() |
protected final ByteBuffer cellBuffer
protected CellImpl(int circuitId,
int command)
protected CellImpl(byte[] rawCell)
public static CellImpl createCell(int circuitId, int command)
public static CellImpl createVarCell(int circuitId, int command, int payloadLength)
public static CellImpl readFromInputStream(InputStream input) throws IOException
IOExceptionpublic int getCircuitId()
CellgetCircuitId in interface Cellpublic int getCommand()
CellgetCommand in interface Cellpublic void resetToPayload()
CellresetToPayload in interface Cellpublic int getByte()
Cellpublic int getByteAt(int index)
Cellpublic int getShort()
Cellpublic int getInt()
Cellpublic int getShortAt(int index)
CellgetShortAt in interface Cellindex - The cell offset.public void getByteArray(byte[] buffer)
Cellbuffer.length bytes from the cell into buffer. The data is copied starting
from the current internal pointer location and afterwards the internal pointer is incremented by buffer.length
bytes.getByteArray in interface Cellbuffer - The array of bytes to copy the cell data into.public int cellBytesConsumed()
CellcellBytesConsumed in interface Cellpublic int cellBytesRemaining()
CellcellBytesRemaining in interface Cellpublic void putByte(int value)
Cellpublic void putByteAt(int index,
int value)
Cellpublic void putShort(int value)
Cellpublic void putShortAt(int index,
int value)
CellputShortAt in interface Cellindex - The offset in bytes into the cell.value - The 16-bit short value to store.public void putInt(int value)
Cellpublic void putByteArray(byte[] data)
Celldata at the current pointer location and increment
the pointer by data.length bytes.putByteArray in interface Celldata - The array of bytes to store in the cell.public void putByteArray(byte[] data,
int offset,
int length)
Celllength bytes of the byte array data starting from
offset into the array at the current pointer location and increment
the pointer by length bytes.putByteArray in interface Celldata - The source array of bytes.offset - The offset into the source array.length - The number of bytes from the source array to store.public byte[] getCellBytes()
CellVERSIONS, this array will be exactly CELL_LEN bytes long.getCellBytes in interface Cellpublic static String errorToDescription(int errorCode)
Copyright © 2015. All rights reserved.