public DBusMatchRule()

in dbus-java/src/main/java/org/freedesktop/dbus/DBusMatchRule.java [91:147]


    public DBusMatchRule(Class<? extends Object> c) throws DBusException {
        if (DBusInterface.class.isAssignableFrom(c)) {
            if (null != c.getAnnotation(DBusInterfaceName.class)) {
                iface = c.getAnnotation(DBusInterfaceName.class).value();
            } else {
                iface = AbstractConnection.DOLLAR_PATTERN.matcher(c.getName()).replaceAll(".");
            }
            if (!iface.matches(".*\\..*")) {
                throw new DBusException("DBusInterfaces must be defined in a package.");
            }
            member = null;
            type = null;
        } else if (DBusSignal.class.isAssignableFrom(c)) {
            if (null == c.getEnclosingClass()) {
                throw new DBusException("Signals must be declared as a member of a class implementing DBusInterface which is the member of a package.");
            } else if (null != c.getEnclosingClass().getAnnotation(DBusInterfaceName.class)) {
                iface = c.getEnclosingClass().getAnnotation(DBusInterfaceName.class).value();
            } else {
                iface = AbstractConnection.DOLLAR_PATTERN.matcher(c.getEnclosingClass().getName()).replaceAll(".");
            }
            // Don't export things which are invalid D-Bus interfaces
            if (!iface.matches(".*\\..*")) {
                throw new DBusException("DBusInterfaces must be defined in a package.");
            }
            if (c.isAnnotationPresent(DBusMemberName.class)) {
                member = c.getAnnotation(DBusMemberName.class).value();
            } else {
                member = c.getSimpleName();
            }
            SIGNALTYPEMAP.put(iface + '$' + member, (Class<? extends DBusSignal>) c);
            type = "signal";
        } else if (Error.class.isAssignableFrom(c)) {
            if (null != c.getAnnotation(DBusInterfaceName.class)) {
                iface = c.getAnnotation(DBusInterfaceName.class).value();
            } else {
                iface = AbstractConnection.DOLLAR_PATTERN.matcher(c.getName()).replaceAll(".");
            }
            if (!iface.matches(".*\\..*")) {
                throw new DBusException("DBusInterfaces must be defined in a package.");
            }
            member = null;
            type = "error";
        } else if (DBusExecutionException.class.isAssignableFrom(c)) {
            if (null != c.getClass().getAnnotation(DBusInterfaceName.class)) {
                iface = c.getClass().getAnnotation(DBusInterfaceName.class).value();
            } else {
                iface = AbstractConnection.DOLLAR_PATTERN.matcher(c.getClass().getName()).replaceAll(".");
            }
            if (!iface.matches(".*\\..*")) {
                throw new DBusException("DBusInterfaces must be defined in a package.");
            }
            member = null;
            type = "error";
        } else {
            throw new DBusException("Invalid type for match rule: " + c);
        }
    }