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;
 }