keycloak-federation
公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 限定公開変数類 | 静的限定公開変数類 | 関数 | 静的関数 | 静的非公開メンバ関数 | 全メンバ一覧
org.freedesktop.dbus.Error クラス
org.freedesktop.dbus.Error の継承関係図
Inheritance graph
org.freedesktop.dbus.Error 連携図
Collaboration graph

公開メンバ関数

 Error (String dest, String errorName, long replyserial, String sig, Object... args) throws DBusException
 
 Error (String source, String dest, String errorName, long replyserial, String sig, Object... args) throws DBusException
 
 Error (String source, Message m, Throwable e) throws DBusException
 
 Error (Message m, Throwable e) throws DBusException
 
DBusExecutionException getException ()
 
void throwException () throws DBusExecutionException
 
long demarshallint (byte[] buf, int ofs, int width)
 
void appendint (long l, int width)
 
void marshallint (long l, byte[] buf, int ofs, int width)
 
byte [][] getWireData ()
 
String toString ()
 
Object getHeader (byte type)
 
void pad (byte type)
 
void append (String sig, Object... data) throws DBusException
 
int align (int current, byte type)
 
Object [] extract (String sig, byte[] buf, int ofs) throws DBusException
 
Object [] extract (String sig, byte[] buf, int[] ofs) throws DBusException
 
String getSource ()
 
String getDestination ()
 
String getInterface ()
 
String getPath ()
 
String getName ()
 
String getSig ()
 
int getFlags ()
 
long getSerial ()
 
long getReplySerial ()
 
Object [] getParameters () throws DBusException
 
void setSource (String source) throws DBusException
 

静的公開メンバ関数

static String getHeaderFieldName (byte field)
 
static long demarshallint (byte[] buf, int ofs, byte endian, int width)
 
static long demarshallintBig (byte[] buf, int ofs, int width)
 
static long demarshallintLittle (byte[] buf, int ofs, int width)
 
static void marshallintBig (long l, byte[] buf, int ofs, int width)
 
static void marshallintLittle (long l, byte[] buf, int ofs, int width)
 
static int getAlignment (byte type)
 

静的公開変数類

static final byte PROTOCOL = 1
 

限定公開メンバ関数

void appendBytes (byte[] buf)
 
void appendByte (byte b)
 
void setArgs (Object[] args)
 

限定公開変数類

byte [][] wiredata
 
long bytecounter
 
Map< Byte, Object > headers
 
long serial
 
byte type
 
byte flags
 
byte protover
 

静的限定公開変数類

static long globalserial = 0
 

関数

 Error ()
 
void populate (byte[] msg, byte[] headers, byte[] body) throws DBusException
 

静的関数

 [static initializer]
 

静的非公開メンバ関数

static Class<? extends DBusExecutionExceptioncreateExceptionClass (String name)
 

詳解

Error messages which can be sent over the bus.

構築子と解体子

◆ Error() [1/5]

org.freedesktop.dbus.Error.Error ( )
inlinepackage
28  {
29  }

◆ Error() [2/5]

org.freedesktop.dbus.Error.Error ( String  dest,
String  errorName,
long  replyserial,
String  sig,
Object...  args 
) throws DBusException
inline
31  {
32  this(null, dest, errorName, replyserial, sig, args);
33  }
Object [] args
Definition: Message.java:164

◆ Error() [3/5]

