本文整理汇总了Java中org.javarosa.core.util.externalizable.ExternalizableWrapper类的典型用法代码示例。如果您正苦于以下问题:Java ExternalizableWrapper类的具体用法?Java ExternalizableWrapper怎么用?Java ExternalizableWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExternalizableWrapper类属于org.javarosa.core.util.externalizable包,在下文中一共展示了ExternalizableWrapper类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExternalizable
import org.javarosa.core.util.externalizable.ExternalizableWrapper; //导入依赖的package包/类
public static void testExternalizable(Object orig, Object template, PrototypeFactory pf, String failMessage) {
if (failMessage == null)
failMessage = "Serialization Failure";
byte[] bytes;
Object deser;
print("");
print("Original: " + printObj(orig));
try {
bytes = ExtUtil.serialize(orig);
print("Serialized as:");
print(ExtUtil.printBytes(bytes));
if (template instanceof Class) {
deser = ExtUtil.deserialize(bytes, (Class)template, pf);
} else if (template instanceof ExternalizableWrapper) {
deser = ExtUtil.read(new DataInputStream(new ByteArrayInputStream(bytes)), (ExternalizableWrapper)template, pf);
} else {
throw new ClassCastException();
}
print("Reconstituted: " + printObj(deser));
if (ExtUtil.equals(orig, deser, true)) {
print("SUCCESS");
} else {
print("FAILURE");
fail(failMessage + ": Objects do not match");
}
print("---------------------------------------------");
} catch (Exception e) {
e.printStackTrace();
fail(failMessage + ": Exception! " + e.getClass().getName() + " " + e.getMessage());
}
}
示例2: testExternalizable
import org.javarosa.core.util.externalizable.ExternalizableWrapper; //导入依赖的package包/类
public static void testExternalizable(Object orig, Object template, PrototypeFactory pf, String failMessage) {
if (failMessage == null) {
failMessage = "Serialization Failure";
}
byte[] bytes;
Object deser;
print("");
print("Original: " + printObj(orig));
try {
bytes = ExtUtil.serialize(orig);
print("Serialized as:");
print(ExtUtil.printBytes(bytes));
if (template instanceof Class) {
deser = ExtUtil.deserialize(bytes, (Class)template, pf);
} else if (template instanceof ExternalizableWrapper) {
deser = ExtUtil.read(new DataInputStream(new ByteArrayInputStream(bytes)), (ExternalizableWrapper)template, pf);
} else {
throw new ClassCastException();
}
print("Reconstituted: " + printObj(deser));
if (ExtUtil.equals(orig, deser, true)) {
print("SUCCESS");
} else {
print("FAILURE");
fail(failMessage + ": Objects do not match");
}
print("---------------------------------------------");
} catch (Exception e) {
e.printStackTrace();
fail(failMessage + ": Exception! " + e.getClass().getName() + " " + e.getMessage());
}
}
示例3: clone
import org.javarosa.core.util.externalizable.ExternalizableWrapper; //导入依赖的package包/类
public ExternalizableWrapper clone(Object val) {
throw new RuntimeException("not supported");
}
示例4: readRecord
import org.javarosa.core.util.externalizable.ExternalizableWrapper; //导入依赖的package包/类
/**
* Return a deserialized record object
*
* @param id
* record ID
* @param ew
* ExternalizableWrapper for record type (should not use
* ExtWrapNull(...), as you can't distinguish the record's data
* being null from null as meaning record-not-found)
* @return record object; null if no record exists for that ID
*/
public Object readRecord(int id, ExternalizableWrapper ew) {
byte[] data = readRecord(id);
try {
return (data != null ? ExtUtil.deserialize(data, ew) : null);
} catch (DeserializationException de) {
throw new RuntimeException("Error deserializing bytestream; "
+ de.getMessage());
}
}