Read a decimal according to the Four Dot Four encoding specification.

@param bb
ByteBuffer containing Export stream data
@return decoded BigDecimal value
5033
static public BigDecimal decodeDecimal(final ByteBuffer bb) {
        final int scale = bb.get();
        final int precisionBytes = bb.get();
        final byte[] bytes = new byte[precisionBytes];
        bb.get(bytes);
        return new BigDecimal(new BigInteger(bytes), scale);
    }
1173407
@Override
  public int read () throws IOException
  {
    // Do we need to get data?
    if (m_nPosition < 0)
    {
      if (m_bEncode)
      {
        final byte [] b3 = new byte [3];
        int numBinaryBytes = 0;
        for (int i = 0; i < 3; i++)
        {
          final int b = in.read ();

          // If end of stream, b is -1.
          if (b < 0)
            break;

          b3[i] = (byte) b;
          numBinaryBytes++;
        }

        if (numBinaryBytes > 0)
        {
          Base64._encode3to4 (b3, 0, numBinaryBytes, m_aBuffer, 0, m_nOptions);
          m_nPosition = 0;
          m_nNumSigBytes = 4;
        }
        else
        {
          return -1; // Must be end of stream
        }
      }
      else
      {
        // Else decoding
        final byte [] b4 = new byte [4];
        int i;
        for (i = 0; i < 4; i++)
        {
          // Read four "meaningful" bytes:
          int b;
          do
          {
            b = in.read ();
          } while (b >= 0 && m_aDecodabet[b & 0x7f] <= Base64.WHITE_SPACE_ENC);

          if (b < 0)
            break; // Reads a -1 if end of stream

          b4[i] = (byte) b;
        }

        if (i == 4)
        {
          m_nNumSigBytes = Base64._decode4to3 (b4, 0, m_aBuffer, 0, m_nOptions);
          m_nPosition = 0;
        }
        else
          if (i == 0)
          {
            return -1;
          }
          else
          {
            // Must have broken out from above.
            throw new IOException ("Improperly padded Base64 input.");
          } // end

      }
    }

    // Got data?
    if (m_nPosition >= 0)
    {
      if ( /* !encode && */m_nPosition >= m_nNumSigBytes)
      {
        return -1;
      }

      if (m_bEncode && m_bBreakLines && m_nLineLength >= Base64.MAX_LINE_LENGTH)
      {
        m_nLineLength = 0;
        return '\n';
      }
      {
        m_nLineLength++; // This isn't important when decoding
        // but throwing an extra "if" seems
        // just as wasteful.

        final int b = m_aBuffer[m_nPosition++];

        if (m_nPosition >= m_nBufferLength)
          m_nPosition = -1;

        return b & 0xFF; // This is how you "cast" a byte that's
                         // intended to be unsigned.
      }
    }

    // Else error
    throw new IOException ("Error in Base64 code reading stream.");
  }
1170018
public float readFloat () throws KryoException {
		require(4);
		byte[] buffer = this.buffer;
		int p = this.position;
		this.position = p + 4;
		return Float.intBitsToFloat(buffer[p] & 0xFF //
			| (buffer[p + 1] & 0xFF) << 8 //
			| (buffer[p + 2] & 0xFF) << 16 //
			| (buffer[p + 3] & 0xFF) << 24);
	}
1138341
public static long readUnsignedIntegerBigEndian(ByteBuffer buf) {
		long value;
		value = ((long)(buf.get() & 0xFF)) << 24;
		value |= (buf.get() & 0xFF) << 16;
		value |= (buf.get() & 0xFF) << 8;
		value |= (buf.get() & 0xFF);
		return value;
	}
118916
public static int readVByte(final InputStream is) throws IOException {
		for(int x = 0; ;) {
			final int b = is.read();
			x |= b & 0x7F;
			if ((b & 0x80) == 0) return x;
			x <<= 7;
		}
	}
425368
public BigDecimal toBigDecimal() {
		int precision = Math.max(precision(), MathContext.DECIMAL128.getPrecision());
		return toBigDecimal(new MathContext(precision));
	}
1260417
static public Object decodeVarbinary(final ByteBuffer bb) {
        final int length = bb.getInt();
        final byte[] data = new byte[length];
        bb.get(data);
        return data;
    }