org.freedesktop.dbus.Error.Error ( String  source,
String  dest,
String  errorName,
long  replyserial,
String  sig,
Object...  args 
) throws DBusException
inline
35  {
36  super(Message.Endian.BIG, Message.MessageType.ERROR, (byte) 0);
37 
38  if (null == errorName)
39  throw new MessageFormatException(getString("missingErrorName"));
40  headers.put(Message.HeaderField.REPLY_SERIAL, replyserial);
41  headers.put(Message.HeaderField.ERROR_NAME, errorName);
42 
43  Vector<Object> hargs = new Vector<Object>();
44  hargs.add(new Object[]{Message.HeaderField.ERROR_NAME, new Object[]{ArgumentType.STRING_STRING, errorName}});
45  hargs.add(new Object[]{Message.HeaderField.REPLY_SERIAL, new Object[]{ArgumentType.UINT32_STRING, replyserial}});
46 
47  if (null != source) {
48  headers.put(Message.HeaderField.SENDER, source);
49  hargs.add(new Object[]{Message.HeaderField.SENDER, new Object[]{ArgumentType.STRING_STRING, source}});
50  }
51 
52  if (null != dest) {
53  headers.put(Message.HeaderField.DESTINATION, dest);
54  hargs.add(new Object[]{Message.HeaderField.DESTINATION, new Object[]{ArgumentType.STRING_STRING, dest}});
55  }
56 
57  if (null != sig) {
58  hargs.add(new Object[]{Message.HeaderField.SIGNATURE, new Object[]{ArgumentType.SIGNATURE_STRING, sig}});
59  headers.put(Message.HeaderField.SIGNATURE, sig);
60  setArgs(args);
61  }
62 
63  byte[] blen = new byte[4];
64  appendBytes(blen);
65  append("ua(yv)", serial, hargs.toArray());
66  pad((byte) 8);
67 
68  long c = bytecounter;
69  if (null != sig) append(sig, args);
70  marshallint(bytecounter - c, blen, 0, 4);
71  }
void appendBytes(byte[] buf)
Definition: Message.java:289
Message()
Definition: Message.java:223
Map< Byte, Object > headers
Definition: Message.java:158
Object [] args
Definition: Message.java:164
void pad(byte type)
Definition: Message.java:764
void setArgs(Object[] args)
Definition: Message.java:1188
long bytecounter
Definition: Message.java:157
void append(String sig, Object... data)
Definition: Message.java:823
long serial
Definition: Message.java:160
void marshallint(long l, byte[] buf, int ofs, int width)
Definition: Message.java:406

◆ Error() [4/5]

org.freedesktop.dbus.Error.Error ( String  source,
Message  m,
Throwable  e 
) throws DBusException
inline
73  {
74  this(source, m.getSource(), AbstractConnection.dollar_pattern.matcher(e.getClass().getName()).replaceAll("."), m.getSerial(), "s", e.getMessage());
75  }

◆ Error() [5/5]

org.freedesktop.dbus.Error.Error ( Message  m,
Throwable  e 
) throws DBusException
inline
77  {
78  this(m.getSource(), AbstractConnection.dollar_pattern.matcher(e.getClass().getName()).replaceAll("."), m.getSerial(), "s", e.getMessage());
79  }

関数詳解

◆ [static initializer]()

org.freedesktop.dbus.Message.[static initializer] ( )
inlinestaticpackageinherited

◆ align()

int org.freedesktop.dbus.Message.align ( int  current,
byte  type 
)
inlineinherited

Align a counter to the given type.

引数
currentThe current counter.
typeThe type to align to.
戻り値
The new, aligned, counter.
840  {
841  if (Debug.debug) Debug.print(Debug.VERBOSE, "aligning to " + (char) type);
842  int a = getAlignment(type);
843  if (0 == (current % a)) return current;
844  return current + (a - (current % a));
845  }
byte type
Definition: Message.java:161
static int getAlignment(byte type)
Definition: Message.java:782

◆ append()

void org.freedesktop.dbus.Message.append ( String  sig,
Object...  data 
) throws DBusException
inlineinherited

Append a series of values to the message.

引数
sigThe signature(s) of the value(s).
dataThe value(s).
823  {
824  if (Debug.debug) Debug.print(Debug.DEBUG, "Appending sig: " + sig + " data: " + Arrays.deepToString(data));
825  byte[] sigb = sig.getBytes();
826  int j = 0;
827  for (int i = 0; i < sigb.length; i++) {
828  if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending item: " + i + " " + ((char) sigb[i]) + " " + j);
829  i = appendone(sigb, i, data[j++]);
830  }
831  }
int appendone(byte[] sigb, int sigofs, Object data)
Definition: Message.java:535

◆ appendByte()

void org.freedesktop.dbus.Message.appendByte ( byte  b)
inlineprotectedinherited

Appends a byte to the buffer list.

