Top Description Inners Fields Constructors Methods
org.freedesktop.dbus.messages

public Class Message

extends Object
Class Inheritance
Known Direct Subclasses
org.freedesktop.dbus.messages.MethodBase, org.freedesktop.dbus.messages.DBusSignal, org.freedesktop.dbus.messages.Error
Static Imports
org.freedesktop.dbus.messages.constants.ArgumentType.*

Superclass of all messages which are sent over the Bus.
This class deals with all the marshalling to/from the wire format.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
pack-priv static interface
Message.ExtractMethod

Interface defining a method to extract a specific data type.

pack-priv static record
Message.ExtractOptions

Additional options to optimize value extraction.

Field Summary

Modifier and TypeField and Description
private Object[]
private boolean
private byte[]
private long
private static final int
BUFFERINCREMENT

Steps to increment the buffer array.

private int
private long
private static final Message.ExtractOptions
DEFAULT_OPTIONS

Default extraction options.

private boolean
private final List<FileDescriptor>
private byte
private static final AtomicLong
private final Object[]
protected final Logger
public static final int
public static final int
public static final int
private static final int
OFFSET_DATA

Position of data offset in int array.

private static final int
OFFSET_SIG

Position of signature offset in int array.

private byte[]
private static byte[][]
padding

Keep a static reference to each size of padding array to prevent allocation.

private int
private int
public static final byte
PROTOCOL

The current protocol major version.

private byte
private long
private byte
private byte[][]

Constructor Summary

AccessConstructor and Description
protected
Message(byte
The endianness to create the message.
_endian
,
byte
The message type.
_type
,
byte
Any message flags.
_flags
)

Create a message; only to be called by sub-classes.

protected
Message()

Create a blank message.

Method Summary

Modifier and TypeMethod and Description
protected int

Returns:

The new, aligned, counter.
align
(int
The current counter.
_current
,
byte
The type to align to.
_type
)

Align a counter to the given type.

protected void
append(String
The signature(s) of the value(s).
_sig
,
Object...
The value(s).
_data
)

Append a series of values to the message.

protected void
appendByte(byte
byte
_b
)

Appends a byte to the buffer list.

protected void
appendBytes(byte[]
buffer byte array
_buf
)

Appends a buffer to the buffer list.

protected void
appendint(long
The integer to marshall.
_l
,
int
The byte-width of the int.
_width
)

Marshalls an integer of a given width and appends it to the message.

private int

Returns:

The offset into the signature of the end of this value's type.
appendOne
(byte[]
A buffer of the D-Bus signature.
_sigb
,
int
The offset into the signature corresponding to this value.
_sigofs
,
Object
The value to marshall.
_data
)

Appends a value to the message.

protected Object[]

Returns:

Object array
createHeaderArgs
(byte
header type (one of HeaderField)
_header
,
String
argument type (one of ArgumentType)
_argType
,
Object
value
_value
)

Creates a message header.

protected long

Returns:

long
demarshallint
(byte[]
The buffer to demarshall from.
_buf
,
int
The offset to demarshall from.
_ofs
,
int
The byte-width of the int.
_width
)

Demarshalls an integer of a given width from a buffer.

public static long

Returns:

long
demarshallint
(byte[]
The buffer to demarshall from.
_buf
,
int
The offset to demarshall from.
_ofs
,
byte
The endianness to use in demarshalling.
_endian
,
int
The byte-width of the int.
_width
)

Demarshalls an integer of a given width from a buffer.

public static long

Returns:

long
demarshallintBig
(byte[]
The buffer to demarshall from.
_buf
,
int
The offset to demarshall from.
_ofs
,
int
The byte-width of the int.
_width
)

Demarshalls an integer of a given width from a buffer using big-endian format.

public static long

Returns:

long
demarshallintLittle
(byte[]
The buffer to demarshall from.
_buf
,
int
The offset to demarshall from.
_ofs
,
int
The byte-width of the int.
_width
)

Demarshalls an integer of a given width from a buffer using little-endian format.

pack-priv String

Returns:

