use of org.javarosa.core.model.data.IntegerData in project collect by opendatakit.
the class ExIntegerWidget method setBinaryData.
/**
* Allows answer to be set externally in {@link FormEntryActivity}.
*/
@Override
public void setBinaryData(Object answer) {
IntegerData integerData = ExternalAppsUtils.asIntegerData(answer);
this.answer.setText(integerData == null ? null : integerData.getValue().toString());
}
use of org.javarosa.core.model.data.IntegerData in project collect by opendatakit.
the class RangeWidgetTest method getAnswerShouldReflectActualValueSetViaSeekBar.
@Test
public void getAnswerShouldReflectActualValueSetViaSeekBar() {
W widget = getWidget();
assertNull(widget.getAnswer());
int progress = Math.abs(random.nextInt()) % widget.getElementCount();
widget.onProgressChanged(widget.getSeekBar(), progress, true);
BigDecimal actualValue;
if (rangeStart.compareTo(rangeEnd) == -1) {
actualValue = rangeStart.add(new BigDecimal(progress).multiply(rangeStep));
} else {
actualValue = rangeStart.subtract(new BigDecimal(progress).multiply(rangeStep));
}
IAnswerData answer = widget.getAnswer();
IAnswerData compareTo;
if (answer instanceof DecimalData) {
compareTo = new DecimalData(actualValue.doubleValue());
} else {
compareTo = new IntegerData(actualValue.intValue());
}
assertEquals(answer.getDisplayText(), compareTo.getDisplayText());
}
use of org.javarosa.core.model.data.IntegerData in project javarosa by opendatakit.
the class QuestionDataElementTests method setUp.
public void setUp() throws Exception {
super.setUp();
stringData = new StringData("Answer Value");
integerData = new IntegerData(4);
stringReference = new IDataReference() {
String reference = "stringValue";
public Object getReference() {
return reference;
}
public void setReference(Object reference) {
this.reference = (String) reference;
}
/*
public boolean referenceMatches(IDataReference reference) {
return this.reference.equals(reference.getReference());
}
public IDataReference clone() {
IDataReference newReference = null;
try {
newReference = (IDataReference)this.getClass().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
newReference.setReference(reference);
return newReference;
}
*/
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
}
public void writeExternal(DataOutputStream out) throws IOException {
}
};
integerReference = new IDataReference() {
Integer intReference = new Integer(15);
public Object getReference() {
return intReference;
}
public void setReference(Object reference) {
this.intReference = (Integer) reference;
}
/*
public boolean referenceMatches(IDataReference reference) {
return this.intReference.equals(reference.getReference());
}
public IDataReference clone() {
IDataReference newReference = null;
try {
newReference = (IDataReference)this.getClass().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
newReference.setReference(intReference);
return newReference;
}
*/
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
}
public void writeExternal(DataOutputStream out) throws IOException {
}
};
intElement = new TreeElement("intElement");
intElement.setValue(integerData);
stringElement = new TreeElement(stringElementName);
stringElement.setValue(stringData);
}
use of org.javarosa.core.model.data.IntegerData in project javarosa by opendatakit.
the class QuestionDataGroupTests method setUp.
public void setUp() throws Exception {
super.setUp();
stringData = new StringData("Answer Value");
integerData = new IntegerData(4);
stringReference = new IDataReference() {
String reference = "stringValue";
public Object getReference() {
return reference;
}
public void setReference(Object reference) {
this.reference = (String) reference;
}
/*
public boolean referenceMatches(IDataReference reference) {
return this.reference.equals(reference.getReference());
}
public IDataReference clone() {
IDataReference newReference = null;
try {
newReference = (IDataReference)this.getClass().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
newReference.setReference(reference);
return newReference;
}
*/
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
}
public void writeExternal(DataOutputStream out) throws IOException {
}
};
integerReference = new IDataReference() {
Integer intReference = new Integer(15);
public Object getReference() {
return intReference;
}
public void setReference(Object reference) {
this.intReference = (Integer) reference;
}
/*
public boolean referenceMatches(IDataReference reference) {
return this.intReference.equals(reference.getReference());
}
public IDataReference clone() {
IDataReference newReference = null;
try {
newReference = (IDataReference)this.getClass().newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
newReference.setReference(intReference);
return newReference;
}
*/
public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOException, DeserializationException {
}
public void writeExternal(DataOutputStream out) throws IOException {
}
};
intElement = new TreeElement("intElement");
intElement.setValue(integerData);
stringElement = new TreeElement(stringElementName);
stringElement.setValue(stringData);
group = new TreeElement(groupName);
}
use of org.javarosa.core.model.data.IntegerData in project javarosa by opendatakit.
the class XFormAnswerDataSerializerTest method setUp.
public void setUp() throws Exception {
super.setUp();
stringData = new StringData(stringDataValue);
stringElement.setValue(stringData);
integerData = new IntegerData(integerDataValue);
intElement.setValue(integerData);
dateData = new DateData(dateDataValue);
dateElement.setValue(dateData);
timeData = new TimeData(timeDataValue);
timeElement.setValue(timeData);
serializer = new XFormAnswerDataSerializer();
}
Aggregations