312  {
313  if (preallocated > 0) {
314  pabuf[paofs++] = b;
315  preallocated--;
316  } else {
317  if (bufferuse == wiredata.length) {
318  if (Debug.debug) Debug.print(Debug.VERBOSE, "Resizing " + bufferuse);
319  byte[][] temp = new byte[wiredata.length + BUFFERINCREMENT][];
320  System.arraycopy(wiredata, 0, temp, 0, wiredata.length);
321  wiredata = temp;
322  }
323  wiredata[bufferuse++] = new byte[]{b};
324  bytecounter++;
325  }
326  }
byte [][] wiredata
Definition: Message.java:156
int bufferuse
Definition: Message.java:170
int preallocated
Definition: Message.java:167
int paofs
Definition: Message.java:168
static final int BUFFERINCREMENT
Definition: Message.java:153
byte [] pabuf
Definition: Message.java:169
long bytecounter
Definition: Message.java:157

◆ appendBytes()

void org.freedesktop.dbus.Message.appendBytes ( byte []  buf)
inlineprotectedinherited

Appends a buffer to the buffer list.

289  {
290  if (null == buf) return;
291  if (preallocated > 0) {
292  if (paofs + buf.length > pabuf.length)
293  throw new ArrayIndexOutOfBoundsException(MessageFormat.format(getString("arrayOutOfBounds"), new Object[]{paofs, pabuf.length, buf.length}));
294  System.arraycopy(buf, 0, pabuf, paofs, buf.length);
295  paofs += buf.length;
296  preallocated -= buf.length;
297  } else {
298  if (bufferuse == wiredata.length) {
299  if (Debug.debug) Debug.print(Debug.VERBOSE, "Resizing " + bufferuse);
300  byte[][] temp = new byte[wiredata.length + BUFFERINCREMENT][];
301  System.arraycopy(wiredata, 0, temp, 0, wiredata.length);
302  wiredata = temp;
303  }
304  wiredata[bufferuse++] = buf;
305  bytecounter += buf.length;
306  }
307  }
byte [][] wiredata
Definition: Message.java:156
int bufferuse
Definition: Message.java:170
int preallocated
Definition: Message.java:167
int paofs
Definition: Message.java:168
static final int BUFFERINCREMENT
Definition: Message.java:153
byte [] pabuf
Definition: Message.java:169
long bytecounter
Definition: Message.java:157

◆ appendint()

void org.freedesktop.dbus.Message.appendint ( long  l,
int  width 
)
inlineinherited

Marshalls an integer of a given width and appends it to the message. Endianness is determined from the message.

引数
lThe integer to marshall.
widthThe byte-width of the int.
391  {
392  byte[] buf = new byte[width];
393  marshallint(l, buf, 0, width);
394  appendBytes(buf);
395  }
void appendBytes(byte[] buf)
Definition: Message.java:289
void marshallint(long l, byte[] buf, int ofs, int width)
Definition: Message.java:406

◆ createExceptionClass()

static Class<? extends DBusExecutionException> org.freedesktop.dbus.Error.createExceptionClass ( String  name)
inlinestaticprivate
82  {
83  if (name == "org.freedesktop.DBus.Local.disconnected") return NotConnected.class;
84  Class<? extends DBusExecutionException> c = null;
85  do {
86  try {
87  c = (Class<? extends org.freedesktop.dbus.exceptions.DBusExecutionException>) Class.forName(name);
88  } catch (ClassNotFoundException CNFe) {
89  }
90  name = name.replaceAll("\\.([^\\.]*)$", "\\$$1");
91  } while (null == c && name.matches(".*\\..*"));
92  return c;
93  }
Definition: DBusExecutionException.java:17
Definition: AbstractConnection.java:11
Definition: DBusException.java:11

◆ demarshallint() [1/2]

long org.freedesktop.dbus.Message.demarshallint ( byte []  buf,
int  ofs,
int  width 
)
inlineinherited

Demarshalls an integer of a given width from a buffer. Endianness is determined from the format of the message.

引数
bufThe buffer to demarshall from.
ofsThe offset to demarshall from.
widthThe byte-width of the int.
336  {
337  return big ? demarshallintBig(buf, ofs, width) : demarshallintLittle(buf, ofs, width);
338  }
static long demarshallintBig(byte[] buf, int ofs, int width)
Definition: Message.java:359
static long demarshallintLittle(byte[] buf, int ofs, int width)
Definition: Message.java:375
boolean big
Definition: Message.java:155

◆ demarshallint() [2/2]

static long org.freedesktop.dbus.Message.demarshallint ( byte []  buf,
int  ofs,
byte  endian,
int  width 
)
inlinestaticinherited

