Get next data bytes with length encoded prefix.

@return the raw binary data
199249
public byte[] getLengthEncodedBytes() {
    int type = this.buf[this.position++] & 0xff;
    int length;
    switch (type) {
      case 251:
        return null;
      case 252:
        length = 0xffff & readShort();
        break;
      case 253:
        length = 0xffffff & read24bitword();
        break;
      case 254:
        length = (int) ((buf[position++] & 0xff)
            + ((long) (buf[position++] & 0xff) << 8)
            + ((long) (buf[position++] & 0xff) << 16)
            + ((long) (buf[position++] & 0xff) << 24)
            + ((long) (buf[position++] & 0xff) << 32)
            + ((long) (buf[position++] & 0xff) << 40)
            + ((long) (buf[position++] & 0xff) << 48)
            + ((long) (buf[position++] & 0xff) << 56));
        break;
      default:
        length = type;
        break;
    }

    byte[] tmpBuf = new byte[length];
    System.arraycopy(buf, position, tmpBuf, 0, length);
    position += length;
    return tmpBuf;
  }
59893
public long getPrefix() {
    // Since JVMs are either 4-byte aligned or 8-byte aligned, we check the size of the string.
    // If size is 0, just return 0.
    // If size is between 0 and 4 (inclusive), assume data is 4-byte aligned under the hood and
    // use a getInt to fetch the prefix.
    // If size is greater than 4, assume we have at least 8 bytes of data to fetch.
    // After getting the data, we use a mask to mask out data that is not part of the string.
    long p;
    long mask = 0;
    if (IS_LITTLE_ENDIAN) {
      if (numBytes >= 8) {
        p = Platform.getLong(base, offset);
      } else if (numBytes > 4) {
        p = Platform.getLong(base, offset);
        mask = (1L << (8 - numBytes) * 8) - 1;
      } else if (numBytes > 0) {
        p = (long) Platform.getInt(base, offset);
        mask = (1L << (8 - numBytes) * 8) - 1;
      } else {
        p = 0;
      }
      p = java.lang.Long.reverseBytes(p);
    } else {
      // byteOrder == ByteOrder.BIG_ENDIAN
      if (numBytes >= 8) {
        p = Platform.getLong(base, offset);
      } else if (numBytes > 4) {
        p = Platform.getLong(base, offset);
        mask = (1L << (8 - numBytes) * 8) - 1;
      } else if (numBytes > 0) {
        p = ((long) Platform.getInt(base, offset)) << 32;
        mask = (1L << (8 - numBytes) * 8) - 1;
      } else {
        p = 0;
      }
    }
    p &= ~mask;
    return p;
  }
254538
public String toBitString() {
    StringBuffer sb = new StringBuffer();
    final int shift = this.bytes.length * 8 - this.bitLength;
    final byte[] shiftRight = shiftRight(this.bytes, shift);
    for (final byte b : shiftRight) {
      String asString = Integer.toBinaryString(b & 0xFF);
      while (asString.length() < 8) {
        asString = "0" + asString;
      }
      sb.append(asString);
    }
    if (sb.length() >= this.bitLength) {
      return sb.substring(sb.length() - this.bitLength, sb.length());
    }
    else {
      final String n = sb.toString();
      sb = new StringBuffer();
      while (sb.length() + n.length() < this.bitLength) {
        sb.append("0");
      }
      return sb + n;
    }
  }
1227611
private int nextByte() throws IOException {
        int result = 0;
        if (!endOfStream) {
            result = read();
            if (result == -1) {
                endOfStream = true;
            }
        }
        return endOfStream ? 0 : result;
    }
756259
private int getLengthFromByteArray(byte[] bin){
        ByteBuffer bb = ByteBuffer.wrap(bin);
        bb.order(ByteOrder.BIG_ENDIAN);
        return bb.getShort();
    }
