本文整理汇总了Java中org.msgpack.core.MessagePacker.packDouble方法的典型用法代码示例。如果您正苦于以下问题:Java MessagePacker.packDouble方法的具体用法?Java MessagePacker.packDouble怎么用?Java MessagePacker.packDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.msgpack.core.MessagePacker
的用法示例。
在下文中一共展示了MessagePacker.packDouble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _writeSimpleObjectToPacker
import org.msgpack.core.MessagePacker; //导入方法依赖的package包/类
private void _writeSimpleObjectToPacker(Object object, MessagePacker packer) throws IOException {
if (object == null) {
packer.packNil();
} else if (object instanceof Byte) {
packer.packByte((Byte)object);
} else if (object instanceof Boolean) {
packer.packBoolean((Boolean)object);
} else if (object instanceof Double) {
packer.packDouble((Double)object);
} else if (object instanceof Float) {
packer.packFloat((Float)object);
} else if (object instanceof Integer) {
packer.packInt((Integer)object);
} else if (object instanceof Long) {
packer.packLong((Long)object);
} else if (object instanceof Short) {
packer.packShort((Short)object);
} else if (object instanceof String) {
packer.packString((String)object);
} else {
packer.packNil();
}
}
示例2: packNumber
import org.msgpack.core.MessagePacker; //导入方法依赖的package包/类
private static void packNumber(MessagePacker pack, String num) throws IOException {
BigDecimal dec = new BigDecimal(num);
try {
pack.packBigInteger(dec.toBigIntegerExact());
} catch ( ArithmeticException ex ) {
pack.packDouble(dec.doubleValue());
}
}
示例3: packValue
import org.msgpack.core.MessagePacker; //导入方法依赖的package包/类
private void packValue(Object v) throws IOException {
MessagePacker messagePacker = getMessagePacker();
if (v == null) {
messagePacker.packNil();
}
else if (v instanceof Integer) {
messagePacker.packInt((Integer) v);
}
else if (v instanceof ByteBuffer) {
ByteBuffer bb = (ByteBuffer) v;
messagePacker.packBinaryHeader(bb.limit());
messagePacker.writePayload(bb);
}
else if (v instanceof String) {
messagePacker.packString((String) v);
}
else if (v instanceof Float) {
messagePacker.packFloat((Float) v);
}
else if (v instanceof Long) {
messagePacker.packLong((Long) v);
}
else if (v instanceof StackItemForObject) {
packObject((StackItemForObject) v);
}
else if (v instanceof StackItemForArray) {
packArray((StackItemForArray) v);
}
else if (v instanceof Double) {
messagePacker.packDouble((Double) v);
}
else if (v instanceof BigInteger) {
messagePacker.packBigInteger((BigInteger) v);
}
else if (v instanceof BigDecimal) {
// TODO
throw new NotImplementedException();
}
else if (v instanceof Boolean) {
messagePacker.packBoolean((Boolean) v);
}
else {
throw new IllegalArgumentException(v.toString());
}
}