本文整理匯總了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());
}
}