407987
public static byte[] encode(byte[] data)
	{
		int sourceChunks = data.length / 3;
		int len = (data.length + 2) / 3 * 4;
		byte[] result = new byte[len];
		int extraBytes = data.length - sourceChunks * 3;
		// Each 4 bytes of input (encoded) we end up with 3 bytes of output
		int dataIndex = 0;
		int resultIndex = 0;
		int allBits = 0;
		for (int i = 0; i < sourceChunks; i++)
		{
			allBits = 0;
			// Loop 3 times gathering input bits (3 * 8 = 24)
			for (int j = 0; j < 3; j++)
			{
				allBits = allBits << 8 | data[dataIndex++] & 0xff;
			}
			// Loop 4 times generating output bits (4 * 6 = 24)
			for (int j = resultIndex + 3; j >= resultIndex; j--)
			{
				result[j] = (byte) digits[allBits & 0x3f]; // Bottom
				// 6
				// bits
				allBits = allBits >>> 6;
			}
			resultIndex += 4; // processed 4 result bytes
		}
		// Now we do the extra bytes in case the original (non-encoded) data
		// is not multiple of 4 bytes
		switch (extraBytes)
		{
			case 1:
				allBits = data[dataIndex++]; // actual byte
				allBits = allBits << 8; // 8 bits of zeroes
				allBits = allBits << 8; // 8 bits of zeroes
				// Loop 4 times generating output bits (4 * 6 = 24)
				for (int j = resultIndex + 3; j >= resultIndex; j--)
				{
					result[j] = (byte) digits[allBits & 0x3f]; // Bottom
					// 6
					// bits
					allBits = allBits >>> 6;
				}
				// 2 pad tags
				result[result.length - 1] = equalSign;
				result[result.length - 2] = equalSign;
				break;
			case 2:
				allBits = data[dataIndex++]; // actual byte
				allBits = allBits << 8 | data[dataIndex++] & 0xff; // actual
				// byte
				allBits = allBits << 8; // 8 bits of zeroes
				// Loop 4 times generating output bits (4 * 6 = 24)
				for (int j = resultIndex + 3; j >= resultIndex; j--)
				{
					result[j] = (byte) digits[allBits & 0x3f]; // Bottom
					// 6
					// bits
					allBits = allBits >>> 6;
				}
				// 1 pad tag
				result[result.length - 1] = equalSign;
				break;
		}
		return result;
	}
37528
private int getMoreData() throws IOException {
        if (noMoreInput) {
            return -1;
        } else {
            byte[] buffer = new byte[1024];
            int bytesRead = input.read(buffer);
            if (bytesRead == -1) {
                noMoreInput = true;
                try {
                    obuffer = cipher.doFinal();
                } catch (IllegalBlockSizeException | BadPaddingException e) {
                    throw new CipherException(e);
                }
                if (obuffer == null) {
                    return -1;
                } else {
                    ostart = 0;
                    return ofinish = obuffer.length;
                }
            } else {
                obuffer = cipher.update(buffer, 0, bytesRead);
                ostart = 0;
                return ofinish = (obuffer == null ? 0 : obuffer.length);
            }
        }
    }
25473
public String getHexDump() {
        if (_buf.position() == _buf.limit()) {
            return "empty";
        }

        StringBuilder hexDump = new StringBuilder();
        for (int i = _buf.position(); i < _buf.limit(); i++) {
            hexDump.append(Integer.toHexString(_buf.get(i)&0xFF)).append(' ');
        }
        return hexDump.toString();
    }
1017494
public String getHexEncodedBytes() {
        buffer.b().flip();
        byte bytes[] = new byte[buffer.b().remaining()];
        buffer.b().get(bytes);
        String hex = Encoder.hexEncode(bytes);
        buffer.discard();
        return hex;
    }
724098
public Packet getNextPacket() {
        Packet parsedPacket = parseNextPacketFromPdml();
        
        if ( parsedPacket == null ) {       // All packets have been read
            return null;
        }
        
        parsedPacket = addTcpdumpInfoToPacket(parsedPacket);
        
        return parsedPacket;
    }
