Top Description Fields Constructors Methods
org.freedesktop.dbus

public final Class Marshalling

extends Object
Class Inheritance
Imports
org.freedesktop.dbus.annotations.Position, org.freedesktop.dbus.connections.AbstractConnection, org.freedesktop.dbus.connections.base.AbstractConnectionBase, org.freedesktop.dbus.exceptions.DBusException, .DBusTypeConversationRuntimeException, org.freedesktop.dbus.interfaces.DBusInterface, .DBusSerializable, org.freedesktop.dbus.messages.constants.ArgumentType, org.freedesktop.dbus.types.*, org.freedesktop.dbus.utils.LoggingHelper, org.slf4j.Logger, .LoggerFactory, java.lang.reflect.*, java.util.*, .Map.Entry, java.util.concurrent.ConcurrentHashMap

Contains static methods for marshalling values.

Field Summary

Modifier and TypeField and Description
private static final Map<Class<?>, Byte>
private static final String[]
private static final Type[]
private static final String
private static final int
INITIAL_BUFFER_SZ

Used as initial and incremental size of StringBuffer array when resolving DBusTypes recursively.

private static final Logger
private static final String
private static final Map<Type, String[]>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

The DBus types
convertJavaClassesToSignature
(Class<?>...
The Java types.
_javaType
)

Will return the DBus type corresponding to the given Java type.

public static Object[]

Returns:

The converted parameters.
convertParameters
(Object[]
The parameters to convert.
_parameters
,
Type[]
The (possibly generic) types of the parameters.
_types
,
String[]
custom signatures used for variants found in _types, each found variant must have one matching custom signature
_customSignatures
,
AbstractConnectionBase
the connection
_conn
)

Recursively converts types for serialization onto DBus.

public static Object[]

Returns:

The converted parameters.
convertParameters
(Object[]
The parameters to convert.
_parameters
,
Type[]
The (possibly generic) types of the parameters.
_types
,
AbstractConnectionBase
the connection
_conn
)

Recursively converts types for serialization onto DBus.

private static int
convertToSig(StringBuilder _sig, int _idx, Class<?>... _javaType)

pack-priv static Object
pack-priv static List<Object>
public static Object[]
deSerializeParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn)

public static String

Returns:

The DBus types.
getDBusType
(Type[]
The Java types.
_javaType
)

Will return the DBus type corresponding to the given Java type.

public static String[]

Returns:

The DBus type.
getDBusType
(Type
The Java type.
_javaType
)

Will return the DBus type corresponding to the given Java type.

public static String[]

Returns:

The DBus type.
getDBusType
(Type
The Java type.
_dataType
,
boolean
If true enforces this to be a non-compound type. (compound types are Maps, Structs and Lists/arrays).
_basic
)

Will return the DBus type corresponding to the given Java type.

public static int

Returns:

number of characters parsed from the type string.
getJavaType
(String
The DBus type or types.
_dbusType
,
List<Type>
List to return the types in.
_resultValue
,
int
Maximum number of types to parse (-1 == nolimit).
_limit
)

Converts a dbus type string into Java Type objects,

private static String[]
recursiveGetDBusType(StringBuffer[] _out, Type _dataType, boolean _basic, int _level)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLASS_TO_ARGUMENTTYPEback to summary
private static final Map<Class<?>, Byte> CLASS_TO_ARGUMENTTYPE
EMPTY_STRING_ARRAYback to summary
private static final String[] EMPTY_STRING_ARRAY
EMPTY_TYPE_ARRAYback to summary
private static final Type[] EMPTY_TYPE_ARRAY
ERROR_MULTI_VALUED_ARRAYback to summary
private static final String ERROR_MULTI_VALUED_ARRAY
INITIAL_BUFFER_SZback to summary
private static final int INITIAL_BUFFER_SZ

Used as initial and incremental size of StringBuffer array when resolving DBusTypes recursively.

LOGGERback to summary
private static final Logger LOGGER
MTH_NAME_DESERIALIZEback to summary
private static final String MTH_NAME_DESERIALIZE
TYPE_CACHEback to summary
private static final Map<Type, String[]> TYPE_CACHE

Constructor Detail

Marshallingback to summary
private Marshalling()

Method Detail

convertJavaClassesToSignatureback to summary
public static String convertJavaClassesToSignature(Class<?>... _javaType) throws DBusTypeConversationRuntimeException