224355
private static Object decodeNextColumn(ByteBuffer bb, VoltType columnType)
            throws IOException {
        Object retval = null;
        switch (columnType) {
        case TINYINT:
            retval = decodeTinyInt(bb);
            break;
        case SMALLINT:
            retval = decodeSmallInt(bb);
            break;
        case INTEGER:
            retval = decodeInteger(bb);
            break;
        case BIGINT:
            retval = decodeBigInt(bb);
            break;
        case FLOAT:
            retval = decodeFloat(bb);
            break;
        case TIMESTAMP:
            retval = decodeTimestamp(bb);
            break;
        case STRING:
            retval = decodeString(bb);
            break;
        case VARBINARY:
            retval = decodeVarbinary(bb);
            break;
        case DECIMAL:
            retval = decodeDecimal(bb);
            break;
        case GEOGRAPHY_POINT:
            retval = decodeGeographyPoint(bb);
            break;
        case GEOGRAPHY:
            retval = decodeGeography(bb);
            break;
        default:
            throw new IOException("Invalid column type: " + columnType);
        }

        return retval;
    }
1111310
protected static int readInt(InputStream input, int bytesNumber, boolean bigEndian) throws IOException
    {
        final int oneByte = 8;
        int ret = 0;
        int sv;
        if (bigEndian)
        {
            sv = (bytesNumber - 1) * oneByte;
        }
        else
        {
            sv = 0;
        }
        final int cnt;
        if (bigEndian)
        {
            cnt = -oneByte;
        }
        else
        {
            cnt = oneByte;
        }
        for (int i = 0; i < bytesNumber; i++)
        {
            ret |= input.read() << sv;
            sv += cnt;
        }
        return ret;
    }
488357
private int readByteFromStream() throws IOException {
    int result = this.in.read();
    if (result >= 0 && this.msb0) {
      result = JBBPUtils.reverseBitsInByte((byte) result) & 0xFF;
    }
    return result;
  }
1150266
@Override
    public int decode ( byte[] buffer, int bufferIndex, int len ) throws SMBProtocolDecodingException {
        this.indexNumber = SMBUtil.readInt8(buffer, bufferIndex);
        return 8;
    }
257769
private static byte[] decode4to3( byte[] fourBytes )
    {
        byte[] outBuff1 = new byte[3];
        int    count    = decode4to3( fourBytes, 0, outBuff1, 0 );
        byte[] outBuff2 = new byte[ count ];
        
        System.arraycopy( outBuff1, 0, outBuff2, 0, count );        
        return outBuff2;
    }
539443
public int read2BE() throws OtpErlangDecodeException {
        final byte[] b = new byte[2];
        try {
            super.read(b);
        } catch (final IOException e) {
            throw new OtpErlangDecodeException("Cannot read from input stream");
        }
        return (b[0] << 8 & 0xff00) + (b[1] & 0xff);
    }
1170572
public BigDecimal getBigDecimal(int columnIndex,
                                    int scale) throws SQLException {

        if (scale < 0) {
            throw Util.outOfRangeArgument();
        }

        // boucherb@users 20020502 - added conversion
        BigDecimal bd = (BigDecimal) getColumnInType(columnIndex,
            Type.SQL_DECIMAL);

        if (bd != null) {
            bd = bd.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
        }

        return bd;
    }
581011
private static ByteBuffer decodePercentEncodedOctets(String s, int i, ByteBuffer bb) {
        if (bb == null) {
            bb = ByteBuffer.allocate(1);
        } else {
            bb.clear();
        }

        while (true) {
            // Decode the hex digits
            bb.put((byte) (decodeHex(s, i++) << 4 | decodeHex(s, i++)));

            // Finish if at the end of the string
            if (i == s.length()) {
                break;
            }

            // Finish if no more percent-encoded octets follow
            if (s.charAt(i++) != '%') {
                break;
            }

            // Check if the byte buffer needs to be increased in size
            if (bb.position() == bb.capacity()) {
                bb.flip();
                // Create a new byte buffer with the maximum number of possible
                // octets, hence resize should only occur once
                ByteBuffer bb_new = ByteBuffer.allocate(s.length() / 3);
                bb_new.put(bb);
                bb = bb_new;
            }
        }

        bb.flip();
        return bb;
    }
222838
public BigDecimal getBigDecimal(String key) throws JSONException {
		Object object = this.get(key);
		try {
			return new BigDecimal(object.toString());
		} catch (Exception e) {
			throw new JSONException("JSONObject[" + quote(key)
					+ "] could not be converted to BigDecimal.");
		}
	}
1168947
public static BigDecimal readBigDecimal(DataInputView source) throws IOException {
		final BigInteger unscaledValue = BigIntSerializer.readBigInteger(source);
		if (unscaledValue == null) {
			return null;
		}
		final int scale = source.readInt();
		// fast-path for 0, 1, 10
		if (scale == 0) {
			if (unscaledValue == BigInteger.ZERO) {
				return BigDecimal.ZERO;
			}
			else if (unscaledValue == BigInteger.ONE) {
				return BigDecimal.ONE;
			}
			else if (unscaledValue == BigInteger.TEN) {
				return BigDecimal.TEN;
			}
		}
		// default
		return new BigDecimal(unscaledValue, scale);
	}