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


Java ValueFactory.createRawValue方法代码示例

本文整理汇总了Java中org.msgpack.type.ValueFactory.createRawValue方法的典型用法代码示例。如果您正苦于以下问题:Java ValueFactory.createRawValue方法的具体用法?Java ValueFactory.createRawValue怎么用?Java ValueFactory.createRawValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.msgpack.type.ValueFactory的用法示例。


在下文中一共展示了ValueFactory.createRawValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: objectToValue

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private Value objectToValue(Object obj) {
    if (obj instanceof String) {
        return ValueFactory.createRawValue((String) obj);
    } else if (obj instanceof Integer) {
        return ValueFactory.createIntegerValue((Integer) obj);
    } else if (obj instanceof Long) {
        return ValueFactory.createIntegerValue((Long) obj);
    } else if (obj instanceof Map) {
        return mapToValue((Map) obj);
    } else if (obj instanceof List) {
        return listToValue((List) obj);
    } else if (obj instanceof Boolean) {
        return ValueFactory.createBooleanValue((Boolean) obj);
    } else if (obj instanceof Double) {
        return ValueFactory.createFloatValue((Double) obj);
    } else {
        return ValueFactory.createNilValue();
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:21,代码来源:JSONUnpacker.java

示例2: join

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
void join(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
    long end_time = System.currentTimeMillis() + unit.toMillis(timeout);
    boolean run_callback = false;
    synchronized (lock) {
        while (done == false) {
            long timeout_remaining = end_time - System.currentTimeMillis();
            if (timeout_remaining <= 0) break;
            lock.wait(timeout_remaining);
        }
        if (!done) {
            this.error = ValueFactory.createRawValue("timedout");
            done = true;
            lock.notifyAll();
            run_callback = true;
        }
    }
    if (run_callback && callback != null) {
        // FIXME #SF submit?
        // session.getEventLoop().getWorkerExecutor().submit(callback);
        callback.run();
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:23,代码来源:FutureImpl.java

示例3: testPackValue

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
public void testPackValue() throws IOException {
	MessagePack msgpack = new MessagePack();
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	Packer packer = msgpack.createPacker(out);
    String text = "This is Value";
    Value value = ValueFactory.createRawValue(text);
    packer.write(value);
    byte[] bytes = out.toByteArray();
    Assert.assertEquals(text.length() + 1,bytes.length);
    Assert.assertEquals(0xa0 + text.length(), 0xff & bytes[0]);
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:13,代码来源:TestPackConvert.java

示例4: testPackValuePassedAsObject

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
public void testPackValuePassedAsObject() throws IOException{
    MessagePack msgpack = new MessagePack();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Packer packer = msgpack.createPacker(out);
    String text = "This is Value";
    Object value = ValueFactory.createRawValue(text);
    packer.write(value); // passed as object
    byte[] bytes = out.toByteArray();
    Assert.assertEquals(text.length() + 1,bytes.length);
    Assert.assertEquals(0xa0 + text.length(), 0xff & bytes[0]);

}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:14,代码来源:TestPackConvert.java

示例5: testValuePassedAsObject

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
   public void testValuePassedAsObject() throws IOException {
MessagePack msgpack = new MessagePack();
       String text = "This class is Value but...";
       Object value = ValueFactory.createRawValue("This class is Value but...");

       byte[] strValue = msgpack.write(value);
       // should be raw type
       assertEquals(0xa0 + text.length(),0xff & strValue[0]);
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:11,代码来源:TestMessagePack01.java

示例6: testRawValueGetString

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
public void testRawValueGetString() throws Exception {
    for (byte[] malform : malforms) {
        RawValue r = ValueFactory.createRawValue(malform);
        try {
            r.getString();
            fail("no exception");
        } catch (MessageTypeException expected) {
        }
        byte[] a = r.getByteArray();
        assertArrayEquals(malform, a);
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:14,代码来源:TestMalformedEncoding.java

示例7: testConverterUnpackString

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
public void testConverterUnpackString() throws Exception {
    for (byte[] malform : malforms) {
        MessagePack msgpack = new MessagePack();
        RawValue r = ValueFactory.createRawValue(malform);
        Converter u = new Converter(msgpack, r);
        try {
            u.readString();
            fail("no exception");
        } catch (MessageTypeException expected) {
        }
        byte[] a = u.readByteArray();
        assertArrayEquals(malform, a);
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:16,代码来源:TestMalformedEncoding.java

示例8: testValueToString

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Test
public void testValueToString() throws Exception {
    for (byte[] malform : malforms) {
        RawValue r = ValueFactory.createRawValue(malform);
        String str = r.toString();
        // malformed bytes will be ignored
        assertEquals("\"\"", str);
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:10,代码来源:TestMalformedEncoding.java

示例9: testByteArray

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Override
public void testByteArray(byte[] v) throws Exception {
    Value v1 = ValueFactory.createRawValue(v);
    Value v2 = ValueFactory.createRawValue(v);
    testEquals(v1, v2);
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:7,代码来源:TestEquals.java

示例10: testString

import org.msgpack.type.ValueFactory; //导入方法依赖的package包/类
@Override
public void testString(String v) throws Exception {
    Value v1 = ValueFactory.createRawValue(v);
    Value v2 = ValueFactory.createRawValue(v);
    testEquals(v1, v2);
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:7,代码来源:TestEquals.java


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