/** * Puts a 64-bit integer into the buffer at the current write position * and increases the write position accordingly. * @param l the 64-bit integer to put */ public void putLong(long l) { putLong(_position, l); _position += 8; }
/** * Puts a 64-bit integer into the buffer at the current write position * and increases the write position accordingly. * @param l the 64-bit integer to put */ public void putLong(long l) { putLong(_position, l); _position += 8; }
/** * Puts a 64-bit floating point number into the buffer at the given * position. Does not increase the write position. * @param pos the position where to put the double * @param d the double to put */ public void putDouble(int pos, double d) { putLong(pos, Double.doubleToRawLongBits(d)); }
/** * Puts a 64-bit floating point number into the buffer at the given * position. Does not increase the write position. * @param pos the position where to put the double * @param d the double to put */ public void putDouble(int pos, double d) { putLong(pos, Double.doubleToRawLongBits(d)); }
/** * Write a BSON date time * * @param date The date to write * @throws IOException If an error occurred in the stream while writing */ public void writeDateTime(Date date) throws IOException { _writeArrayFieldNameIfNeeded(); _verifyValueWrite("write datetime"); _buffer.putByte(_typeMarker, BsonConstants.TYPE_DATETIME); _buffer.putLong(date.getTime()); flushBuffer(); }
/** * Write a BSON date time * * @param date The date to write * @throws IOException If an error occurred in the stream while writing */ public void writeDateTime(Date date) throws IOException { _writeArrayFieldNameIfNeeded(); _verifyValueWrite("write datetime"); _buffer.putByte(_typeMarker, BsonConstants.TYPE_DATETIME); _buffer.putLong(date.getTime()); flushBuffer(); }
@Override public void writeNumber(long v) throws IOException, JsonGenerationException { _writeArrayFieldNameIfNeeded(); _verifyValueWrite("write number"); _buffer.putByte(_typeMarker, BsonConstants.TYPE_INT64); _buffer.putLong(v); flushBuffer(); }
@Override public void writeNumber(long v) throws IOException, JsonGenerationException { _writeArrayFieldNameIfNeeded(); _verifyValueWrite("write number"); _buffer.putByte(_typeMarker, BsonConstants.TYPE_INT64); _buffer.putLong(v); flushBuffer(); }
@Override public void writeNumber(BigDecimal dec) throws IOException, JsonGenerationException { if (isEnabled(Feature.WRITE_BIGDECIMALS_AS_DECIMAL128)) { Decimal128 d = new Decimal128(dec); _writeArrayFieldNameIfNeeded(); _verifyValueWrite("write number"); _buffer.putByte(_typeMarker, BsonConstants.TYPE_DECIMAL128); _buffer.putLong(d.getLow()); _buffer.putLong(d.getHigh()); flushBuffer(); return; } if (isEnabled(Feature.WRITE_BIGDECIMALS_AS_STRINGS)) { writeString(dec.toString()); return; } float f = dec.floatValue(); if (!Float.isInfinite(f)) { writeNumber(f); } else { double d = dec.doubleValue(); if (!Double.isInfinite(d)) { writeNumber(d); } else { writeString(dec.toString()); } } }
@Override public void writeNumber(BigDecimal dec) throws IOException, JsonGenerationException { if (isEnabled(Feature.WRITE_BIGDECIMALS_AS_DECIMAL128)) { Decimal128 d = new Decimal128(dec); _writeArrayFieldNameIfNeeded(); _verifyValueWrite("write number"); _buffer.putByte(_typeMarker, BsonConstants.TYPE_DECIMAL128); _buffer.putLong(d.getLow()); _buffer.putLong(d.getHigh()); flushBuffer(); return; } if (isEnabled(Feature.WRITE_BIGDECIMALS_AS_STRINGS)) { writeString(dec.toString()); return; } float f = dec.floatValue(); if (!Float.isInfinite(f)) { writeNumber(f); } else { double d = dec.doubleValue(); if (!Double.isInfinite(d)) { writeNumber(d); } else { writeString(dec.toString()); } } }