Demarshalls an integer of a given width from a buffer.

引数
bufThe buffer to demarshall from.
ofsThe offset to demarshall from.
endianThe endianness to use in demarshalling.
widthThe byte-width of the int.
348  {
349  return endian == Endian.BIG ? demarshallintBig(buf, ofs, width) : demarshallintLittle(buf, ofs, width);
350  }
static long demarshallintBig(byte[] buf, int ofs, int width)
Definition: Message.java:359
static long demarshallintLittle(byte[] buf, int ofs, int width)
Definition: Message.java:375

◆ demarshallintBig()

static long org.freedesktop.dbus.Message.demarshallintBig ( byte []  buf,
int  ofs,
int  width 
)
inlinestaticinherited

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

引数
bufThe buffer to demarshall from.
ofsThe offset to demarshall from.
widthThe byte-width of the int.
359  {
360  long l = 0;
361  for (int i = 0; i < width; i++) {
362  l <<= 8;
363  l |= (buf[ofs + i] & 0xFF);
364  }
365  return l;
366  }

◆ demarshallintLittle()

static long org.freedesktop.dbus.Message.demarshallintLittle ( byte []  buf,
int  ofs,
int  width 
)
inlinestaticinherited

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

引数
bufThe buffer to demarshall from.
ofsThe offset to demarshall from.
widthThe byte-width of the int.
375  {
376  long l = 0;
377  for (int i = (width - 1); i >= 0; i--) {
378  l <<= 8;
379  l |= (buf[ofs + i] & 0xFF);
380  }
381  return l;
382  }

◆ extract() [1/2]

Object [] org.freedesktop.dbus.Message.extract ( String  sig,
byte []  buf,
int  ofs 
) throws DBusException
inlineinherited

Demarshall values from a buffer.

引数
sigThe D-Bus signature(s) of the value(s).
bufThe buffer to demarshall from.
ofsThe offset into the data buffer to start.
戻り値
The demarshalled value(s).
1076  {
1077  return extract(sig, buf, new int[]{0, ofs});
1078  }
Object [] extract(String sig, byte[] buf, int ofs)
Definition: Message.java:1076

◆ extract() [2/2]

Object [] org.freedesktop.dbus.Message.extract ( String  sig,
byte []  buf,
int []  ofs 
) throws DBusException
inlineinherited

Demarshall values from a buffer.

引数
sigThe D-Bus signature(s) of the value(s).
bufThe buffer to demarshall from.
ofsAn array of two ints, the offset into the signature and the offset into the data buffer. These values will be updated to the start of the next value ofter demarshalling.
戻り値
The demarshalled value(s).
1090  {
1091  if (Debug.debug)
1092  Debug.print(Debug.VERBOSE, "extract(" + sig + ",#" + buf.length + ", {" + ofs[0] + "," + ofs[1] + "}");
1093  Vector<Object> rv = new Vector<Object>();
1094  byte[] sigb = sig.getBytes();
1095  for (int[] i = ofs; i[0] < sigb.length; i[0]++) {
1096  rv.add(extractone(sigb, buf, i, false));
1097  }
1098  return rv.toArray();
1099  }
Object extractone(byte[] sigb, byte[] buf, int[] ofs, boolean contained)
Definition: Message.java:858

◆ getAlignment()

static int org.freedesktop.dbus.Message.getAlignment ( byte  type)
inlinestaticinherited

Return the alignment for a given type.

782  {
783  switch (type) {
784  case 2:
785  case ArgumentType.INT16:
786  case ArgumentType.UINT16:
787  return 2;
788  case 4:
789  case ArgumentType.BOOLEAN:
790  case ArgumentType.FLOAT:
791  case ArgumentType.INT32:
792  case ArgumentType.UINT32:
793  case ArgumentType.STRING:
794  case ArgumentType.OBJECT_PATH:
795  case ArgumentType.ARRAY:
796  return 4;
797  case 8:
798  case ArgumentType.INT64:
799  case ArgumentType.UINT64:
800  case ArgumentType.DOUBLE:
801  case ArgumentType.STRUCT:
802  case ArgumentType.DICT_ENTRY:
803  case ArgumentType.STRUCT1:
804  case ArgumentType.DICT_ENTRY1:
805  case ArgumentType.STRUCT2:
806  case ArgumentType.DICT_ENTRY2:
807  return 8;
808  case 1:
809  case ArgumentType.BYTE:
810  case ArgumentType.SIGNATURE:
811  case ArgumentType.VARIANT:
812  default:
813  return 1;
814  }
815  }
byte type
Definition: Message.java:161

