/* * Decompiled with CFR 0.152. * * Could not load the following classes: * javax.baja.nre.util.ByteArrayUtil */ package com.tridium.asm; import javax.baja.nre.util.ByteArrayUtil; public class Buffer { public byte[] bytes; public int count; public final int u1(int n) { int n2 = this.count; if (this.count + 1 >= this.bytes.length) { this.grow(this.count + 1); } this.bytes[this.count++] = (byte)(n & 0xFF); return n2; } public final int u2(int n) { int n2 = this.count; if (this.count + 2 >= this.bytes.length) { this.grow(this.count + 2); } this.bytes[this.count++] = (byte)(n >>> 8 & 0xFF); this.bytes[this.count++] = (byte)(n & 0xFF); return n2; } public final int u4(int n) { int n2 = this.count; if (this.count + 4 >= this.bytes.length) { this.grow(this.count + 4); } this.bytes[this.count++] = (byte)(n >>> 24 & 0xFF); this.bytes[this.count++] = (byte)(n >>> 16 & 0xFF); this.bytes[this.count++] = (byte)(n >>> 8 & 0xFF); this.bytes[this.count++] = (byte)(n & 0xFF); return n2; } public final int u8(long l) { int n = this.count; if (this.count + 8 >= this.bytes.length) { this.grow(this.count + 8); } this.bytes[this.count++] = (byte)(l >>> 56 & 0xFFL); this.bytes[this.count++] = (byte)(l >>> 48 & 0xFFL); this.bytes[this.count++] = (byte)(l >>> 40 & 0xFFL); this.bytes[this.count++] = (byte)(l >>> 32 & 0xFFL); this.bytes[this.count++] = (byte)(l >>> 24 & 0xFFL); this.bytes[this.count++] = (byte)(l >>> 16 & 0xFFL); this.bytes[this.count++] = (byte)(l >>> 8 & 0xFFL); this.bytes[this.count++] = (byte)(l & 0xFFL); return n; } public final void utf(String string) { char c; int n = string.length(); int n2 = 0; int n3 = 0; while (n3 < n) { c = string.charAt(n3); n2 = c >= '\u0001' && c <= '\u007f' ? ++n2 : (c > '\u07ff' ? (n2 += 3) : (n2 += 2)); ++n3; } if (n2 > (int)-1) { throw new RuntimeException("Illegal UTF exception"); } if (this.count + n2 + 2 >= this.bytes.length) { this.grow(this.count + n2 + 2); } this.bytes[this.count++] = (byte)(n2 >>> 8 & 0xFF); this.bytes[this.count++] = (byte)(n2 & 0xFF); n3 = 0; while (n3 < n) { c = string.charAt(n3); if (c >= '\u0001' && c <= '\u007f') { this.bytes[this.count++] = (byte)c; } else if (c > '\u07ff') { this.bytes[this.count++] = (byte)(0xE0 | c >> 12 & 0xF); this.bytes[this.count++] = (byte)(0x80 | c >> 6 & 0x3F); this.bytes[this.count++] = (byte)(0x80 | c & 0x3F); } else { this.bytes[this.count++] = (byte)(0xC0 | c >> 6 & 0x1F); this.bytes[this.count++] = (byte)(0x80 | c & 0x3F); } ++n3; } } public void append(Buffer buffer) { if (this.count + buffer.count >= this.bytes.length) { this.grow(this.count + buffer.count); } System.arraycopy(buffer.bytes, 0, this.bytes, this.count, buffer.count); this.count += buffer.count; } public void append(byte[] byArray) { if (this.count + byArray.length >= this.bytes.length) { this.grow(this.count + byArray.length); } System.arraycopy(byArray, 0, this.bytes, this.count, byArray.length); this.count += byArray.length; } public final void u1(int n, int n2) { this.bytes[n] = (byte)(n2 & 0xFF); } public final void u2(int n, int n2) { this.bytes[n] = (byte)(n2 >>> 8 & 0xFF); this.bytes[n + 1] = (byte)(n2 & 0xFF); } public final void u4(int n, int n2) { this.bytes[n] = (byte)(n2 >>> 24 & 0xFF); this.bytes[n + 1] = (byte)(n2 >>> 16 & 0xFF); this.bytes[n + 2] = (byte)(n2 >>> 8 & 0xFF); this.bytes[n + 3] = (byte)(n2 & 0xFF); } public void dump() { ByteArrayUtil.hexDump((byte[])this.bytes, (int)0, (int)this.count); } private final void grow(int n) { int n2 = Math.max(n, this.bytes.length * 2); byte[] byArray = new byte[n2]; System.arraycopy(this.bytes, 0, byArray, 0, this.bytes.length); this.bytes = byArray; } public Buffer() { this(1024); } public Buffer(int n) { this.bytes = new byte[n]; } }