当前位置: 首页>>代码示例>>Java>>正文


Java ValueFactory.createArrayValue方法代码示例

本文整理汇总了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);
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:9,代码来源:JSONUnpacker.java

示例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;
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:37,代码来源:TestBufferUnpacker.java

示例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);
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:13,代码来源:TestEquals.java

示例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);
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:50,代码来源:TestUnpackerSkip.java

示例5: RemoteError

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
public RemoteError() {
    super();
    this.data = ValueFactory.createArrayValue(
            new Value[] { ValueFactory.createRawValue("unknown error") });
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:6,代码来源:RemoteError.java


注:本文中的org.msgpack.type.ValueFactory.createArrayValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。