String, maybe empty
dumpWireData
()

Dumps the current content of wiredata to String.

private void
ensureBuffers(int
number of free buffers to create.
_num
)

Ensures there are enough free buffers.

protected Object[]

Returns:

The demarshalled value(s).
extract
(String
The D-Bus signature(s) of the value(s).
_signature
,
byte[]
The buffer to demarshall from.
_dataBuf
,
int
The offset into the data buffer to start.
_offsets
,
Message.ExtractOptions
additional options
_options
)

Demarshall values from a buffer.

protected Object[]

Returns:

The demarshalled value(s).
extract
(String
The D-Bus signature(s) of the value(s).
_signature
,
byte[]
The buffer to demarshall from.
_dataBuf
,
int[]
An array of two ints, which holds the position of the current signature offset and the current offset of the data buffer. These values will be updated to the start of the next value after demarshalling.
_offsets
,
Message.ExtractOptions
additional options
_options
)

Demarshall values from a buffer.

pack-priv Object[]
extract(String _signature, byte[] _dataBuf, int[] _offsets, Message.ExtractOptions _options, Message.ExtractMethod _method)

private Object[]

Returns:

object array
extractArgs
(List<Type[]>
list of desired constructor arguments
_constructorArgs
)

Creates a object array containing all objects which should be used to call a constructor.

private Object

Returns:

Object
extractArray
(byte[]
signature string (as byte array) of the content of the array
_signatureBuf
,
byte[]
buffer containing the array to read
_dataBuf
,
int[]
current offsets in the buffer (will be updated)
_offsets
,
Message.ExtractOptions
additional options
_options
,
Message.ExtractMethod
method to be called for every entry contained in the array
_extractMethod
)

Extracts an array from the data received on bus.

private Object

Returns:

Object
extractByte
(byte[]
buffer holding the byte
_dataBuf
,
int[]
offset position in buffer (will be updated)
_offsets
)

Extracts a byte from the data received on bus.

pack-priv Object[]

Returns:

Object array containing header data
extractHeader
(byte[]
D-Bus serialized data of type a(yv)
_headers
)

Extracts the header information from the given byte array.

private Object

Returns:

The demarshalled value.
extractOne
(byte[]
A buffer of the D-Bus signature.
_signatureBuf
,
byte[]
The buffer to demarshall from.
_dataBuf
,
int[]
An array of two ints, which holds the position of the current signature offset and the current offset of the data buffer.
_offsets
,
Message.ExtractOptions
extract options
_options
)

Demarshall one value from a buffer.

private Object

Returns:

Object
extractStruct
(byte[]
signature (as byte array) defining the struct content
_signatureBuf
,
byte[]
buffer containing the struct
_dataBuf
,
int[]
offset position in buffer (will be updated)
_offsets
,
Message.ExtractOptions
extract options
_options
,
Message.ExtractMethod
method to be called for every entry contained of the struct
_extractMethod
)

Extracts a struct from the data received on bus.

private Object

Returns:

Object / Variant
extractVariant
(byte[]
buffer containing the variant
_dataBuf
,
int[]
current offsets in the buffer (will be updated)
_offsets
,
Message.ExtractOptions
extract options
_options
,
BiFunction<String, Object, Object>
method to create new Variant objects (or other object types)
_variantFactory
)

Extracts a Variant from the data received on bus.

public static int

Returns:

int
getAlignment
(byte
type
_type
)

Return the alignment for a given type.

pack-priv long
protected long
public String

Returns:

string
getDestination
()

Returns the destination of the message.

public byte
public List<FileDescriptor>
public int

Returns:

int
getFlags
()

Returns the message flags.

protected Object[]
protected Object

Returns:

The value of the field or null if unset.
getHeader
(byte
The field to return.
_type
)

Returns the value of the header field of a given field.

public static String

Returns:

string
getHeaderFieldName
(byte
field
_field
)

Returns the name of the given header field.

public String

Returns:

string
getInterface
()

Returns the interface of the message.

public String

Returns:

string
getName
()

Returns the member name or error name this message represents.