◆ getDestination()

String org.freedesktop.dbus.Message.getDestination ( )
inlineinherited

Returns the destination of the message.

1111  {
1112  return (String) headers.get(HeaderField.DESTINATION);
1113  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getException()

DBusExecutionException org.freedesktop.dbus.Error.getException ( )
inline

Turns this into an exception of the correct type

98  {
99  try {
100  Class<? extends DBusExecutionException> c = createExceptionClass(getName());
101  if (null == c || !DBusExecutionException.class.isAssignableFrom(c)) c = DBusExecutionException.class;
102  Constructor<? extends DBusExecutionException> con = c.getConstructor(String.class);
103  DBusExecutionException ex;
104  Object[] args = getParameters();
105  if (null == args || 0 == args.length)
106  ex = con.newInstance("");
107  else {
108  String s = "";
109  for (Object o : args)
110  s += o + " ";
111  ex = con.newInstance(s.trim());
112  }
113  ex.setType(getName());
114  return ex;
115  } catch (Exception e) {
116  if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
117  if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug && null != e.getCause())
118  Debug.print(Debug.ERR, e.getCause());
119  DBusExecutionException ex;
120  Object[] args = null;
121  try {
122  args = getParameters();
123  } catch (Exception ee) {
124  }
125  if (null == args || 0 == args.length)
126  ex = new DBusExecutionException("");
127  else {
128  String s = "";
129  for (Object o : args)
130  s += o + " ";
131  ex = new DBusExecutionException(s.trim());
132  }
133  ex.setType(getName());
134  return ex;
135  }
136  }
String getName()
Definition: Message.java:1134
static Class<? extends DBusExecutionException > createExceptionClass(String name)
Definition: Error.java:82
Object [] args
Definition: Message.java:164
Object [] getParameters()
Definition: Message.java:1178

◆ getFlags()

int org.freedesktop.dbus.Message.getFlags ( )
inlineinherited

Returns the message flags.

1151  {
1152  return flags;
1153  }
byte flags
Definition: Message.java:162

◆ getHeader()

Object org.freedesktop.dbus.Message.getHeader ( byte  type)
inlineinherited

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

引数
typeThe field to return.
戻り値
The value of the field or null if unset.
520  {
521  return headers.get(type);
522  }
byte type
Definition: Message.java:161
Map< Byte, Object > headers
Definition: Message.java:158

◆ getHeaderFieldName()

static String org.freedesktop.dbus.Message.getHeaderFieldName ( byte  field)
inlinestaticinherited

Returns the name of the given header field.

175  {
176  switch (field) {
177  case HeaderField.PATH:
178  return "Path";
179  case HeaderField.INTERFACE:
180  return "Interface";
181  case HeaderField.MEMBER:
182  return "Member";
183  case HeaderField.ERROR_NAME:
184  return "Error Name";
185  case HeaderField.REPLY_SERIAL:
186  return "Reply Serial";
187  case HeaderField.DESTINATION:
188  return "Destination";
189  case HeaderField.SENDER:
190  return "Sender";
191  case HeaderField.SIGNATURE:
192  return "Signature";
193  default:
194  return "Invalid";
195  }
196  }

◆ getInterface()

String org.freedesktop.dbus.Message.getInterface ( )
inlineinherited

Returns the interface of the message.

