Package org.dogtagpki.tps.main
Class TPSBuffer
- java.lang.Object
-
- org.dogtagpki.tps.main.TPSBuffer
-
public class TPSBuffer extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description TPSBuffer()
Creates 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'.TPSBuffer(java.lang.String str)
TPSBuffer(TPSBuffer cpy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(byte b)
Append operators.void
add(TPSBuffer addend)
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
equals(TPSBuffer cmp)
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
main(java.lang.String[] args)
void
prepend(TPSBuffer prepend)
void
prependBytes(byte[] preBytes)
void
reset()
void
resize(int newLen)
Changes the length of the Buffer.void
set(byte[] newContents)
void
set(TPSBuffer newContents)
void
setAt(int i, byte value)
int
size()
The length of buffer.TPSBuffer
substr(int start)
Get the SubString from start to the endTPSBuffer
substr(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[]
toBytesArray()
java.lang.String
toHexString()
java.lang.String
toHexStringPlain()
void
zeroize()
Sets all bytes in the buffer to 0.
-
-
-
Constructor Detail
-
TPSBuffer
public TPSBuffer()
Creates an empty Buffer.
-
TPSBuffer
public TPSBuffer(java.lang.String str)
-
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
public TPSBuffer(TPSBuffer cpy)
-
-
Method Detail
-
at
public byte at(int i)
-
setAt
public void setAt(int i, byte value)
-
equals
public boolean equals(TPSBuffer cmp)
Returns true if the two buffers are the same length and contain the same byte at each offset.
-
prepend
public void prepend(TPSBuffer prepend)
-
add
public void add(TPSBuffer addend)
-
set
public void set(TPSBuffer newContents)
-
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
public TPSBuffer substr(int start, int theLen)
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
public TPSBuffer substr(int start)
Get the SubString from start to the end- Parameters:
start
-
-
dump
public void dump()
dump()s this Buffer to stdout.
-
toHexString
public java.lang.String toHexString()
-
toHexStringPlain
public java.lang.String 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
public static void main(java.lang.String[] args)
-
-