本文整理汇总了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();
}
}
示例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();
}
}
示例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]);
}
示例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]);
}
示例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]);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}