Data type | Java Type | Data class |
---|---|---|
char | char | Data.Char |
short | short | Data.Short |
byte | byte | Data.Byte |
int | int | Data.Int |
long | long | Data.Long |
float | float | Data.Float |
double | double | Data.Double |
boolean | boolean | Data.Bool |
string | String | Data.Str |
xmlType | String, see XML values | Data.Xml |
jsonType | String, see JSON values | Data.JSON |
enumType | int, see enumerations | Data.Enum |
Data type | Java Type | Data class |
---|---|---|
array | List | Data.Array |
structure | List | Data.Structure |
union | List | Data.Union |
map | Map | Data.MapData |
int
Datas. As such, as for int
values:int
int
value is the index of the state in the enumeration. For example:<types> <enumType name="intEnum" > <enumValue name="ONE" /> <enumValue name="TWO" /> </enumType> </types>In the following type definition, "ONE" will have the value 1, and "TWO" the value 2:
<types> <enumType name="intEnum" > <enumValue name="ONE" value="1" /> <enumValue name="TWO" value="2"/> </enumType> </types>However, several additional methods allow to get or set the value of an enumeration according to the name of the state.
data.setIntValue(2)
will set the state TWO
data.setStringValue("TWO")
will set the state TWO
String
Datas. They can be set or get as XML Nodes, or as Strings: The Data.Xml datas have two specific methods which allow to get or set the Data value as an XMLNode
:XMLNode
XMLNode
as the argumentXMLNode
represents an element in the XML structure, this element hold:XMLNode.getName()
XMLNode.getAttribute(String)
XMLNode.getChildren()
String
Datas. They can be set or get as JSONObject
, or as Strings: The Data.JSON datas have two specific methods which allow to get or set the Data value as a JSONObject
:JSONObject
JSONObject
as the argument<types> <simpleType name="int" baseType="int" /> <arrayType name="arrayOfInt" type="int"/> </types>The following code will work correctly:
ArrayType myArray = (ArrayType)module.getType("arrayOfInt"); List<Object> firstInstance = myArray.getDefaultValue(); firstInstance.add(1); List<Object> secondInstance = myArray.getDefaultValue(); int size = secondInstance.getSize(); // size is equal to 0
<types> <simpleType name="int" baseType="int" /> </types>We will have:
Type myInt = module.getType("int"); String str = myInt.getValueAsString(2); // str is "2"
<types> <enumType name="intEnum" > <enumValue name="ONE" /> <enumValue name="TWO" /> </enumType> </types>We will have:
EnumType myEnum = (EnumType)module.getType("intEnum"); String str = myEnum.getValueAsString("ONE"); // str is "ONE" str = myEnum.getValueAsString(1); // str is "TWO" str = myEnum.getValueAsString(2); // str is "2" str = myEnum.getValueAsString("TUTU"); // str is nullThe EnumType.getProtectedStateValueAsString(Object) will return a guaranteed state value as a String. It a corresponding state does not exist, the first state name will be returned. For example, with the same enumeration:
EnumType myEnum = (EnumType)module.getType("intEnum"); String str = myEnum.getProtectedStateValueAsString("ONE"); // str is "ONE" str = myEnum.getProtectedStateValueAsString(1); // str is "TWO" str = myEnum.getProtectedStateValueAsString(2); // str is "ONE" str = myEnum.getValueAsString("TUTU"); // str is "ONE"
copy(Data fromData, true)
vesion of the previous methodCopyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence