コード例 #1
0
 public void write(Kryo kryo, Output output, Enum object) {
   if (object == null) {
     output.writeVarInt(NULL, true);
     return;
   }
   output.writeVarInt(object.ordinal() + 1, true);
 }
コード例 #2
0
ファイル: InputOutputTest.java プロジェクト: esialb/kryo
  public void testVerySmallBuffers() throws Exception {
    Output out1 = new Output(4, -1);
    Output out2 = new ByteBufferOutput(4, -1);

    for (int i = 0; i < 16; i++) {
      out1.writeVarInt(92, false);
    }

    for (int i = 0; i < 16; i++) {
      out2.writeVarInt(92, false);
    }

    assertEquals(out1.toBytes(), out2.toBytes());
  }
コード例 #3
0
 public void write(Kryo kryo, Output output, BigInteger object) {
   if (object == null) {
     output.writeVarInt(NULL, true);
     return;
   }
   BigInteger value = (BigInteger) object;
   // fast-path optimizations for BigInteger.ZERO constant
   if (value == BigInteger.ZERO) {
     output.writeVarInt(2, true);
     output.writeByte(0);
     return;
   }
   // default behaviour
   byte[] bytes = value.toByteArray();
   output.writeVarInt(bytes.length + 1, true);
   output.writeBytes(bytes);
 }
コード例 #4
0
 public void write(Kryo kryo, Output output, BigDecimal object) {
   if (object == null) {
     output.writeVarInt(NULL, true);
     return;
   }
   BigDecimal value = (BigDecimal) object;
   // fast-path optimizations for BigDecimal constants
   if (value == BigDecimal.ZERO) {
     bigIntegerSerializer.write(kryo, output, BigInteger.ZERO);
     output.writeInt(0, false); // for backwards compatibility
     return;
   }
   // default behaviour
   bigIntegerSerializer.write(kryo, output, value.unscaledValue());
   output.writeInt(value.scale(), false);
 }