本文整理汇总了Java中org.red5.io.object.Deserializer类的典型用法代码示例。如果您正苦于以下问题:Java Deserializer类的具体用法?Java Deserializer怎么用?Java Deserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Deserializer类属于org.red5.io.object包,在下文中一共展示了Deserializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeResult
import org.red5.io.object.Deserializer; //导入依赖的package包/类
/**
* Decode response received from remoting server.
*
* @param data
* Result data to decode
* @return Object deserialized from byte buffer data
*/
private Object decodeResult(IoBuffer data) {
log.debug("decodeResult - data limit: {}", (data != null ? data.limit() : 0));
processHeaders(data);
int count = data.getUnsignedShort();
if (count != 1) {
throw new RuntimeException("Expected exactly one result but got " + count);
}
Input input = new Input(data);
String target = input.getString(); // expect "/onResult"
log.debug("Target: {}", target);
String nullString = input.getString(); // expect "null"
log.debug("Null string: {}", nullString);
// Read return value
Deserializer deserializer = new Deserializer();
return deserializer.deserialize(input, Object.class);
}
示例2: readArray
import org.red5.io.object.Deserializer; //导入依赖的package包/类
public Object readArray(Type target) {
log.debug("readArray - target: {}", target);
Object result = null;
int count = buf.getInt();
log.debug("Count: {}", count);
List<Object> resultCollection = new ArrayList<Object>(count);
storeReference(result);
for (int i = 0; i < count; i++) {
resultCollection.add(Deserializer.deserialize(this, Object.class));
}
// To maintain conformance to the Input API, we should convert the output
// into an Array if the Type asks us to.
Class<?> collection = Collection.class;
if (target instanceof Class<?>) {
collection = (Class<?>) target;
}
if (collection.isArray()) {
result = ArrayUtils.toArray(collection.getComponentType(), resultCollection);
} else {
result = resultCollection;
}
return result;
}
示例3: testByteArray
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testByteArray() {
log.debug("Testing ByteArray");
// just some ones and such
ByteArray baIn = new ByteArray();
baIn.writeBytes(new byte[] { (byte) 0, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42,
(byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x99 });
Serializer.serialize(out, baIn);
dumpOutput();
ByteArray baOut = Deserializer.deserialize(in, ByteArray.class);
assertNotNull(baOut);
assertEquals(baIn.length(), baOut.length());
for (int i = 0; i < baOut.length(); i++) {
System.err.println("Byte: " + baOut.readByte());
}
resetOutput();
}
示例4: testVectorRoundTrip
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testVectorRoundTrip() {
log.debug("Testing Vector on a round trip");
Vector<String> vIn = new Vector<String>();
vIn.add("This is my vector and her name is Sally");
Serializer.serialize(out, vIn);
dumpOutput();
// test fails without enforcing amf3 here
((org.red5.io.amf3.Input) in).enforceAMF3();
Vector<String> vOut = Deserializer.deserialize(in, Vector.class);
assertNotNull(vOut);
assertEquals(vIn.size(), vOut.size());
for (int i = 0; i < vOut.size(); i++) {
System.err.println("Element: " + vOut.elementAt(i));
}
resetOutput();
}
示例5: testVectorIntInput
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testVectorIntInput() {
log.debug("Testing Vector<int>");
//0D090000000002000007D07FFFFFFF80000000
byte[] v = new byte[] { (byte) 0x0D, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xD0,
(byte) 0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
in = new Input(IoBuffer.wrap(v));
List<Object> vectorOut = Deserializer.deserialize(in, null);
//[2, 2000, 2147483647, -2147483648]
assertNotNull(vectorOut);
assertEquals(vectorOut.size(), 4);
for (int i = 0; i < vectorOut.size(); i++) {
System.err.println("Vector: " + vectorOut.get(i));
}
resetOutput();
}
示例6: testVectorUIntInput
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testVectorUIntInput() {
log.debug("Testing Vector<uint>");
//0E090000000002000007D0FFFFFFFF00000000
byte[] v = new byte[] { (byte) 0x0E, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xD0,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
in = new Input(IoBuffer.wrap(v));
List<Object> vectorOut = Deserializer.deserialize(in, null);
//[2, 2000, 4294967295, 0]
assertNotNull(vectorOut);
assertEquals(vectorOut.size(), 4);
for (int i = 0; i < vectorOut.size(); i++) {
System.err.println("Vector: " + vectorOut.get(i));
}
resetOutput();
}
示例7: testVectorNumberInput
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testVectorNumberInput() {
log.debug("Testing Vector<Number>");
//0F0F003FF199999999999ABFF199999999999A7FEFFFFFFFFFFFFF0000000000000001FFF8000000000000FFF00000000000007FF0000000000000
byte[] v = new byte[] { (byte) 0x0F, (byte) 0x0F, (byte) 0x00, (byte) 0x3F, (byte) 0xF1, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x9A,
(byte) 0xBF, (byte) 0xF1, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x99, (byte) 0x9A, (byte) 0x7F, (byte) 0xEF, (byte) 0xFF, (byte) 0xFF,
(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0xFF, (byte) 0xF8, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xFF, (byte) 0xF0, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x7F, (byte) 0xF0, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
in = new Input(IoBuffer.wrap(v));
((org.red5.io.amf3.Input) in).enforceAMF3();
List<Double> vectorOut = Deserializer.deserialize(in, null);
//[1.1, -1.1, 1.7976931348623157E308, 4.9E-324, NaN, -Infinity, Infinity]
assertNotNull(vectorOut);
assertEquals(vectorOut.size(), 7);
for (int i = 0; i < vectorOut.size(); i++) {
System.err.println("Vector: " + vectorOut.get(i));
}
resetOutput();
}
示例8: testVectorMixedInput
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testVectorMixedInput() {
log.debug("Testing Vector<Object>");
//100700010607666f6f010a13256f72672e726564352e74673742e466f6f33000403
//[foo, null, org.red5.test.Foo3[foo=0]] // Foo3 is a class instance
byte[] v2 = new byte[] { (byte) 0x10, (byte) 0x07, (byte) 0x00, (byte) 0x01, (byte) 0x06, (byte) 0x07, (byte) 0x66, (byte) 0x6f, (byte) 0x6f, (byte) 0x01, (byte) 0x0a,
(byte) 0x13, (byte) 0x25, (byte) 0x6f, (byte) 0x72, (byte) 0x67, (byte) 0x2e, (byte) 0x72, (byte) 0x65, (byte) 0x64, (byte) 0x35, (byte) 0x2e, (byte) 0x74,
(byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x2e, (byte) 0x46, (byte) 0x6f, (byte) 0x6f, (byte) 0x33, (byte) 0x00, (byte) 0x04, (byte) 0x03 };
in = new Input(IoBuffer.wrap(v2));
((org.red5.io.amf3.Input) in).enforceAMF3();
List<Object> vectorOut = Deserializer.deserialize(in, null);
assertNotNull(vectorOut);
assertEquals(vectorOut.size(), 3);
for (int i = 0; i < vectorOut.size(); i++) {
System.err.println("Vector: " + vectorOut.get(i));
}
resetOutput();
}
示例9: testList
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testList() {
log.debug("Testing list");
List<Comparable<?>> listIn = new LinkedList<Comparable<?>>();
listIn.add(null);
listIn.add(Boolean.FALSE);
listIn.add(Boolean.TRUE);
listIn.add(Integer.valueOf(1));
listIn.add("This is a test string");
listIn.add(new Date());
Serializer.serialize(out, listIn);
dumpOutput();
List<?> listOut = Deserializer.deserialize(in, List.class);
assertNotNull(listOut);
assertEquals(listIn.size(), listOut.size());
for (int i = 0; i < listIn.size(); i++) {
assertEquals(listOut.get(i), listIn.get(i));
}
resetOutput();
}
示例10: handleParameters
import org.red5.io.object.Deserializer; //导入依赖的package包/类
/**
* Sets incoming connection parameters and / or returns encoded parameters for use in a call.
*
* @param in
* @param notify
* @param input
* @return parameters array
*/
private Object[] handleParameters(IoBuffer in, Notify notify, Input input) {
Object[] params = new Object[] {};
List<Object> paramList = new ArrayList<>();
final Object obj = Deserializer.deserialize(input, Object.class);
if (obj instanceof Map) {
// Before the actual parameters we sometimes (connect) get a map of parameters, this is usually null, but if set should be
// passed to the connection object.
@SuppressWarnings("unchecked")
final Map<String, Object> connParams = (Map<String, Object>) obj;
notify.setConnectionParams(connParams);
} else if (obj != null) {
paramList.add(obj);
}
while (in.hasRemaining()) {
paramList.add(Deserializer.deserialize(input, Object.class));
}
params = paramList.toArray();
if (log.isDebugEnabled()) {
log.debug("Num params: {}", paramList.size());
for (int i = 0; i < params.length; i++) {
log.debug(" > {}: {}", i, params[i]);
}
}
return params;
}
示例11: decodeResult
import org.red5.io.object.Deserializer; //导入依赖的package包/类
/**
* Decode response received from remoting server.
*
* @param data
* Result data to decode
* @return Object deserialized from byte buffer data
*/
private Object decodeResult(IoBuffer data) {
log.debug("decodeResult - data limit: {}", (data != null ? data.limit() : 0));
processHeaders(data);
int count = data.getUnsignedShort();
if (count != 1) {
throw new RuntimeException("Expected exactly one result but got " + count);
}
Input input = new Input(data);
String target = input.getString(); // expect "/onResult"
log.debug("Target: {}", target);
String nullString = input.getString(); // expect "null"
log.debug("Null string: {}", nullString);
// Read return value
return Deserializer.deserialize(input, Object.class);
}
示例12: readArray
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Override
public Object readArray(Type target) {
log.debug("readArray - target: {}", target);
Object result = null;
int count = buf.getInt();
log.debug("Count: {}", count);
// To conform to the Input API, we should convert the output into an Array if the Type asks us to.
Class<?> collection = Collection.class;
if (target instanceof Class<?>) {
collection = (Class<?>) target;
}
List<Object> resultCollection = new ArrayList<>(count);
if (collection.isArray()) {
result = ArrayUtils.getArray(collection.getComponentType(), count);
} else {
result = resultCollection;
}
storeReference(result); //reference should be stored before reading of objects to get correct refIds
for (int i = 0; i < count; i++) {
resultCollection.add(Deserializer.deserialize(this, Object.class));
}
if (collection.isArray()) {
ArrayUtils.fillArray(collection.getComponentType(), result, resultCollection);
}
return result;
}
示例13: readMap
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Override
public Object readMap() {
// the maximum number used in this mixed array
int maxNumber = buf.getInt();
log.debug("Read start mixed array: {}", maxNumber);
ObjectMap<Object, Object> result = new ObjectMap<Object, Object>();
// we must store the reference before we deserialize any items in it to ensure that reference IDs are correct
int reference = storeReference(result);
while (hasMoreProperties()) {
String key = getString();
Object item = Deserializer.deserialize(this, Object.class);
log.debug("item: {}", item);
if (!NumberUtils.isParsable(key)) {
result.put(key, item);
} else {
result.put(Integer.valueOf(key), item);
}
}
result.remove("length");
// replace the original reference with the final result
storeReference(reference, result);
return result;
}
示例14: testByteArray
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testByteArray() {
log.debug("\n Testing ByteArray");
// just some ones and such
ByteArray baIn = new ByteArray();
baIn.writeBytes(new byte[] { (byte) 0, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x1, (byte) 0x42, (byte) 0x99 });
Serializer.serialize(out, baIn);
dumpOutput();
ByteArray baOut = Deserializer.deserialize(in, ByteArray.class);
assertNotNull(baOut);
assertEquals(baIn.length(), baOut.length());
for (int i = 0; i < baOut.length(); i++) {
System.err.println("Byte: " + baOut.readByte());
}
resetOutput();
}
示例15: testVectorIntInput
import org.red5.io.object.Deserializer; //导入依赖的package包/类
@Test
public void testVectorIntInput() {
log.debug("\n Testing Vector<int>");
//0D090000000002000007D07FFFFFFF80000000
byte[] v = new byte[] { (byte) 0x0D, (byte) 0x09, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x07, (byte) 0xD0, (byte) 0x7F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x80, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
in = new Input(IoBuffer.wrap(v));
List<Object> vectorOut = Deserializer.deserialize(in, null);
//[2, 2000, 2147483647, -2147483648]
assertNotNull(vectorOut);
assertEquals(vectorOut.size(), 4);
for (int i = 0; i < vectorOut.size(); i++) {
System.err.println("Vector: " + vectorOut.get(i));
}
resetOutput();
}