String name = "Struct"+elements; if (null != structs) structs.put(name, elements);
   public static String getJavaType(String dbus, Set<String> imports, Map<String,Integer> structs, boolean container, boolean fullnames) throws DBusException   {      if (null == dbus || "".equals(dbus)) return "";            try {         switch(dbus.charAt(0)) {            case '(':               int elements = 0;               String types="<";               String s = dbus.substring(1, dbus.length()-1);               for (int i = 0; i < s.length(); i++) {                  switch (s.charAt(i)) {                     case 'a':                        if ('{' == s.charAt(i+1)) {                           int j, c;                           for (j = i+2, c = 1; c > 0; j++)                              if ('{' == s.charAt(j)) c++;                               else if ('}' == s.charAt(j)) c--;                           types += getJavaType(s.substring(i,j+1), imports, structs, true, false) +  ", ";                           i=j;                        } else {                           types += getJavaType(s.substring(i,i+2), imports, structs, true, false) + ", ";                           i++;                        }                        elements++;                        break;                                             case '(':                        int j, c;                        for (j = i+1, c = 1; c > 0; j++)                           if ('(' == s.charAt(j)) c++;                           else if (')' == s.charAt(j)) c--;                        types += getJavaType(s.substring(i,j+1), imports, structs, true, false) +  ", ";                                            elements++;                        i=j;                        break;                     default:                        types += getJavaType(s.substring(i,i+1), imports, structs, true, false) + ", ";                        elements++;                  }               }               String name = "Struct"+elements;               if (null != structs) structs.put(name, elements);               if (fullnames) return "org.freedesktop.dbus.Struct";               else return name + types.replaceAll(", $", ">");            case 'a':               if ('{' == dbus.charAt(1)) {                  if (null != imports) imports.add("java.utils.Map");                  if (fullnames) return "java.util.Map";                  else return "Map<"+getJavaType(dbus.substring(2,3), imports, structs, true, false)+", "+                     getJavaType(dbus.substring(3,dbus.length()-1), imports, structs, true, false)+">";               }               if (null != imports) imports.add("java.utils.List");               if (fullnames) return "java.util.List";               else return "List<"+getJavaType(dbus.substring(1), imports, structs, true, false) + ">";            case 'v':               if (null != imports) imports.add("org.freedesktop.dbus.Variant");               if (fullnames) return "org.freedesktop.dbus.Variant";               else return "Variant";            case 'b':               if (container) {                  if (fullnames) return "java.lang.Boolean";                  else return "Boolean";               }               else return "boolean";            case 'n':               if (container) {                  if (fullnames) return "java.lang.Short";                  else return "Short";               } else return "short";            case 'y':               if (container) {                  if (fullnames) return "java.lang.Byte";                  else return "Byte";               } else return "byte";            case 'o':               if (null != imports) imports.add("org.freedesktop.dbus.DBusInterface");               if (fullnames) return "org.freedesktop.dbus.DBusInterface";               else return "DBusInterface";            case 'q':               if (null != imports) imports.add("org.freedesktop.dbus.UInt16");               if (fullnames) return "org.freedesktop.dbus.UInt16";               else return "UInt16";            case 'i':               if (container) {                  if (fullnames) return "java.lang.Integer";                  else return "Integer";               } else return "int";            case 'u':               if (null != imports) imports.add("org.freedesktop.dbus.UInt32");               if (fullnames) return "org.freedesktop.dbus.UInt32";               else return "UInt32";            case 'x':               if (container) {                  if (fullnames) return "java.lang.Long";                  else return "Long";               } else return "long";            case 't':               if (null != imports) imports.add("org.freedesktop.dbus.UInt64");               if (fullnames) return "org.freedesktop.dbus.UInt64";               else return "UInt64";            case 'd':               if (container) {                  if (fullnames) return "java.lang.Double";                  else return "Double";               } else return "double";            case 's':               if (fullnames) return "java.lang.String";               else return "String";            default:               throw new DBusException("Failed to parse DBus type signature: "+dbus);         }      } catch (IndexOutOfBoundsException IOOBe) {         throw new DBusException("Failed to parse DBus type signature: "+dbus);      }   }