Package org.javagi.interop
Class Variants
java.lang.Object
org.javagi.interop.Variants
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Variants
public Variants()
-
-
Method Details
-
unpack
Unpack a GVariant into a Java Object.- A basic primitive type is returned as a Java boxed primitive.
- A string, object path or type signature is returned as a Java String.
- A nested GVariant is returned as a Java Variant (when
recursiveisfalse) or recursively unpacked (whenrecursiveistrue). - A Maybe type is returned as either
nullor the unpacked value. - An array is returned as an
ArrayList<?>with unpacked values. - A dictionary is returned as a
HashMap<?, ?>with unpacked entries. - A tuple is returned as a
ArrayList<Object>with unpacked entries.
- Parameters:
v- a Variant to unpackrecursive- whether to recursively unpack nested GVariants- Returns:
- the unpacked Java Object
-
pack
Create a GVariant from a Java Object.- a
nullvalue is returned as a maybe ("mv") GVariant with valuenull - a
booleanis returned as abooleanGVariant - a
byteis returned as abyteGVariant - a
charis returned as a (single-character) string GVariant - an
shortis returned as anint16GVariant - an
intis returned as anint32GVariant - an
longis returned as anint64GVariant - a
floatordoubleis returned as adoubleGVariant - a Java String is returned as a string GVariant
- a Java List or Set is returned as an array GVariant with recursively packed elements
- a Java Map is returned as a dictionary GVariant with recursively packed entries
- a Java Optional is returned as a maybe (
"m") GVariant with either the packed value ornull(with type"mv")
- Parameters:
o- the Java Object to pack into a GVariant- Returns:
- the GVariant with the packed Object
- a
-