public void push(ByteQueue source) { if (source.size == 0) return; if (source == this) source = (ByteQueue) clone(); int firstCopyLen = source.queue.length - source.head; if (source.size < firstCopyLen) firstCopyLen = source.size; push(source.queue, source.head, firstCopyLen); if (firstCopyLen < source.size) push(source.queue, 0, source.tail); }
public void push(String hex) { if (hex.length() % 2 != 0) throw new IllegalArgumentException("Hex string must have an even number of characters"); byte[] b = new byte[hex.length() / 2]; for (int i = 0; i < b.length; i++) b[i] = (byte) Integer.parseInt(hex.substring(i * 2, i * 2 + 2), 16); push(b, 0, b.length); }
public void pushLong(long l) { push((byte) (l >> 56)); push((byte) (l >> 48)); push((byte) (l >> 40)); push((byte) (l >> 32)); push((byte) (l >> 24)); push((byte) (l >> 16)); push((byte) (l >> 8)); push((byte) l); }
/** Push unsigned 2 bytes. */ public void pushU2B(int i) { push((byte) (i >> 8)); push((byte) i); }
public void push(long l) { push((byte) l); }
public void push(int i) { push((byte) i); }
public ByteQueue(String hex) { this(hex.length() / 2); push(hex); }
public ByteQueue(byte[] b, int pos, int length) { this(length); push(b, pos, length); }
public ByteQueue(byte[] b) { this(b.length); push(b, 0, b.length); }
public void push(ByteQueue source, int len) { // TODO There is certainly a more elegant way to do this... while (len-- > 0) push(source.pop()); }
public void push(byte[] b) { push(b, 0, b.length); }
public void pushShort(short s) { push((byte) (s >> 8)); push((byte) s); }
public void pushInt(int i) { push((byte) (i >> 24)); push((byte) (i >> 16)); push((byte) (i >> 8)); push((byte) i); }
public void pushChar(char c) { push((byte) (c >> 8)); push((byte) c); }
/** Push unsigned 4 bytes. */ public void pushU4B(long l) { push((byte) (l >> 24)); push((byte) (l >> 16)); push((byte) (l >> 8)); push((byte) l); }