use of org.javarosa.core.util.externalizable.ExtWrapNullable in project javarosa by opendatakit.
the class ItemsetBinding method writeExternal.
public void writeExternal(DataOutputStream out) throws IOException {
ExtUtil.write(out, new ExtWrapTagged(nodesetExpr));
ExtUtil.write(out, contextRef);
ExtUtil.write(out, new ExtWrapTagged(labelExpr));
ExtUtil.write(out, new ExtWrapNullable(valueExpr == null ? null : new ExtWrapTagged(valueExpr)));
ExtUtil.write(out, new ExtWrapNullable(copyExpr == null ? null : new ExtWrapTagged(copyExpr)));
ExtUtil.writeBool(out, labelIsItext);
ExtUtil.writeBool(out, copyMode);
}
use of org.javarosa.core.util.externalizable.ExtWrapNullable 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");
}
}
use of org.javarosa.core.util.externalizable.ExtWrapNullable in project javarosa by opendatakit.
the class TreeElement method readExternal.
/* ==== SERIALIZATION ==== */
/*
* TODO:
*
* this new serialization scheme is kind of lame. ideally, we shouldn't have
* to sub-class TreeElement at all; we should have an API that can
* seamlessly represent complex data model objects (like weight history or
* immunizations) as if they were explicity XML subtrees underneath the
* parent TreeElement
*
* failing that, we should wrap this scheme in an ExternalizableWrapper
*/
@Override
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
name = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
multiplicity = ExtUtil.readInt(in);
flags = ExtUtil.readInt(in);
value = (IAnswerData) ExtUtil.read(in, new ExtWrapNullable(new ExtWrapTagged()), pf);
// child
if (!ExtUtil.readBool(in)) {
// 1.
// todo is this needed?
children.clear();
} else {
// 2.
int numChildren = (int) ExtUtil.readNumeric(in);
children.clear();
// 3.
List<TreeElement> newChildren = new ArrayList<>(numChildren);
for (int i = 0; i < numChildren; ++i) {
boolean normal = ExtUtil.readBool(in);
TreeElement child;
if (normal) {
// 3.1
child = new TreeElement();
child.readExternal(in, pf);
} else {
// 3.2
child = (TreeElement) ExtUtil.read(in, new ExtWrapTagged(), pf);
}
child.setParent(this);
newChildren.add(child);
}
children.addAll(newChildren);
}
// end Jan 22, 2009
dataType = ExtUtil.readInt(in);
instanceName = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
constraint = (Constraint) ExtUtil.read(in, new ExtWrapNullable(Constraint.class), pf);
preloadHandler = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
preloadParams = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
namespace = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
bindAttributes = ExtUtil.readAttributes(in, this);
attributes = ExtUtil.readAttributes(in, this);
}
use of org.javarosa.core.util.externalizable.ExtWrapNullable in project javarosa by opendatakit.
the class CompactInstanceWrapper method writeExternal.
/**
* serialize a compact instance
*/
public void writeExternal(DataOutputStream out) throws IOException {
if (instance == null) {
throw new RuntimeException("instance has not yet been set via setData()");
}
ExtUtil.writeNumeric(out, instance.getFormId());
ExtUtil.writeNumeric(out, instance.getID());
ExtUtil.write(out, new ExtWrapNullable(instance.getDateSaved()));
writeTreeElement(out, instance.getRoot());
}
use of org.javarosa.core.util.externalizable.ExtWrapNullable in project javarosa by opendatakit.
the class DataBinding method writeExternal.
/* (non-Javadoc)
* @see org.javarosa.core.services.storage.utilities.Externalizable#writeExternal(java.io.DataOutputStream)
*/
public void writeExternal(DataOutputStream out) throws IOException {
ExtUtil.write(out, new ExtWrapNullable(getId()));
ExtUtil.writeNumeric(out, getDataType());
ExtUtil.write(out, new ExtWrapNullable(getPreload()));
ExtUtil.write(out, new ExtWrapNullable(getPreloadParams()));
ExtUtil.write(out, new ExtWrapTagged(ref));
// don't bother writing relevancy/required/readonly/constraint/calculate/additionalAttrs right now; they're only used during parse anyway
}
Aggregations