Exemplo n.º 1
0
 /**
  * Create a Variant.
  *
  * @param o The wrapped value.
  * @param type The explicit type of the value.
  * @throws IllegalArugmentException If you try and wrap Null or an object which cannot be sent
  *     over DBus.
  */
 public Variant(T o, Type type) throws IllegalArgumentException {
   if (null == o) throw new IllegalArgumentException(getString("cannotWrapNullInVariant"));
   this.type = type;
   try {
     String[] ss = Marshalling.getDBusType(type);
     if (ss.length != 1)
       throw new IllegalArgumentException(getString("cannotWrapMultiValuedInVariant") + type);
     this.sig = ss[0];
   } catch (DBusException DBe) {
     if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
     throw new IllegalArgumentException(
         MessageFormat.format(
             getString("cannotWrapUnqualifiedVariant"), new Object[] {type, DBe.getMessage()}));
   }
   this.o = o;
 }
Exemplo n.º 2
0
 /**
  * Create a Variant.
  *
  * @param o The wrapped value.
  * @param sig The explicit type of the value, as a dbus type string.
  * @throws IllegalArugmentException If you try and wrap Null or an object which cannot be sent
  *     over DBus.
  */
 public Variant(T o, String sig) throws IllegalArgumentException {
   if (null == o) throw new IllegalArgumentException(getString("cannotWrapNullInVariant"));
   this.sig = sig;
   try {
     Vector<Type> ts = new Vector<Type>();
     Marshalling.getJavaType(sig, ts, 1);
     if (ts.size() != 1)
       throw new IllegalArgumentException(getString("cannotWrapNoTypesInVariant") + sig);
     this.type = ts.get(0);
   } catch (DBusException DBe) {
     if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
     throw new IllegalArgumentException(
         MessageFormat.format(
             getString("cannotWrapUnqualifiedVariant"), new Object[] {sig, DBe.getMessage()}));
   }
   this.o = o;
 }
Exemplo n.º 3
0
 @SuppressWarnings("unchecked")
 private synchronized void checkReply()
 {
    if (mc.hasReply()) {
       Message m = mc.getReply();
       if (m instanceof Error)
          error = ((Error) m).getException();
       else if (m instanceof MethodReturn) {
          try {
             rval = (ReturnType) RemoteInvocationHandler.convertRV(m.getSig(), m.getParameters(), me, conn);
          } catch (DBusExecutionException DBEe) {
             error = DBEe;
          } catch (DBusException DBe) {
             if (AbstractConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
             error = new DBusExecutionException(DBe.getMessage());
          }
       }
    }
 }