Package org.dogtagpki.tps.main
Class TPSBuffer
java.lang.Object
org.dogtagpki.tps.main.TPSBuffer
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty Buffer.TPSBuffer
(byte b) Creates a buffer from only one byteTPSBuffer
(byte[] inBuf) Creates a Buffer of length 'len', initialized from 'buf'.TPSBuffer
(int len) Creates a Buffer of length 'len', initialized to zeroes.TPSBuffer
(int len, byte b) Creates a Buffer of length 'len', with each byte initialized to 'b'. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(byte b) Append operators.void
void
addBytes
(byte[] addBytes) void
addInt2Bytes
(int value) void
addLong4Bytes
(long value) byte
at
(int i) void
dump()
dump()s this Buffer to stdout.boolean
Returns true if the two buffers are the same length and contain the same byte at each offset.int
getIntFrom1Byte
(int offset) int
getIntFrom2Bytes
(int offset) long
getLongFrom4Bytes
(int offset) static void
void
void
prependBytes
(byte[] preBytes) void
reset()
void
resize
(int newLen) Changes the length of the Buffer.void
set
(byte[] newContents) void
void
setAt
(int i, byte value) int
size()
The length of buffer.substr
(int start) Get the SubString from start to the endsubstr
(int start, int theLen) Returns a new Buffer that is a substring of this Buffer, starting from offset 'start' and continuing for 'len' bytes.byte[]
void
zeroize()
Sets all bytes in the buffer to 0.
-
Constructor Details
-
TPSBuffer
public TPSBuffer()Creates an empty Buffer. -
TPSBuffer
-
TPSBuffer
public TPSBuffer(int len, byte b) Creates a Buffer of length 'len', with each byte initialized to 'b'. -
TPSBuffer
public TPSBuffer(byte b) Creates a buffer from only one byte- Parameters:
b
-
-
TPSBuffer
public TPSBuffer(int len) Creates a Buffer of length 'len', initialized to zeroes. -
TPSBuffer
public TPSBuffer(byte[] inBuf) Creates a Buffer of length 'len', initialized from 'buf'. 'buf' must contain at least 'len' bytes. -
TPSBuffer
-
-
Method Details
-
at
public byte at(int i) -
setAt
public void setAt(int i, byte value) -
equals
Returns true if the two buffers are the same length and contain the same byte at each offset. -
prepend
-
add
-
set
-
set
public void set(byte[] newContents) -
add
public void add(byte b) Append operators. -
prependBytes
public void prependBytes(byte[] preBytes) -
addBytes
public void addBytes(byte[] addBytes) -
toBytesArray
public byte[] toBytesArray() -
size
public int size()The length of buffer. The actual amount of space allocated may be higher--see capacity(). -
zeroize
public void zeroize()Sets all bytes in the buffer to 0. -
resize
public void resize(int newLen) Changes the length of the Buffer. If 'newLen' is shorter than the current length, the Buffer is truncated. If 'newLen' is longer, the new bytes are initialized to 0. If 'newLen' is the same as size(), this is a no-op. -
substr
Returns a new Buffer that is a substring of this Buffer, starting from offset 'start' and continuing for 'len' bytes. This Buffer must have . -
substr
Get the SubString from start to the end- Parameters:
start
-
-
dump
public void dump()dump()s this Buffer to stdout. -
toHexString
-
toHexStringPlain
-
getIntFrom1Byte
public int getIntFrom1Byte(int offset) -
getIntFrom2Bytes
public int getIntFrom2Bytes(int offset) -
addLong4Bytes
public void addLong4Bytes(long value) -
addInt2Bytes
public void addInt2Bytes(int value) -
getLongFrom4Bytes
public long getLongFrom4Bytes(int offset) -
reset
public void reset() -
main
-