Top Description Fields Constructors Methods
org.freedesktop.dbus.utils.generator

public final Class TypeConverter

extends Object
Class Inheritance
Imports
org.freedesktop.dbus.Marshalling, org.freedesktop.dbus.exceptions.DBusException, org.freedesktop.dbus.types.*, org.freedesktop.dbus.utils.Util, java.lang.reflect.ParameterizedType, .Type, java.util.*, .Map.Entry, java.util.regex.Matcher, .Pattern, java.util.stream.Collectors

Helper to convert DBus types and java types.
Author
hypfvieh
Since
v3.0.1 - 2018-12-22

Field Summary

Modifier and TypeField and Description
private static final Map<String, String>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static String

Returns:

primitive or original input
convertJavaBoxedTypeToPrimitive
(String
class name of boxed type
_clazzName
)

Converts certain boxed types to primitives.

public static String

Returns:

converted type or original input
convertJavaType
(String
fully qualified classname of the type to convert
_fqcn
,
boolean
if true, boxed types will be converted to primitives
_usePrimitives
)

Transform certain java types to other java types (see CLASS_MAP).

public static String

Returns:

Java classname, maybe null if no suitable input was given
getJavaTypeFromDBusType
(String
DBus data type string
_dbusType
,
Set<String>
List where additional imports will be added to (should not be null!)
_javaIncludes
)

Converts a DBus data type string to java classname(s).

public static String

Returns:

String with proper type, if no converation could be done, original input is returned
getProperJavaClass
(String
Argument to convert
_argType
,
Set<String>
Set where additional includes will be added (should never be null!)
_includes
)

Converts a java class type to another type.

private static Map<String, List<String>>

Returns:

Map where key is parent classname (e.g. List) and value is a list of types used inside the generics
getTypeAdv
(Type
Type object
_type
)

Resolve java type recursively.

private static String

Returns:

class name of the parent type, maybe null if no suitable input provided
getTypeAdv
(String
DBus type string
_dbusType
,
Set<String>
list where additional java imports are added to (if any)
_javaIncludes
)

Special handling for DBusMapType and DBusListType.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASS_MAPback to summary
private static final Map<String, String> CLASS_MAP

Constructor Detail

TypeConverterback to summary
private TypeConverter()

Method Detail

convertJavaBoxedTypeToPrimitiveback to summary
private static String convertJavaBoxedTypeToPrimitive(String _clazzName)

Converts certain boxed types to primitives.

Parameters
_clazzName:String

class name of boxed type

Returns:String

primitive or original input

convertJavaTypeback to summary
public static String convertJavaType(String _fqcn, boolean _usePrimitives)

Transform certain java types to other java types (see CLASS_MAP).

Parameters
_fqcn:String

fully qualified classname of the type to convert

_usePrimitives:boolean

if true, boxed types will be converted to primitives

Returns:String

converted type or original input

getJavaTypeFromDBusTypeback to summary
public static String getJavaTypeFromDBusType(String _dbusType, Set<String> _javaIncludes) throws DBusException

Converts a DBus data type string to java classname(s).

Parameters
_dbusType:String

DBus data type string

_javaIncludes:Set<String>

List where additional imports will be added to (should not be null!)

Returns:String

Java classname, maybe null if no suitable input was given

Exceptions
DBusException:
on DBus error
getProperJavaClassback to summary
public static String getProperJavaClass(String _argType, Set<String> _includes)

Converts a java class type to another type. This is used for converting e.g. CharSequence to String etc. It will also remove unnecessary package names like java.lang.

Parameters
_argType:String

Argument to convert

_includes:Set<String>

Set where additional includes will be added (should never be null!)

Returns:String

String with proper type, if no converation could be done, original input is returned

getTypeAdvback to summary
private static Map<String, List<String>> getTypeAdv(Type _type) throws DBusException

Resolve java type recursively.

Parameters
_type:Type

Type object

Returns:Map<String, List<String>>

Map where key is parent classname (e.g. List) and value is a list of types used inside the generics

Exceptions
DBusException:
on error
getTypeAdvback to summary
private static String getTypeAdv(String _dbusType, Set<String> _javaIncludes) throws DBusException

Special handling for DBusMapType and DBusListType.

Parameters
_dbusType:String

DBus type string

_javaIncludes:Set<String>

list where additional java imports are added to (if any)

Returns:String

class name of the parent type, maybe null if no suitable input provided