public class DataTypeConverter extends Object
| Constructor and Description |
|---|
DataTypeConverter(UaAddressSpace addressSpace)
Creates a new DataTypeConverter, using a given AddressSpace that is used to look up the
UaDataType Nodes that are used.
|
| Modifier and Type | Method and Description |
|---|---|
protected Boolean |
booleanValue(Object value)
Returns the value of the specified Variant as a boolean.
|
Variant |
convert(Variant value,
Class<?> toClass)
Convert the given Variant value to a new Variant of the DataType specified with the given Java
class.
|
Variant |
convert(Variant value,
NodeId dataTypeId)
Convert the given Variant value to a new Variant of the DataType specified with the given
NodeId.
|
Variant |
convert(Variant value,
UaDataType dataType)
Convert the given Variant value to a new Variant of the specified DataType.
|
protected Object |
convertValue(Object value,
Class<?> fromClass,
Class<?> toClass)
Tries to convert the given value from the given class to another given class.
|
protected Object |
convertVariant(Variant value,
Class<?> fromClass,
Class<?> toClass)
Tries to convert the value of the given Variant from the given class to another given class.
|
UaDataType |
getDataTypeForJavaClass(Class<?> clazz)
Deprecated.
Use
getDataTypesForJavaClass(Class) instead as it returns all possible
types. This method just returns the first entry. |
UaDataType[] |
getDataTypesForJavaClass(Class<?> clazz)
Returns the UA DataTypes that correspond to the given Java class.
|
boolean |
isNullable(NodeId dataType)
Deprecated.
returns true for all data types
|
protected Object |
numberToInteger(Number number,
NodeId dataTypeId)
Converts a Number to a UA Integer value.
|
protected Object |
numberToInteger(Number number,
UaDataType dataType)
Converts a Number to a UA Integer value.
|
Variant |
parseVariant(String string,
Class<?> javaClass)
Parse a string to a Variant of the DataType specified with the given Java class.
|
Variant |
parseVariant(String string,
NodeId dataTypeId)
Parse a string to a Variant of the DataType specified with the given NodeId.
|
Variant |
parseVariant(String string,
UaDataType dataType)
Parse a string to a Variant of the specified DataType.
|
protected Number |
toNumber(Object value,
Class<?> toClass)
Convert the given value to the given class.
|
public DataTypeConverter(UaAddressSpace addressSpace)
public Variant convert(Variant value, Class<?> toClass) throws DataTypeConversionException
value - the Variant value to convert.toClass - Java class type, which defines the desired DataTypeDataTypeConversionException - if the conversion failspublic Variant convert(Variant value, NodeId dataTypeId) throws DataTypeConversionException
value - the Variant value to convert.dataTypeId - the NodeId of the UA Data Type to convert to.DataTypeConversionException - if the conversion failspublic Variant convert(Variant value, UaDataType dataType) throws DataTypeConversionException
value - the Variant value to convert.dataType - the UA DataType to convert to.DataTypeConversionException - if the conversion failsIllegalArgumentException - if the given dataType is null@Deprecated public UaDataType getDataTypeForJavaClass(Class<?> clazz)
getDataTypesForJavaClass(Class) instead as it returns all possible
types. This method just returns the first entry.clazz - the Java classIllegalArgumentException - if a suitable data type is not foundpublic UaDataType[] getDataTypesForJavaClass(Class<?> clazz)
clazz - the Java classIllegalArgumentException - if a suitable DataType is not foundRuntimeException - if DataTypeConverter cannot be initialized (e.g. on Client side if the
Client is not connected to the Server).@Deprecated public boolean isNullable(NodeId dataType)
public Variant parseVariant(String string, Class<?> javaClass)
string - string to parsejavaClass - Java class type, which defines the desired DataType.IllegalArgumentException - if the parsing failsNullPointerException - if string is nullpublic Variant parseVariant(String string, NodeId dataTypeId)
string - string to parsedataTypeId - NodeId of the DataType to create: This must correspond to a UaDataType Node
in the NodeMap used by the converter.IllegalArgumentException - if the parsing failsNullPointerException - if string is nullpublic Variant parseVariant(String string, UaDataType dataType)
string - string to parse. Must not be nulldataType - DataType to create. The JavaClass of the DataType must be defined: the
conversion will be done using this class.IllegalArgumentException - if the parsing failsNullPointerException - if string is nullprotected Boolean booleanValue(Object value) throws DataTypeConversionException
value - the value to convert to Boolean.DataTypeConversionException - if the Variant value is not null, but cannot be cast to
booleanprotected Object convertValue(Object value, Class<?> fromClass, Class<?> toClass) throws DataTypeConversionException
value - the value to convert.fromClass - the source class.toClass - the target class.DataTypeConversionException - if the conversion failsprotected Object convertVariant(Variant value, Class<?> fromClass, Class<?> toClass) throws DataTypeConversionException
value - the Variant to convert.fromClass - the source class.toClass - the target class.DataTypeConversionException - if the conversion failsprotected Object numberToInteger(Number number, NodeId dataTypeId)
number - the Number to convert.dataTypeId - the NodeId of the Integer DataType.protected Object numberToInteger(Number number, UaDataType dataType)
number - the Number to convert.dataType - the Integer DataType.protected Number toNumber(Object value, Class<?> toClass) throws ClassCastException
value - the value to convert.toClass - the Number class.ClassCastException - if the conversion failsCopyright © 2026. All rights reserved.