当前位置: 首页>>代码示例>>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;未经允许,请勿转载。