Search in sources :

Example 6 with DeserializationException

use of org.javarosa.core.util.externalizable.DeserializationException in project javarosa by opendatakit.

the class QuestionDef method readExternal.

@Override
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException {
    try {
        setID(ExtUtil.readInt(dis));
        binding = (IDataReference) ExtUtil.read(dis, new ExtWrapNullable(new ExtWrapTagged()), pf);
        setAppearanceAttr((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setTextID((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setLabelInnerText((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setHelpText((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setHelpTextID((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setHelpInnerText((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setControlType(ExtUtil.readInt(dis));
        additionalAttributes = ExtUtil.readAttributes(dis, null);
        choices = (List<SelectChoice>) ExtUtil.nullIfEmpty((List<SelectChoice>) ExtUtil.read(dis, new ExtWrapList(SelectChoice.class), pf));
        for (int i = 0; i < getNumChoices(); i++) {
            choices.get(i).setIndex(i);
        }
        setDynamicChoices((ItemsetBinding) ExtUtil.read(dis, new ExtWrapNullable(ItemsetBinding.class)));
        osmTags = (List<OSMTag>) ExtUtil.nullIfEmpty((List<OSMTag>) ExtUtil.read(dis, new ExtWrapList(OSMTag.class), pf));
    } catch (OutOfMemoryError e) {
        throw new DeserializationException("serialization format change caused misalignment and out-of-memory error");
    }
}
Also used : OSMTag(org.javarosa.core.model.osm.OSMTag) ExtWrapTagged(org.javarosa.core.util.externalizable.ExtWrapTagged) ExtWrapList(org.javarosa.core.util.externalizable.ExtWrapList) DeserializationException(org.javarosa.core.util.externalizable.DeserializationException) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Aggregations

DeserializationException (org.javarosa.core.util.externalizable.DeserializationException)6 DataInputStream (java.io.DataInputStream)3 IOException (java.io.IOException)3 TreeElement (org.javarosa.core.model.instance.TreeElement)3 DataOutputStream (java.io.DataOutputStream)2 IDataReference (org.javarosa.core.model.IDataReference)2 IntegerData (org.javarosa.core.model.data.IntegerData)2 StringData (org.javarosa.core.model.data.StringData)2 AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)2 ExtWrapNullable (org.javarosa.core.util.externalizable.ExtWrapNullable)2 ExtWrapTagged (org.javarosa.core.util.externalizable.ExtWrapTagged)2 PrototypeFactory (org.javarosa.core.util.externalizable.PrototypeFactory)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 FormDef (org.javarosa.core.model.FormDef)1 InvalidReferenceException (org.javarosa.core.model.instance.InvalidReferenceException)1 TreeReference (org.javarosa.core.model.instance.TreeReference)1 OSMTag (org.javarosa.core.model.osm.OSMTag)1 ExtWrapList (org.javarosa.core.util.externalizable.ExtWrapList)1 ExtWrapListPoly (org.javarosa.core.util.externalizable.ExtWrapListPoly)1