public Object[]

Returns:

object array
getParameters
()

Parses and returns the parameters to this message as an Object array.

public Object[]

Returns:

object array
getParameters
(List<Type[]>
list of desired constructor arguments
_constructorArgs
)

Parses and returns the parameters to this message as an Object array.

public String

Returns:

string
getPath
()

Returns the object path of the message.

pack-priv byte
public long

Returns:

The reply serial, or 0 if it is not a reply.
getReplySerial
()

If this is a reply to a message, this returns its serial.

public synchronized long

Returns:

the message serial.
getSerial
()

Returns the message serial ID (unique for this connection)

public String

Returns:

string
getSig
()

Returns the dbus signature of the parameters.

public String

Returns:

string
getSource
()

Returns the Bus ID that sent the message.

public byte

Returns:

byte
getType
()

Type of this message.

public byte[][]
protected void
marshallint(long
The integer to marshall.
_l
,
byte[]
The buffer to marshall to.
_buf
,
int
The offset to marshall to.
_ofs
,
int
The byte-width of the int.
_width
)

Marshalls an integer of a given width into a buffer.

public static void
marshallintBig(long
The integer to marshall.
_l
,
byte[]
The buffer to marshall to.
_buf
,
int
The offset to marshall to.
_ofs
,
int
The byte-width of the int.
_width
)

Marshalls an integer of a given width into a buffer using big-endian format.

public static void
marshallintLittle(long
The integer to marshall.
_l
,
byte[]
The buffer to demarshall to.
_buf
,
int
The offset to demarshall to.
_ofs
,
int
The byte-width of the int.
_width
)

Marshalls an integer of a given width into a buffer using little-endian format.

private Object

Returns:

Object array
optimizePrimitives
(byte[]
signature string (as byte array) containing the type of array
_signatureBuf
,
byte[]
buffer containing the array
_dataBuf
,
int[]
current offset in buffer (will be updated)
_offsets
,
long
size of a byte
_size
,
byte
data offset padding width when reading primitives (except byte)
_algn
,
int
length of the array
_length
,
Message.ExtractOptions
extract options
_options
,
Message.ExtractMethod
method to be called for every entry contained in the array if not primitive array
_extractMethod
)

Will create primitive arrays when an array is read.

protected void
pad(byte
type
_type
)

Pad the message to the proper alignment for the given type.

protected void
padAndMarshall(List<Object> _hargs, long _serial, String _sig, Object... _args)

Adds message padding and marshalling.

pack-priv void
populate(byte[]
D-Bus serialized data of type yyyuu
_msg
,
byte[]
D-Bus serialized data of type a(yv)
_headers
,
byte[]
D-Bus serialized data of the signature defined in headers.
_body
,
List<FileDescriptor> _descriptors)

Create a message from wire-format data.

private void
preallocate(int _num)

Create a buffer of num bytes.

private int
prepareCollection(byte[] _signatureBuf, int[] _offsets, long _size)

private Object

Returns:

Object
readHeaderVariants
(byte[]
DBus signature string as byte array
_signatureBuf
,
byte[]
buffer with header data
_dataBuf
,
int[]
current offsets
_offsets
,
Message.ExtractOptions
additional options
_options
)

Special lightweight version to read the variant objects in DBus message header.

public void
setArgs(Object[] _args)

protected void
setByteCounter(long _bytecounter)

protected void
setHeader(Object[]
header to set
_header
)

Set header content.

protected synchronized void
setSerial(long _serial)

public void
setSource(String
string
_source
)

Warning, do not use this method unless you really know what you are doing.

protected void
setWireData(byte[][] _wiredata)

public String
toString()

Overrides java.lang.Object.toString.

Formats the message in a human-readable format.

public void
updateEndianess(byte _endianess)

pack-priv static List<Message.ConstructorArgType>

Returns:

List of ConstructorArgType
usesPrimitives
(List<Type[]>
list of constructor types to check
_constructorArgs
,
List<Type>
list of desired types
_dataType
)

Compares a list of Type[] with a list of desired types.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait