![]() |
OTX-Runtime for Java
|
|
Converts OTX Value to String and vice versa. More...
Static Public Member Functions | |
static Object | String2Value (String stringLiteral, String targetDataType) |
Converts a String into a value of the given data type. More... | |
static String | Value2String (Object value) |
Converts a value from an element of the API to a String literal. More... | |
Converts OTX Value to String and vice versa.
|
inlinestatic |
Converts a String
into a value of the given data type.
This method converts a String
in OTL notation into a value of the given data type. The String for the data type is formatted in OTL notation and is therefore independent from the underlying software platform like C++, DotNet or Java. The data type String can be get via the related method or property of the related OTX element, e.g. ProcedureParameter.
stringLiteral | String literal formatted in OTL notation |
targetDataType | OTL notation of the data type which the string literal will be converted to. To get the data type the property DataType of the related element can be used, e.g. ProcedureParameter. |
OpenTestSystem.Otx.Runtime.Api.Exceptions.InvalidLiteralException | Thrown when a literal string cannot be converted to OTX Object. |
IllegalArgumentException | Thrown when either stringLiteral or targetDataType is null. |
Example
String2Value("1", "Integer"); String2Value("\"Hello World!"", "String"); String2Value("true", "Boolean") String2Value("1.23", "Float"); String2Value("&123456789ABCDEF0", "ByteField"); String2Value("{"Value1", "Value2", "Value3"}", "List<String>"); String2Value("{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}", "Map<String, String>"); String2Value("{StringElement="Hello", IntegerElement=123, FloatElement=457.0}", "StructurePackage1.Document1.StructureSignature1<String, Integer, Float>"); // structure defined in OTX String2Value("IntegerElement", "EnumerationElementPackage1.Document1.EnumerationSignature1"); // enumeration defined in OTX String2Value("{"Value1", "Value2", "Value3"}", parameter.DataType);
|
inlinestatic |
Converts a value from an element of the API to a String
literal.
This method converts a value from an element of the API like a ProcedureParameter to a String
literal. The String
literal is formatted in OTL notation and is therefore independent from the underlying software platform like C++, DotNet or Java.
value | An arbitrary value of an OTX object e.g. ProcedureParameter. |
IllegalArgumentException | Thrown when value is null. |
Example