本文整理汇总了Java中org.msgpack.type.ValueFactory.createArrayValue方法的典型用法代码示例。如果您正苦于以下问题:Java ValueFactory.createArrayValue方法的具体用法?Java ValueFactory.createArrayValue怎么用?Java ValueFactory.createArrayValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.msgpack.type.ValueFactory
的用法示例。
在下文中一共展示了ValueFactory.createArrayValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listToValue
import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private Value listToValue(List list) {
Value[] array = new Value[list.size()];
for (int i = 0; i < array.length; i++) {
array[i] = objectToValue(list.get(i));
}
return ValueFactory.createArrayValue(array, true);
}
示例2: createComplexType
import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
public Value createComplexType() throws Exception {
Random rand = new Random(System.currentTimeMillis());
byte[] b0 = new byte[0];
byte[] b1 = new byte[10];
rand.nextBytes(b1);
byte[] b2 = new byte[1024];
rand.nextBytes(b2);
Value list = ValueFactory.createArrayValue(new Value[] {
ValueFactory.createRawValue(b0),
ValueFactory.createRawValue(b1),
ValueFactory.createRawValue(b2), });
Value map = ValueFactory.createMapValue(new Value[] {
ValueFactory.createIntegerValue(0),
ValueFactory.createIntegerValue(Integer.MIN_VALUE),
ValueFactory.createIntegerValue(rand.nextInt()),
ValueFactory.createIntegerValue(Integer.MAX_VALUE),
ValueFactory.createFloatValue(rand.nextFloat()),
ValueFactory.createBooleanValue(true),
ValueFactory.createFloatValue(rand.nextDouble()),
ValueFactory.createNilValue(), });
List<Value> values = new ArrayList<Value>();
for (int i = 0; i < 2; i++) {
values.add(list);
for (int j = 0; j < 100; j++) {
values.add(map);
}
}
Value complex = ValueFactory.createArrayValue(values
.toArray(new Value[values.size()]));
return complex;
}
示例3: testBooleanArray
import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Override
public void testBooleanArray(boolean[] v) throws Exception {
Value[] vs1 = new Value[v.length];
Value[] vs2 = new Value[v.length];
for (int i = 0; i < v.length; i++) {
vs1[i] = ValueFactory.createBooleanValue(v[i]);
vs2[i] = ValueFactory.createBooleanValue(v[i]);
}
Value v1 = ValueFactory.createArrayValue(vs1);
Value v2 = ValueFactory.createArrayValue(vs2);
testEquals(v1, v2);
}
示例4: testNested
import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
public void testNested() throws Exception {
MessagePack msgpack = new MessagePack();
BufferPacker packer = msgpack.createBufferPacker();
Value v1 = ValueFactory.createArrayValue(new Value[] {
ValueFactory.createRawValue("a"),
ValueFactory.createMapValue(new Value[] {
ValueFactory.createRawValue("k1"),
ValueFactory
.createArrayValue(new Value[] { ValueFactory
.createIntegerValue(1) }) }) });
Value v2 = ValueFactory.createArrayValue(new Value[] {
ValueFactory.createMapValue(new Value[] {
ValueFactory.createRawValue("k1"),
ValueFactory
.createArrayValue(new Value[] { ValueFactory
.createIntegerValue(1) }),
ValueFactory.createRawValue("k2"),
ValueFactory
.createArrayValue(new Value[] { ValueFactory
.createIntegerValue(2) }) }),
ValueFactory.createMapValue(new Value[] {
ValueFactory.createRawValue("k1"),
ValueFactory
.createArrayValue(new Value[] { ValueFactory
.createIntegerValue(1) }),
ValueFactory.createRawValue("k2"),
ValueFactory
.createArrayValue(new Value[] { ValueFactory
.createIntegerValue(2) }) }),
ValueFactory.createRawValue("a") });
for (int i = 0; i < 10; i++) {
packer.write(v1);
packer.write(v2);
}
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker(bytes);
for (int i = 0; i < 10; i++) {
unpacker.skip();
Value v2a = unpacker.readValue();
assertEquals(v2, v2a);
}
}
示例5: RemoteError
import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
public RemoteError() {
super();
this.data = ValueFactory.createArrayValue(
new Value[] { ValueFactory.createRawValue("unknown error") });
}