Ejemplo n.º 1
0
  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);
  }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 /** Push unsigned 2 bytes. */
 public void pushU2B(int i) {
   push((byte) (i >> 8));
   push((byte) i);
 }
Ejemplo n.º 5
0
 public void push(long l) {
   push((byte) l);
 }
Ejemplo n.º 6
0
 public void push(int i) {
   push((byte) i);
 }
Ejemplo n.º 7
0
 public ByteQueue(String hex) {
   this(hex.length() / 2);
   push(hex);
 }
Ejemplo n.º 8
0
 public ByteQueue(byte[] b, int pos, int length) {
   this(length);
   push(b, pos, length);
 }
Ejemplo n.º 9
0
 public ByteQueue(byte[] b) {
   this(b.length);
   push(b, 0, b.length);
 }
Ejemplo n.º 10
0
 public void push(ByteQueue source, int len) {
   // TODO There is certainly a more elegant way to do this...
   while (len-- > 0) push(source.pop());
 }
Ejemplo n.º 11
0
 public void push(byte[] b) {
   push(b, 0, b.length);
 }
Ejemplo n.º 12
0
 public void pushShort(short s) {
   push((byte) (s >> 8));
   push((byte) s);
 }
Ejemplo n.º 13
0
 public void pushInt(int i) {
   push((byte) (i >> 24));
   push((byte) (i >> 16));
   push((byte) (i >> 8));
   push((byte) i);
 }
Ejemplo n.º 14
0
 public void pushChar(char c) {
   push((byte) (c >> 8));
   push((byte) c);
 }
Ejemplo n.º 15
0
 /** Push unsigned 4 bytes. */
 public void pushU4B(long l) {
   push((byte) (l >> 24));
   push((byte) (l >> 16));
   push((byte) (l >> 8));
   push((byte) l);
 }