java.lang.Object
org.freedesktop.dbus.Marshalling
Contains static methods for marshalling values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String[]private static final Type[]private static final Stringprivate static final intUsed as initial and incremental size of StringBuffer array when resolving DBusTypes recursively.private static final org.slf4j.Loggerprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertJavaClassesToSignature(Class<?>... _javaType) Will return the DBus type corresponding to the given Java type.static Object[]convertParameters(Object[] _parameters, Type[] _types, String[] _customSignatures, AbstractConnectionBase _conn) Recursively converts types for serialization onto DBus.
When _customSignature is not empty or null, it will be used to wrap the given parameters to aVariant
of the type defined in the _customSignature array.
It is required that everyVariantpassed has a signature definition in _customSignature.
E.g.static Object[]convertParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn) Recursively converts types for serialization onto DBus.private static intconvertToSig(StringBuilder _sig, int _idx, Class<?>... _javaType) (package private) static ObjectdeSerializeParameter(Object _parameter, Type _type, AbstractConnectionBase _conn) static Object[]deSerializeParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn) deSerializeParameters(List<Object> _parameters, Type _type, AbstractConnectionBase _conn) static String[]getDBusType(Type _javaType) Will return the DBus type corresponding to the given Java type.static StringgetDBusType(Type[] _javaType) Will return the DBus type corresponding to the given Java type.static String[]getDBusType(Type _dataType, boolean _basic) Will return the DBus type corresponding to the given Java type.static intgetJavaType(String _dbusType, List<Type> _resultValue, int _limit) Converts a dbus type string into Java Type objects,private static String[]recursiveGetDBusType(StringBuffer[] _out, Type _dataType, boolean _basic, int _level)
-
Field Details
-
EMPTY_STRING_ARRAY
-
EMPTY_TYPE_ARRAY
-
INITIAL_BUFFER_SZ
private static final int INITIAL_BUFFER_SZUsed as initial and incremental size of StringBuffer array when resolving DBusTypes recursively.- See Also:
-
MTH_NAME_DESERIALIZE
- See Also:
-
ERROR_MULTI_VALUED_ARRAY
- See Also:
-
LOGGER
private static final org.slf4j.Logger LOGGER -
TYPE_CACHE
-
CLASS_TO_ARGUMENTTYPE
-
-
Constructor Details
-
Marshalling
private Marshalling()
-
-
Method Details
-
getDBusType
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- The Java types.- Returns:
- The DBus types.
- Throws:
DBusException
-
convertJavaClassesToSignature
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- The Java types.- Returns:
- The DBus types
- Throws:
DBusTypeConversationRuntimeException- when conversation fails- Since:
- 5.1.0 - 2024-05-19
-
convertToSig
-
getDBusType
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- The Java type.- Returns:
- The DBus type.
- Throws:
DBusException- If the given type cannot be converted to a DBus type.
-
getDBusType
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- The Java type._basic- If true enforces this to be a non-compound type. (compound types are Maps, Structs and Lists/arrays).- Returns:
- The DBus type.
- Throws:
DBusException- If the given type cannot be converted to a DBus type.
-
recursiveGetDBusType
private static String[] recursiveGetDBusType(StringBuffer[] _out, Type _dataType, boolean _basic, int _level) throws DBusException - Throws:
DBusException
-
getJavaType
public static int getJavaType(String _dbusType, List<Type> _resultValue, int _limit) throws DBusException Converts a dbus type string into Java Type objects,- Parameters:
_dbusType- The DBus type or types._resultValue- List to return the types in._limit- Maximum number of types to parse (-1 == nolimit).- Returns:
- number of characters parsed from the type string.
- Throws:
DBusException- on error
-
convertParameters
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 aVariant
of the type defined in the _customSignature array.
It is required that everyVariantpassed 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 eachVariant.
If the _customSignature is smaller than the count ofVariants in _parameters, all remainingVariants
are created without a explicit signature (Variant constructor will try to determine type automatically).
If more entries are given thenVariants found in _parameters, the additional signatures are ignored.- Parameters:
_parameters- The parameters to convert._types- The (possibly generic) types of the parameters._customSignatures- custom signatures used for variants found in _types, each found variant must have one matching custom signature_conn- the connection- Returns:
- The converted parameters.
- Throws:
DBusException- Thrown if there is an error in converting the objects.
-
convertParameters
public static Object[] convertParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn) throws DBusException Recursively converts types for serialization onto DBus.- Parameters:
_parameters- The parameters to convert._types- The (possibly generic) types of the parameters._conn- the connection- Returns:
- The converted parameters.
- Throws:
DBusException- Thrown if there is an error in converting the objects.
-
deSerializeParameter
static Object deSerializeParameter(Object _parameter, Type _type, AbstractConnectionBase _conn) throws Exception - Throws:
Exception
-
deSerializeParameters
static List<Object> deSerializeParameters(List<Object> _parameters, Type _type, AbstractConnectionBase _conn) throws Exception - Throws:
Exception
-
deSerializeParameters
public static Object[] deSerializeParameters(Object[] _parameters, Type[] _types, AbstractConnectionBase _conn) throws Exception - Throws:
Exception
-