public static HashMap<String, double[]> getTagsHistogramMap(
      String[] allTags, double[][] mTagAverageHistogram) {

    HashMap<String, double[]> tagsHistogramMap = Create.hashMap();

    for (int i = 0; i < allTags.length; i++) {
      /** * HashMap for <tag, tag histogram>** */
      tagsHistogramMap.put(allTags[i], mTagAverageHistogram[i]);
    }

    return tagsHistogramMap;
  }
  public static HashMap<String, Map<Integer, Double>> getTagsDescriptorMap(
      String[] allTags, Vector<Map<Integer, Double>> mTagAverageDescriptor) {

    HashMap<String, Map<Integer, Double>> tagsDescriptorMap = Create.hashMap();

    for (int i = 0; i < allTags.length; i++) {
      /** * HashMap for <tag, tag descriptor map>** */
      tagsDescriptorMap.put(allTags[i], mTagAverageDescriptor.elementAt(i));
    }

    return tagsDescriptorMap;
  }
  public static Vector<Map<Integer, Double>> getTagsDescriptor(double[][] mTagAverageHistogram) {

    Vector<Map<Integer, Double>> tmpVec = new Vector<Map<Integer, Double>>();

    for (int i = 0; i < mTagAverageHistogram.length; i++) {
      Map<Integer, Double> des = Create.linkedHashMap();
      for (int j = 0; j < BIN_HISTO; j++) {
        if (mTagAverageHistogram[i][j] > 0.0) {
          // System.out.print(mTagAverageHistogram[i][j] + " ");
          des.put(j, mTagAverageHistogram[i][j]);
        }
      }
      // System.out.println();
      tmpVec.add(des);
    }
    return tmpVec;
  }
Ejemplo n.º 4
0
  public static void testNaming() throws Exception {
    Map<String, Object> map = Create.map();

    map.put("_secret", "_secret");
    map.put("_secret", "_secret");
    map.put(".secret", ".secret");
    map.put("$new", "$new");
    map.put("new", "new");
    map.put("secret", "secret");
    map.put("a_b_c", "a_b_c");
    map.put("a.b.c", "a.b.c");
    map.put(".a_b", ".a_b");
    map.put("$$$$a_b", "$$$$a_b");
    map.put("$$$$a.b", "$$$$a.b");
    map.put("a", "a");
    map.put("a$", "a$");
    map.put("a$$", "a$$");
    map.put("a$.$", "a$.$");
    map.put("a$_$", "a$_$");
    map.put("a..", "a..");
    map.put("noid", "noid");
    map.put("nullid", "nullid");

    Naming trt = Configurable.createConfigurable(Naming.class, map);

    // By name
    assertEquals("secret", trt.secret());
    assertEquals("_secret", trt.__secret());
    assertEquals(".secret", trt._secret());
    assertEquals("new", trt.$new());
    assertEquals("$new", trt.$$new());
    assertEquals("a.b.c", trt.a_b_c());
    assertEquals("a_b_c", trt.a__b__c());
    assertEquals(".a_b", trt._a__b());
    assertEquals("$$$$a.b", trt.$$$$$$$$a_b());
    assertEquals("$$$$a_b", trt.$$$$$$$$a__b());
    assertEquals("a", trt.a$());
    assertEquals("a$", trt.a$$());
    assertEquals("a$", trt.a$$$());
    assertEquals("a$.$", trt.a$$_$$());
    assertEquals("a$_$", trt.a$$__$$());
    assertEquals("a..", trt.a_$_());
    assertEquals("noid", trt.noid());
    assertEquals("nullid", trt.nullid());

    // By AD
    assertEquals("secret", trt.xsecret());
    assertEquals("_secret", trt.x__secret());
    assertEquals(".secret", trt.x_secret());
    assertEquals("new", trt.x$new());
    assertEquals("$new", trt.x$$new());
    assertEquals("a.b.c", trt.xa_b_c());
    assertEquals("a_b_c", trt.xa__b__c());
    assertEquals(".a_b", trt.x_a__b());
    assertEquals("$$$$a.b", trt.x$$$$$$$$a_b());
    assertEquals("$$$$a_b", trt.x$$$$$$$$a__b());
    assertEquals("a", trt.xa$());
    assertEquals("a$", trt.xa$$());
    assertEquals("a$", trt.xa$$$());
    assertEquals("a$.$", trt.xa$$_$$());

    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setProperty("Export-Package", "test.metatype");
    b.setProperty("-metatype", "*");
    b.build();
    assertEquals(0, b.getErrors().size());
    assertEquals(0, b.getWarnings().size());

    Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.MetatypeTest$Naming.xml");
    IO.copy(r.openInputStream(), System.err);
    Document d = db.parse(r.openInputStream(), "UTF-8");
    assertEquals(
        "http://www.osgi.org/xmlns/metatype/v1.1.0", d.getDocumentElement().getNamespaceURI());
  }