1173054
public int getLength() {
        int length = 12;

        if (mCodeBuffer != null) {
            length += mCodeBuffer.getByteCodes().length;
            ExceptionHandler[] handlers = mCodeBuffer.getExceptionHandlers();
            if (handlers != null) {
                length += 8 * handlers.length;
            }
        }
        
        int size = mAttributes.size();
        for (int i=0; i<size; i++) {
            length += mAttributes.get(i).getLength();
            length += 6; // attributes have an intial 6 byte length
        }
        
        return length;
    }
823920
public static String bytesToHex(byte[] raw) {
    if (raw == null) {
      return null;
    }
    final StringBuilder hex = new StringBuilder(2 * raw.length);
    for (final byte b : raw) {
      hex.append(Character.forDigit((b & 0xF0) >> 4, 16))
          .append(Character.forDigit((b & 0x0F), 16));
    }
    return hex.toString();
  }
52374
public byte[] getOctets() {
        byte[] octets = new byte[8];
        long bits = this.bits;
        for (int n = 8; --n >= 0; bits >>= 8) {
            octets[n] = (byte) (bits & 0xff);
        }
        return octets;
    }
458945
public byte[] getBytes() {
        byte[] retval = new byte[buffer.b().position()];
        int position = buffer.b().position();
        buffer.b().rewind();
        buffer.b().get(retval);
        assert position == buffer.b().position();
        return retval;
    }
253717
private byte[] getMMapBytes(long offset)
      throws IOException {
    //Read the first 4 bytes to get the size of the data
    ByteBuffer buf = getDataBuffer(offset);
    int maxLen = (int) Math.min(5, dataSize - offset);

    int size;
    if (buf.remaining() >= maxLen) {
      //Continuous read
      int pos = buf.position();
      size = LongPacker.unpackInt(buf);

      // Used in case of data is spread over multiple buffers
      offset += buf.position() - pos;
    } else {
      //The size of the data is spread over multiple buffers
      int len = maxLen;
      int off = 0;
      sizeBuffer.reset();
      while (len > 0) {
        buf = getDataBuffer(offset + off);
        int count = Math.min(len, buf.remaining());
        buf.get(sizeBuffer.getBuf(), off, count);
        off += count;
        len -= count;
      }
      size = LongPacker.unpackInt(sizeBuffer);
      offset += sizeBuffer.getPos();
      buf = getDataBuffer(offset);
    }

    //Create output bytes
    byte[] res = new byte[size];

    //Check if the data is one buffer
    if (buf.remaining() >= size) {
      //Continuous read
      buf.get(res, 0, size);
    } else {
      int len = size;
      int off = 0;
      while (len > 0) {
        buf = getDataBuffer(offset);
        int count = Math.min(len, buf.remaining());
        buf.get(res, off, count);
        offset += count;
        off += count;
        len -= count;
      }
    }

    return res;
  }
825629
public Object getNextData()
    {
        if (m_iCurrentIndex >= m_string.length())
            m_iCurrentIndex = -1;
        if (m_iCurrentIndex == -1)
            return null;    // EOF
        int iLength = m_string.charAt(m_iCurrentIndex);
        m_iCurrentIndex++;      // Bump past the length
        String strNext = m_string.substring(m_iCurrentIndex, m_iCurrentIndex + iLength);
        m_iCurrentIndex += iLength;   // Bump past the string
        return strNext;
    }
446846
public long getLong() {
		long v = 0;
		v |= ((getByte() & 0xFFL) << 56);
		v |= ((getByte() & 0xFFL) << 48);
		v |= ((getByte() & 0xFFL) << 40);
		v |= ((getByte() & 0xFFL) << 32);
		v |= ((getByte() & 0xFFL) << 24);
		v |= ((getByte() & 0xFFL) << 16);
		v |= ((getByte() & 0xFFL) << 8);
		v |= (getByte() & 0xFFL);
		return v;
	}