Exemple #1
0
  public void write(OutputStream out) throws IOException {
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out, "UTF8"));

    bw.write("JarIndex-Version: 1.0\n\n");

    if (jarFiles != null) {
      for (String jar : jarFiles) {
        bw.write(jar + "\n");

        LinkedList<String> jarlist = jarMap.get(jar);

        if (jarlist != null) {
          Iterator<String> listitr = jarlist.iterator();

          while (listitr.hasNext()) {
            bw.write(listitr.next() + "\n");
          }
        }

        bw.write("\n");
      }

      bw.flush();
    }
  }
Exemple #2
0
  public static void noNullElements(Collection collection, String message) {
    Validate.notNull(collection);

    for (Iterator it = collection.iterator(); it.hasNext(); ) {
      if (it.next() == null) {
        throw new IllegalArgumentException(message);
      }
    }
  }
Exemple #3
0
  public static void allElementsOfType(Collection collection, Class clazz, String message) {
    Validate.notNull(collection);

    Validate.notNull(clazz);

    for (Iterator it = collection.iterator(); it.hasNext(); ) {
      if (clazz.isInstance(it.next()) == false) {
        throw new IllegalArgumentException(message);
      }
    }
  }
Exemple #4
0
  public static void noNullElements(Collection collection) {
    Validate.notNull(collection);

    int i = 0;

    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      if (it.next() == null) {
        throw new IllegalArgumentException(
            "The validated collection contains null element at index: " + i);
      }
    }
  }
Exemple #5
0
  public static void allElementsOfType(Collection collection, Class clazz) {
    Validate.notNull(collection);

    Validate.notNull(clazz);

    int i = 0;

    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      if (clazz.isInstance(it.next()) == false) {
        throw new IllegalArgumentException(
            "The validated collection contains an element not of type "
                + clazz.getName()
                + " at index: "
                + i);
      }
    }
  }
Exemple #6
0
  public void merge(JarIndex toIndex, String path) {
    Iterator<Map.Entry<String, LinkedList<String>>> itr = indexMap.entrySet().iterator();

    while (itr.hasNext()) {
      Map.Entry<String, LinkedList<String>> e = itr.next();

      String packageName = e.getKey();

      LinkedList<String> from_list = e.getValue();

      Iterator<String> listItr = from_list.iterator();

      while (listItr.hasNext()) {
        String jarName = listItr.next();

        if (path != null) {
          jarName = path.concat(jarName);
        }

        toIndex.addMapping(packageName, jarName);
      }
    }
  }