Search in sources :

Example 1 with ExtWrapNullable

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

the class TreeElement method writeExternal.

@Override
public void writeExternal(DataOutputStream out) throws IOException {
    ExtUtil.writeString(out, ExtUtil.emptyIfNull(name));
    ExtUtil.writeNumeric(out, multiplicity);
    ExtUtil.writeNumeric(out, flags);
    ExtUtil.write(out, new ExtWrapNullable(value == null ? null : new ExtWrapTagged(value)));
    // child
    if (children.isEmpty()) {
        // 1.
        ExtUtil.writeBool(out, false);
    } else {
        // 1.
        ExtUtil.writeBool(out, true);
        // 2.
        ExtUtil.writeNumeric(out, children.size());
        // 3.
        for (TreeElement child : children) {
            if (child.getClass() == TreeElement.class) {
                // 3.1
                ExtUtil.writeBool(out, true);
                child.writeExternal(out);
            } else {
                // 3.2
                ExtUtil.writeBool(out, false);
                ExtUtil.write(out, new ExtWrapTagged(child));
            }
        }
    }
    // end Jan 22, 2009
    ExtUtil.writeNumeric(out, dataType);
    ExtUtil.writeString(out, ExtUtil.emptyIfNull(instanceName));
    // TODO: inefficient for repeats
    ExtUtil.write(out, new ExtWrapNullable(constraint));
    ExtUtil.writeString(out, ExtUtil.emptyIfNull(preloadHandler));
    ExtUtil.writeString(out, ExtUtil.emptyIfNull(preloadParams));
    ExtUtil.writeString(out, ExtUtil.emptyIfNull(namespace));
    ExtUtil.writeAttributes(out, bindAttributes);
    ExtUtil.writeAttributes(out, attributes);
}
Also used : ExtWrapTagged(org.javarosa.core.util.externalizable.ExtWrapTagged) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 2 with ExtWrapNullable

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

the class CompactInstanceWrapper method readExternal.

/**
 * deserialize a compact instance. note the retrieval of the template data instance
 */
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    int formID = ExtUtil.readInt(in);
    instance = getTemplateInstance(formID).clone();
    instance.setID(ExtUtil.readInt(in));
    instance.setDateSaved((Date) ExtUtil.read(in, new ExtWrapNullable(Date.class)));
    // formID, name, schema, versions, and namespaces are all invariants of the template instance
    TreeElement root = instance.getRoot();
    readTreeElement(root, in, pf);
}
Also used : Date(java.util.Date) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable) TreeElement(org.javarosa.core.model.instance.TreeElement)

Example 3 with ExtWrapNullable

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

the class FormInstance method readExternal.

public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    super.readExternal(in, pf);
    schema = (String) ExtUtil.read(in, new ExtWrapNullable(String.class), pf);
    dateSaved = (Date) ExtUtil.read(in, new ExtWrapNullable(Date.class), pf);
    namespaces = (HashMap<String, Object>) ExtUtil.read(in, new ExtWrapMap(String.class, String.class));
    setRoot((TreeElement) ExtUtil.read(in, TreeElement.class, pf));
}
Also used : ExtWrapMap(org.javarosa.core.util.externalizable.ExtWrapMap) Date(java.util.Date) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 4 with ExtWrapNullable

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

the class TreeReference method readExternal.

@Override
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    refLevel = ExtUtil.readInt(in);
    instanceName = (String) ExtUtil.read(in, new ExtWrapNullable(String.class), pf);
    contextType = ExtUtil.readInt(in);
    int size = ExtUtil.readInt(in);
    for (int i = 0; i < size; ++i) {
        TreeReferenceLevel level = (TreeReferenceLevel) ExtUtil.read(in, TreeReferenceLevel.class);
        this.add(level.intern());
    }
}
Also used : ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 5 with ExtWrapNullable

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

the class XPathQName method readExternal.

public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    namespace = (String) ExtUtil.read(in, new ExtWrapNullable(String.class));
    name = ExtUtil.readString(in);
}
Also used : ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Aggregations

ExtWrapNullable (org.javarosa.core.util.externalizable.ExtWrapNullable)27 ExtWrapTagged (org.javarosa.core.util.externalizable.ExtWrapTagged)13 ExtWrapListPoly (org.javarosa.core.util.externalizable.ExtWrapListPoly)9 ExtWrapList (org.javarosa.core.util.externalizable.ExtWrapList)7 ExtWrapMap (org.javarosa.core.util.externalizable.ExtWrapMap)7 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Date (java.util.Date)3 Condition (org.javarosa.core.model.condition.Condition)2 Recalculate (org.javarosa.core.model.condition.Recalculate)2 DeserializationException (org.javarosa.core.util.externalizable.DeserializationException)2 HashMap (java.util.HashMap)1 Constraint (org.javarosa.core.model.condition.Constraint)1 IConditionExpr (org.javarosa.core.model.condition.IConditionExpr)1 DataInstance (org.javarosa.core.model.instance.DataInstance)1 TreeElement (org.javarosa.core.model.instance.TreeElement)1 OSMTag (org.javarosa.core.model.osm.OSMTag)1 Localizer (org.javarosa.core.services.locale.Localizer)1 OrderedMap (org.javarosa.core.util.OrderedMap)1 ExtWrapBase (org.javarosa.core.util.externalizable.ExtWrapBase)1