Class CompactInstanceWrapper

java.lang.Object
org.javarosa.core.model.instance.utils.CompactInstanceWrapper
All Implemented Interfaces:
WrappingStorageUtility.SerializationWrapper, Externalizable

public class CompactInstanceWrapper
extends Object
implements WrappingStorageUtility.SerializationWrapper
An alternate serialization format for FormInstances (saved form instances) that drastically reduces the resultant record size by cutting out redundant information. Size savings are typically 90-95%. The trade-off is that in order to deserialize, a template FormInstance (typically from the original FormDef) must be provided. In general, the format is thus: 1) write the fields from the FormInstance object (e.g., date saved), excluding those that never change for a given form type (e.g., schema). 2) walk the tree depth-first. for each node: if repeatable, write the number of repetitions at the current level; if not, write a boolean indicating if the node is relevant. non-relevant nodes are not descended into. repeated nodes (i.e., several nodes with the same name at the current level) are handled in order 3) for each leaf (data) node, write a boolean whether the node is empty or has data 4) if the node has data, serialize the data. do not specify the data type -- it can be determined from the template. multiple choice questions use a more compact format than normal. 4a) in certain situations where the data differs from its prescribed data type (can happen as the result of 'calculate' expressions), flag the actual data type by hijacking the 'empty' flag above
Author:
Drew Roos