public static String encodeUrl(Parameters parameters) {
    if (parameters == null) {
      return "";
    }

    StringBuilder sb = new StringBuilder();
    boolean first = true;
    int size = parameters.size();
    for (int loc = 0; loc < size; loc++) {
      if (first) {
        first = false;
      } else {
        sb.append("&");
      }
      String _key = parameters.getKey(loc);
      String _value = parameters.getValue(_key);
      if (_value == null) {
        // Log.i("encodeUrl", "key:" + _key + " 's value is null");
      } else {
        // Log.i("encodeUrl", URLEncoder.encode(parameters.getKey(loc))
        // + "=" + URLEncoder.encode(parameters.getValue(loc)));
        sb.append(
            URLEncoder.encode(parameters.getKey(loc))
                + "="
                + URLEncoder.encode(encodeBase64(parameters.getValue(loc).getBytes())));
      }
    }
    return sb.toString();
  }
 public void setParameters(Parameters pList) {
   if (sharedForward) {
     throw new RuntimeException("Please not call setParameters on a shared forward module");
   }
   if (pList.size() != (input_size * output_size)) {
     throw new RuntimeException("pList is not of good dimensions");
   }
   paramList = pList;
   /*for(Parameter p:pList){
   	p.parent.addListener(this);
   }*/
   paramsChanged();
 }
  public CommandData parseCommandData(ArtifactData artifact) throws Exception {
    File source = new File(artifact.file);
    if (!source.isFile()) throw new FileNotFoundException();

    CommandData data = new CommandData();
    data.sha = artifact.sha;
    data.jpmRepoDir = repoDir.getCanonicalPath();
    JarFile jar = new JarFile(source);
    try {
      reporter.trace("Parsing %s", source);
      Manifest m = jar.getManifest();
      Attributes main = m.getMainAttributes();
      data.name = data.bsn = main.getValue("Bundle-SymbolicName");
      String version = main.getValue("Bundle-Version");
      if (version == null) data.version = Version.LOWEST;
      else data.version = new Version(version);

      data.main = main.getValue("Main-Class");
      data.description = main.getValue("Bundle-Description");
      data.title = main.getValue("JPM-Name");

      reporter.trace("name " + data.name + " " + data.main + " " + data.title);
      DependencyCollector path = new DependencyCollector(this);
      path.add(artifact);
      DependencyCollector bundles = new DependencyCollector(this);
      if (main.getValue("JPM-Classpath") != null) {
        Parameters requires = OSGiHeader.parseHeader(main.getValue("JPM-Classpath"));

        for (Map.Entry<String, Attrs> e : requires.entrySet()) {
          path.add(e.getKey(), e.getValue().get("name")); // coordinate
        }
      } else if (!artifact.local) { // No JPM-Classpath, falling back to
        // server's revision
        // Iterable<RevisionRef> closure =
        // library.getClosure(artifact.sha,
        // false);
        // System.out.println("getting closure " + artifact.url + " " +
        // Strings.join("\n",closure));

        // if (closure != null) {
        // for (RevisionRef ref : closure) {
        // path.add(Hex.toHexString(ref.revision));
        // }
        // }
      }

      if (main.getValue("JPM-Runbundles") != null) {
        Parameters jpmrunbundles = OSGiHeader.parseHeader(main.getValue("JPM-Runbundles"));

        for (Map.Entry<String, Attrs> e : jpmrunbundles.entrySet()) {
          bundles.add(e.getKey(), e.getValue().get("name"));
        }
      }

      reporter.trace("collect digests runpath");
      data.dependencies.addAll(path.getDigests());
      reporter.trace("collect digests bundles");
      data.runbundles.addAll(bundles.getDigests());

      Parameters command = OSGiHeader.parseHeader(main.getValue("JPM-Command"));
      if (command.size() > 1) reporter.error("Only one command can be specified");

      for (Map.Entry<String, Attrs> e : command.entrySet()) {
        data.name = e.getKey();

        Attrs attrs = e.getValue();

        if (attrs.containsKey("jvmargs")) data.jvmArgs = attrs.get("jvmargs");

        if (attrs.containsKey("title")) data.title = attrs.get("title");

        if (data.title != null) data.title = data.name;
      }
      return data;
    } finally {
      jar.close();
    }
  }
 private static boolean isBundleEmpty(Parameters bundle) {
   if (bundle == null || bundle.size() == 0) {
     return true;
   }
   return false;
 }