當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalizableWrapper類代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:39,代碼來源:ExternalizableTest.java

示例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());
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:40,代碼來源:ExternalizableTest.java

示例3: clone

import org.javarosa.core.util.externalizable.ExternalizableWrapper; //導入依賴的package包/類
public ExternalizableWrapper clone(Object val) {
	throw new RuntimeException("not supported");
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:4,代碼來源:CompactInstanceWrapper.java

示例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());
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:21,代碼來源:RMS.java


注:本文中的org.javarosa.core.util.externalizable.ExternalizableWrapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。