Package org.javarosa.core.model.data
Class UncastData
java.lang.Object
org.javarosa.core.model.data.UncastData
- All Implemented Interfaces:
IAnswerData,Externalizable
public class UncastData extends Object implements IAnswerData
Uncast data values are those which are not assigned a particular
data type. This is relevant when data is read before a datatype is
available, or when it must be pulled from external instances.
In general, Uncast data should be used when a value is available
in string form, and no adequate assumption can be made about the type
of data being represented. This is preferable to making the assumption
that data is a StringData object, since that will cause issues when
select choices or other typed values are expected.
- Author:
- ctsims
-
Constructor Summary
Constructors Constructor Description UncastData()UncastData(String value) -
Method Summary
Modifier and Type Method Description UncastDatacast(UncastData data)Casts the provided data into this data type.IAnswerDataclone()StringgetDisplayText()StringgetString()ObjectgetValue()voidreadExternal(DataInputStream in, PrototypeFactory pf)voidsetValue(Object o)UncastDatauncast()Data types can be uncast if they are expected to be used in different contexts.voidwriteExternal(DataOutputStream out)
-
Constructor Details
-
UncastData
public UncastData() -
UncastData
-
-
Method Details
-
clone
- Specified by:
clonein interfaceIAnswerData- Overrides:
clonein classObject
-
getDisplayText
- Specified by:
getDisplayTextin interfaceIAnswerData- Returns:
- Gets a string representation of this answer
-
getValue
- Specified by:
getValuein interfaceIAnswerData- Returns:
- The value of this answer, will never be null
-
setValue
- Specified by:
setValuein interfaceIAnswerData- Parameters:
o- the value of this answerdata object. Cannot be null. Null Data will not overwrite existing values.
-
getString
- Returns:
- The string representation of this data. This value should be castable into its appropriate data type.
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
uncast
Description copied from interface:IAnswerDataData types can be uncast if they are expected to be used in different contexts. This allows, for instance, select values to be generated by casting other types or vic-a-versa.- Specified by:
uncastin interfaceIAnswerData- Returns:
- An uncast representation of this answer which can be used in a different context.
-
cast
Description copied from interface:IAnswerDataCasts the provided data into this data type.- Specified by:
castin interfaceIAnswerData- Parameters:
data- An uncast data value which is compatible with this data type- Returns:
- An instance of the instance's data type which contains that value
-