Search in sources :

Example 11 with ExtWrapNullable

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

the class XPathStep method readExternal.

public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
    axis = ExtUtil.readInt(in);
    test = ExtUtil.readInt(in);
    switch(test) {
        case TEST_NAME:
            name = (XPathQName) ExtUtil.read(in, XPathQName.class);
            break;
        case TEST_NAMESPACE_WILDCARD:
            namespace = ExtUtil.readString(in);
            break;
        case TEST_TYPE_PROCESSING_INSTRUCTION:
            literal = (String) ExtUtil.read(in, new ExtWrapNullable(String.class));
            break;
    }
    List<Object> v = (List<Object>) ExtUtil.read(in, new ExtWrapListPoly(), pf);
    predicates = new XPathExpression[v.size()];
    for (int i = 0; i < predicates.length; i++) predicates[i] = (XPathExpression) v.get(i);
}
Also used : ExtWrapListPoly(org.javarosa.core.util.externalizable.ExtWrapListPoly) List(java.util.List) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 12 with ExtWrapNullable

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

the class XPathStep method writeExternal.

public void writeExternal(DataOutputStream out) throws IOException {
    ExtUtil.writeNumeric(out, axis);
    ExtUtil.writeNumeric(out, test);
    switch(test) {
        case TEST_NAME:
            ExtUtil.write(out, name);
            break;
        case TEST_NAMESPACE_WILDCARD:
            ExtUtil.writeString(out, namespace);
            break;
        case TEST_TYPE_PROCESSING_INSTRUCTION:
            ExtUtil.write(out, new ExtWrapNullable(literal));
            break;
    }
    List<XPathExpression> v = Arrays.asList(predicates);
    ExtUtil.write(out, new ExtWrapListPoly(v));
}
Also used : ExtWrapListPoly(org.javarosa.core.util.externalizable.ExtWrapListPoly) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 13 with ExtWrapNullable

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

the class FormDef method writeExternal.

/**
 * Writes the form definition object to the supplied stream.
 *
 * @param dos - the stream to write to.
 * @throws IOException
 */
@Override
public void writeExternal(DataOutputStream dos) throws IOException {
    ExtUtil.writeNumeric(dos, getID());
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(getName()));
    ExtUtil.write(dos, new ExtWrapNullable(getTitle()));
    ExtUtil.write(dos, new ExtWrapListPoly(getChildren()));
    ExtUtil.write(dos, getMainInstance());
    ExtUtil.write(dos, new ExtWrapNullable(localizer));
    List<Condition> conditions = dagImpl.getConditions();
    List<Recalculate> recalcs = dagImpl.getRecalculates();
    ExtUtil.write(dos, new ExtWrapList(conditions));
    ExtUtil.write(dos, new ExtWrapList(recalcs));
    ExtUtil.write(dos, new ExtWrapListPoly(outputFragments));
    ExtUtil.write(dos, new ExtWrapMap(submissionProfiles));
    // for support of multi-instance forms
    ExtUtil.write(dos, new ExtWrapMap(formInstances, new ExtWrapTagged()));
    ExtUtil.write(dos, new ExtWrapMap(eventListeners, new ExtWrapListPoly()));
    ExtUtil.write(dos, new ExtWrapListPoly(extensions));
}
Also used : Condition(org.javarosa.core.model.condition.Condition) ExtWrapListPoly(org.javarosa.core.util.externalizable.ExtWrapListPoly) Recalculate(org.javarosa.core.model.condition.Recalculate) ExtWrapTagged(org.javarosa.core.util.externalizable.ExtWrapTagged) ExtWrapMap(org.javarosa.core.util.externalizable.ExtWrapMap) ExtWrapList(org.javarosa.core.util.externalizable.ExtWrapList) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 14 with ExtWrapNullable

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

the class GroupDef method writeExternal.

/**
 * Write the group definition object to the supplied stream.
 */
public void writeExternal(DataOutputStream dos) throws IOException {
    ExtUtil.writeNumeric(dos, getID());
    ExtUtil.write(dos, new ExtWrapNullable(getAppearanceAttr()));
    ExtUtil.write(dos, new ExtWrapTagged(getBind()));
    ExtUtil.write(dos, new ExtWrapNullable(getTextID()));
    ExtUtil.write(dos, new ExtWrapNullable(getLabelInnerText()));
    ExtUtil.writeBool(dos, getRepeat());
    ExtUtil.write(dos, new ExtWrapListPoly(getChildren()));
    ExtUtil.writeBool(dos, noAddRemove);
    ExtUtil.write(dos, new ExtWrapNullable(count != null ? new ExtWrapTagged(count) : null));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(chooseCaption));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(addCaption));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(delCaption));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(doneCaption));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(addEmptyCaption));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(doneEmptyCaption));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(entryHeader));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(delHeader));
    ExtUtil.writeString(dos, ExtUtil.emptyIfNull(mainHeader));
    ExtUtil.writeAttributes(dos, additionalAttributes);
}
Also used : ExtWrapListPoly(org.javarosa.core.util.externalizable.ExtWrapListPoly) ExtWrapTagged(org.javarosa.core.util.externalizable.ExtWrapTagged) ExtWrapNullable(org.javarosa.core.util.externalizable.ExtWrapNullable)

Example 15 with ExtWrapNullable

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

the class GroupDef method readExternal.

/**
 * Reads a group definition object from the supplied stream.
 */
public void readExternal(DataInputStream dis, PrototypeFactory pf) throws IOException, DeserializationException {
    try {
        setID(ExtUtil.readInt(dis));
        setAppearanceAttr((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setBind((IDataReference) ExtUtil.read(dis, new ExtWrapTagged(), pf));
        setTextID((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setLabelInnerText((String) ExtUtil.read(dis, new ExtWrapNullable(String.class), pf));
        setRepeat(ExtUtil.readBool(dis));
        setChildren((List<IFormElement>) ExtUtil.read(dis, new ExtWrapListPoly(), pf));
        noAddRemove = ExtUtil.readBool(dis);
        count = (IDataReference) ExtUtil.read(dis, new ExtWrapNullable(new ExtWrapTagged()), pf);
        chooseCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        addCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        delCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        doneCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        addEmptyCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        doneEmptyCaption = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        entryHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        delHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        mainHeader = ExtUtil.nullIfEmpty(ExtUtil.readString(dis));
        additionalAttributes = ExtUtil.readAttributes(dis, null);
    } catch (OutOfMemoryError e) {
        throw new DeserializationException("serialization format change caused misalignment and out-of-memory error");
    }
}
Also used : ExtWrapListPoly(org.javarosa.core.util.externalizable.ExtWrapListPoly) ExtWrapTagged(org.javarosa.core.util.externalizable.ExtWrapTagged) DeserializationException(org.javarosa.core.util.externalizable.DeserializationException) 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