1118  {
1119  return (String) headers.get(HeaderField.INTERFACE);
1120  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getName()

String org.freedesktop.dbus.Message.getName ( )
inlineinherited

Returns the member name or error name this message represents.

1134  {
1135  if (this instanceof Error)
1136  return (String) headers.get(HeaderField.ERROR_NAME);
1137  else
1138  return (String) headers.get(HeaderField.MEMBER);
1139  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getParameters()

Object [] org.freedesktop.dbus.Message.getParameters ( ) throws DBusException
inlineinherited

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

1178  {
1179  if (null == args && null != body) {
1180  String sig = (String) headers.get(HeaderField.SIGNATURE);
1181  if (null != sig && 0 != body.length) {
1182  args = extract(sig, body, 0);
1183  } else args = new Object[0];
1184  }
1185  return args;
1186  }
Object [] extract(String sig, byte[] buf, int ofs)
Definition: Message.java:1076
Map< Byte, Object > headers
Definition: Message.java:158
byte [] body
Definition: Message.java:165
Object [] args
Definition: Message.java:164

◆ getPath()

String org.freedesktop.dbus.Message.getPath ( )
inlineinherited

Returns the object path of the message.

1125  {
1126  Object o = headers.get(HeaderField.PATH);
1127  if (null == o) return null;
1128  return o.toString();
1129  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getReplySerial()

long org.freedesktop.dbus.Message.getReplySerial ( )
inlineinherited

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

戻り値
The reply serial, or 0 if it is not a reply.
1169  {
1170  Number l = (Number) headers.get(HeaderField.REPLY_SERIAL);
1171  if (null == l) return 0;
1172  return l.longValue();
1173  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getSerial()

long org.freedesktop.dbus.Message.getSerial ( )
inlineinherited

Returns the message serial ID (unique for this connection)

戻り値
the message serial.
1160  {
1161  return serial;
1162  }
long serial
Definition: Message.java:160

◆ getSig()

String org.freedesktop.dbus.Message.getSig ( )
inlineinherited

Returns the dbus signature of the parameters.

1144  {
1145  return (String) headers.get(HeaderField.SIGNATURE);
1146  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getSource()

String org.freedesktop.dbus.Message.getSource ( )
inlineinherited

Returns the Bus ID that sent the message.

1104  {
1105  return (String) headers.get(HeaderField.SENDER);
1106  }
Map< Byte, Object > headers
Definition: Message.java:158

◆ getWireData()

byte [][] org.freedesktop.dbus.Message.getWireData ( )
inlineinherited
442  {
443  return wiredata;
444  }
byte [][] wiredata
Definition: Message.java:156

◆ marshallint()

void org.freedesktop.dbus.Message.marshallint ( long  l,
byte []  buf,
int  ofs,
int  width 
)
inlineinherited

Marshalls an integer of a given width into a buffer. Endianness is determined from the message.

引数
lThe integer to marshall.
bufThe buffer to marshall to.
ofsThe offset to marshall to.
widthThe byte-width of the int.
406  {
407  if (big) marshallintBig(l, buf, ofs, width);
408  else marshallintLittle(l, buf, ofs, width);
409  if (Debug.debug) Debug.print(Debug.VERBOSE, "Marshalled int " + l + " to " + Hexdump.toHex(buf, ofs, width));
410  }
static void marshallintLittle(long l, byte[] buf, int ofs, int width)
Definition: Message.java:435
static void marshallintBig(long l, byte[] buf, int ofs, int width)
Definition: Message.java:420
boolean big
Definition: Message.java:155

◆ marshallintBig()

static void org.freedesktop.dbus.Message.marshallintBig ( long  l,
byte []  buf,
int  ofs,
int  width 
)
inlinestaticinherited

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

引数
lThe integer to marshall.
bufThe buffer to marshall to.
ofsThe offset to marshall to.
widthThe byte-width of the int.
420  {
421  for (int i = (width - 1); i >= 0; i--) {
422  buf[i + ofs] = (byte) (l & 0xFF);
423  l >>= 8;
424  }
425  }

◆ marshallintLittle()

static void org.freedesktop.dbus.Message.marshallintLittle ( long  l,
byte []  buf,
int  ofs,
int  width 
)
inlinestaticinherited

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

引数
lThe integer to marshall.
bufThe buffer to demarshall to.
ofsThe offset to demarshall to.
widthThe byte-width of the int.
435  {
436  for (int i = 0; i < width; i++) {
437  buf[i + ofs] = (byte) (l & 0xFF);
438  l >>= 8;
439  }
440  }

◆ pad()

void org.freedesktop.dbus.Message.pad ( byte  type)
inlineinherited

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

764  {
765  if (Debug.debug) Debug.print(Debug.VERBOSE, "padding for " + (char) type);
766  int a = getAlignment(type);
767  if (Debug.debug) Debug.print(Debug.VERBOSE, preallocated + " " + paofs + " " + bytecounter + " " + a);
768  int b = (int) ((bytecounter - preallocated) % a);
769  if (0 == b) return;
770  a = (a - b);
771  if (preallocated > 0) {
772  paofs += a;
773  preallocated -= a;
774  } else
775  appendBytes(padding[a]);
776  if (Debug.debug) Debug.print(Debug.VERBOSE, preallocated + " " + paofs + " " + bytecounter + " " + a);
777  }
void appendBytes(byte[] buf)
Definition: Message.java:289
byte type
Definition: Message.java:161
int preallocated
Definition: Message.java:167
int paofs
Definition: Message.java:168
static byte [][] padding
Definition: Message.java:136
long bytecounter
Definition: Message.java:157
static int getAlignment(byte type)
Definition: Message.java:782

◆ populate()

void org.freedesktop.dbus.Message.populate ( byte []  msg,
byte []  headers,
byte []  body 
) throws DBusException
inlinepackageinherited

Create a message from wire-format data.

引数
msgD-Bus serialized data of type yyyuu
headersD-Bus serialized data of type a(yv)
bodyD-Bus serialized data of the signature defined in headers.
237  {
238  big = (msg[0] == Endian.BIG);
239  type = msg[1];
240  flags = msg[2];
241  protover = msg[3];
242  wiredata[0] = msg;
243  wiredata[1] = headers;
244  wiredata[2] = body;
245  this.body = body;
246  bufferuse = 3;
247  bodylen = ((Number) extract(Message.ArgumentType.UINT32_STRING, msg, 4)[0]).longValue();
248  serial = ((Number) extract(Message.ArgumentType.UINT32_STRING, msg, 8)[0]).longValue();
249  bytecounter = msg.length + headers.length + body.length;
250  if (Debug.debug) Debug.print(Debug.VERBOSE, headers);
251  Object[] hs = extract("a(yv)", headers, 0);
252  if (Debug.debug) Debug.print(Debug.VERBOSE, Arrays.deepToString(hs));
253  for (Object o : (Vector<Object>) hs[0]) {
254  this.headers.put((Byte) ((Object[]) o)[0], ((Variant<Object>) ((Object[]) o)[1]).getValue());
255  }
256  }
Object [] extract(String sig, byte[] buf, int ofs)
Definition: Message.java:1076
byte type
Definition: Message.java:161
byte [][] wiredata
Definition: Message.java:156
int bufferuse
Definition: Message.java:170
long bodylen
Definition: Message.java:166
Message()
Definition: Message.java:223
byte flags
Definition: Message.java:162
Map< Byte, Object > headers
Definition: Message.java:158
byte [] body
Definition: Message.java:165
byte protover
Definition: Message.java:163
boolean big
Definition: Message.java:155
long bytecounter
Definition: Message.java:157
long serial
Definition: Message.java:160

◆ setArgs()

void org.freedesktop.dbus.Message.setArgs ( Object []  args)
inlineprotectedinherited
1188  {
1189  this.args = args;
1190  }
Object [] args
Definition: Message.java:164

◆ setSource()

void org.freedesktop.dbus.Message.setSource ( String  source) throws DBusException
inlineinherited

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

1195  {
1196  if (null != body) {
1197  wiredata = new byte[BUFFERINCREMENT][];
1198  bufferuse = 0;
1199  bytecounter = 0;
1200  preallocate(12);
1201  append("yyyyuu", big ? Endian.BIG : Endian.LITTLE, type, flags, protover, bodylen, serial);
1202  headers.put(HeaderField.SENDER, source);
1203  Object[][] newhead = new Object[headers.size()][];
1204  int i = 0;
1205  for (Byte b : headers.keySet()) {
1206  newhead[i] = new Object[2];
1207  newhead[i][0] = b;
1208  newhead[i][1] = headers.get(b);
1209  i++;
1210  }
1211  append("a(yv)", (Object) newhead);
1212  pad((byte) 8);
1213  appendBytes(body);
1214  }
1215  }
void appendBytes(byte[] buf)
Definition: Message.java:289
byte type
Definition: Message.java:161
byte [][] wiredata
Definition: Message.java:156
int bufferuse
Definition: Message.java:170
long bodylen
Definition: Message.java:166
void preallocate(int num)
Definition: Message.java:262
byte flags
Definition: Message.java:162
Map< Byte, Object > headers
Definition: Message.java:158
byte [] body
Definition: Message.java:165
byte protover
Definition: Message.java:163
boolean big
Definition: Message.java:155
static final int BUFFERINCREMENT
Definition: Message.java:153
void pad(byte type)
Definition: Message.java:764
long bytecounter
Definition: Message.java:157
void append(String sig, Object... data)
Definition: Message.java:823
long serial
Definition: Message.java:160

◆ throwException()

void org.freedesktop.dbus.Error.throwException ( ) throws DBusExecutionException
inline

Throw this as an exception of the correct type

141  {
142  throw getException();
143  }
DBusExecutionException getException()
Definition: Error.java:98

◆ toString()

String org.freedesktop.dbus.Message.toString ( )
inlineinherited

Formats the message in a human-readable format.

449  {
450  StringBuffer sb = new StringBuffer();
451  sb.append(getClass().getSimpleName());
452  sb.append('(');
453  sb.append(flags);
454  sb.append(',');
455  sb.append(serial);
456  sb.append(')');
457  sb.append(' ');
458  sb.append('{');
459  sb.append(' ');
460  if (headers.size() == 0)
461  sb.append('}');
462  else {
463  for (Byte field : headers.keySet()) {
464  sb.append(getHeaderFieldName(field));
465  sb.append('=');
466  sb.append('>');
467  sb.append(headers.get(field).toString());
468  sb.append(',');
469  sb.append(' ');
470  }
471  sb.setCharAt(sb.length() - 2, ' ');
472  sb.setCharAt(sb.length() - 1, '}');
473  }
474  sb.append(' ');
475  sb.append('{');
476  sb.append(' ');
477  Object[] args = null;
478  try {
479  args = getParameters();
480  } catch (DBusException DBe) {
481  if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
482  }
483  if (null == args || 0 == args.length)
484  sb.append('}');
485  else {
486  for (Object o : args) {
487  if (o instanceof Object[])
488  sb.append(Arrays.deepToString((Object[]) o));
489  else if (o instanceof byte[])
490  sb.append(Arrays.toString((byte[]) o));
491  else if (o instanceof int[])
492  sb.append(Arrays.toString((int[]) o));
493  else if (o instanceof short[])
494  sb.append(Arrays.toString((short[]) o));
495  else if (o instanceof long[])
496  sb.append(Arrays.toString((long[]) o));
497  else if (o instanceof boolean[])
498  sb.append(Arrays.toString((boolean[]) o));
499  else if (o instanceof double[])
500  sb.append(Arrays.toString((double[]) o));
501  else if (o instanceof float[])
502  sb.append(Arrays.toString((float[]) o));
503  else
504  sb.append(o.toString());
505  sb.append(',');
506  sb.append(' ');
507  }
508  sb.setCharAt(sb.length() - 2, ' ');
509  sb.setCharAt(sb.length() - 1, '}');
510  }
511  return sb.toString();
512  }
static String getHeaderFieldName(byte field)
Definition: Message.java:175
byte flags
Definition: Message.java:162
Map< Byte, Object > headers
Definition: Message.java:158
Object [] args
Definition: Message.java:164
Object [] getParameters()
Definition: Message.java:1178
long serial
Definition: Message.java:160

メンバ詳解

◆ bytecounter

long org.freedesktop.dbus.Message.bytecounter
protectedinherited

◆ flags

byte org.freedesktop.dbus.Message.flags
protectedinherited

◆ globalserial

long org.freedesktop.dbus.Message.globalserial = 0
staticprotectedinherited

◆ headers

Map<Byte, Object> org.freedesktop.dbus.Message.headers
protectedinherited

◆ PROTOCOL

final byte org.freedesktop.dbus.Message.PROTOCOL = 1
staticinherited

The current protocol major version.

◆ protover

byte org.freedesktop.dbus.Message.protover
protectedinherited

◆ serial

long org.freedesktop.dbus.Message.serial
protectedinherited

◆ type

byte org.freedesktop.dbus.Message.type
protectedinherited

◆ wiredata

byte [][] org.freedesktop.dbus.Message.wiredata
protectedinherited

このクラス詳解は次のファイルから抽出されました: