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