Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful Session Pause (Hotfix) #1437

Open
wants to merge 2 commits into
base: commcare_2.54
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions src/main/java/org/javarosa/core/model/FormIndex.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package org.javarosa.core.model;

import org.javarosa.core.model.instance.TreeReference;

import org.javarosa.core.util.externalizable.DeserializationException;
import org.javarosa.core.util.externalizable.ExtUtil;
import org.javarosa.core.util.externalizable.ExtWrapNullable;
import org.javarosa.core.util.externalizable.Externalizable;
import org.javarosa.core.util.externalizable.PrototypeFactory;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;

/**
Expand All @@ -22,15 +30,15 @@
*
* @author Clayton Sims
*/
public class FormIndex {
public class FormIndex implements Externalizable {

private boolean beginningOfForm = false;
private boolean endOfForm = false;

/**
* The index of the questiondef in the current context
*/
private final int localIndex;
private int localIndex;

/**
* The multiplicity of the current instance of a repeated question or group
Expand All @@ -44,6 +52,10 @@ public class FormIndex {

private TreeReference reference;

// needed for serialization
public FormIndex(){
}

public static FormIndex createBeginningOfFormIndex() {
FormIndex begin = new FormIndex(-1, null);
begin.beginningOfForm = true;
Expand Down Expand Up @@ -453,4 +465,24 @@ public void assignRefs(FormDef f) {
i++;
}
}

@Override
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
beginningOfForm = ExtUtil.readBool(in);
endOfForm = ExtUtil.readBool(in);
localIndex = ExtUtil.readInt(in);
instanceIndex = ExtUtil.readInt(in);
reference = (TreeReference)ExtUtil.read(in, new ExtWrapNullable(TreeReference.class), pf);
nextLevel = (FormIndex)ExtUtil.read(in, new ExtWrapNullable(FormIndex.class), pf);
}

@Override
public void writeExternal(DataOutputStream out) throws IOException {
ExtUtil.writeBool(out, beginningOfForm);
ExtUtil.writeBool(out, endOfForm);
ExtUtil.writeNumeric(out, localIndex);
ExtUtil.writeNumeric(out, instanceIndex);
ExtUtil.write(out, new ExtWrapNullable(reference));
ExtUtil.write(out, new ExtWrapNullable(nextLevel));
}
}