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
recursive
isfalse
) or recursively unpacked (whenrecursive
istrue
). - A Maybe type is returned as either
null
or 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
null
value is returned as a maybe ("mv"
) GVariant with valuenull
- a
boolean
is returned as aboolean
GVariant - a
byte
is returned as abyte
GVariant - a
char
is returned as a (single-character) string GVariant - an
short
is returned as anint16
GVariant - an
int
is returned as anint32
GVariant - an
long
is returned as anint64
GVariant - a
float
ordouble
is returned as adouble
GVariant - 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
-