Class 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 byte
      TPSBuffer​(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)  
    • 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)