Will return the DBus type corresponding to the given Java type. Note, container type should have their ParameterizedType not their Class passed in here.

Parameters
_javaType:Class<?>[]

The Java types.

Returns:String

The DBus types

Exceptions
DBusTypeConversationRuntimeException:
when conversation fails
Since
5.1.0 - 2024-05-19
convertParametersback to summary
public static Object[] convertParameters(Object[] _parameters, Type[] _types, String[] _customSignatures, AbstractConnectionBase _conn) throws DBusException

Recursively converts types for serialization onto DBus.

When _customSignature is not empty or null, it will be used to wrap the given parameters to a Variant
of the type defined in the _customSignature array.
It is required that every Variant passed has a signature definition in _customSignature.
E.g. 3 Objects are given in _parameters: String, Variant, Variant.
Then it is expected that _customSignature (if used) contains 2 entries one for each Variant.

If the _customSignature is smaller than the count of Variants in _parameters, all remaining Variants
are created without a explicit signature (Variant constructor will try to determine type automatically).
If more entries are given then Variants found in _parameters, the additional signatures are ignored.

Parameters
_parameters:Object[]

The parameters to convert.

_types:Type[]

The (possibly generic) types of the parameters.

_customSignatures:String[]

custom signatures used for variants found in _types, each found variant must have one matching custom signature

_conn:AbstractConnectionBase

the connection

Returns:Object[]

The converted parameters.

Exceptions
DBusException:
Thrown if there is an error in converting the objects.
convertParametersback to summary
public static Object[] convertParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn) throws DBusException

Recursively converts types for serialization onto DBus.

Parameters
_parameters:Object[]

The parameters to convert.

_types:Type[]

The (possibly generic) types of the parameters.

_conn:AbstractConnectionBase

the connection

Returns:Object[]

The converted parameters.

Exceptions
DBusException:
Thrown if there is an error in converting the objects.
convertToSigback to summary
private static int convertToSig(StringBuilder _sig, int _idx, Class<?>... _javaType)
deSerializeParameterback to summary
pack-priv static Object deSerializeParameter(Object _parameter, Type _type, AbstractConnectionBase _conn) throws Exception
Annotations
@SuppressWarnings:unchecked, rawtypes
deSerializeParametersback to summary
pack-priv static List<Object> deSerializeParameters(List<Object> _parameters, Type _type, AbstractConnectionBase _conn) throws Exception
deSerializeParametersback to summary
public static Object[] deSerializeParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn) throws Exception
Annotations
@SuppressWarnings:unchecked
getDBusTypeback to summary
public static String getDBusType(Type[] _javaType) throws DBusException

Will return the DBus type corresponding to the given Java type. Note, container type should have their ParameterizedType not their Class passed in here.

Parameters
_javaType:Type[]

The Java types.

Returns:String

The DBus types.

getDBusTypeback to summary
public static String[] getDBusType(Type _javaType) throws DBusException

Will return the DBus type corresponding to the given Java type. Note, container type should have their ParameterizedType not their Class passed in here.

Parameters
_javaType:Type

The Java type.

Returns:String[]

The DBus type.

Exceptions
DBusException:
If the given type cannot be converted to a DBus type.
getDBusTypeback to summary
public static String[] getDBusType(Type _dataType, boolean _basic) throws DBusException

Will return the DBus type corresponding to the given Java type. Note, container type should have their ParameterizedType not their Class passed in here.

Parameters
_dataType:Type

The Java type.

_basic:boolean

If true enforces this to be a non-compound type. (compound types are Maps, Structs and Lists/arrays).

Returns:String[]

The DBus type.

Exceptions
DBusException:
If the given type cannot be converted to a DBus type.
getJavaTypeback to summary
public static int getJavaType(String _dbusType, List<Type> _resultValue, int _limit) throws DBusException

Converts a dbus type string into Java Type objects,

Parameters
_dbusType:String

The DBus type or types.

_resultValue:List<Type>

List to return the types in.

_limit:int

Maximum number of types to parse (-1 == nolimit).

Returns:int

number of characters parsed from the type string.

Exceptions
DBusException:
on error
recursiveGetDBusTypeback to summary
private static String[] recursiveGetDBusType(StringBuffer[] _out, Type _dataType, boolean _basic, int _level) throws DBusException
Annotations
@SuppressWarnings:checkstyle:parameterassignment