Example #1
0
  public static void testSpecialConversions() throws URISyntaxException {
    Properties p = new Properties();
    p.put("enumv", "A");
    p.put("pattern", ".*");
    p.put("clazz", "java.lang.Object");
    p.put("constructor", "http://www.aQute.biz");

    SpecialConversions trt =
        Configurable.createConfigurable(SpecialConversions.class, (Map<Object, Object>) p);
    assertEquals(SpecialConversions.X.A, trt.enumv());
    assertEquals(".*", trt.pattern().pattern());
    assertEquals(Object.class, trt.clazz());
    assertEquals(new URI("http://www.aQute.biz"), trt.constructor());
  }
Example #2
0
File: Macro.java Project: bramk/bnd
 /**
  * Take all the properties and translate them to actual values. This method takes the set
  * properties and traverse them over all entries, including the default properties for that
  * properties. The values no longer contain macros.
  *
  * @return A new Properties with the flattened values
  */
 public Properties getFlattenedProperties() {
   // Some macros only work in a lower processor, so we
   // do not report unknown macros while flattening
   flattening = true;
   try {
     Properties flattened = new Properties();
     Properties source = domain.getProperties();
     for (Enumeration<?> e = source.propertyNames(); e.hasMoreElements(); ) {
       String key = (String) e.nextElement();
       if (!key.startsWith("_"))
         if (key.startsWith("-")) flattened.put(key, source.getProperty(key));
         else flattened.put(key, process(source.getProperty(key)));
     }
     return flattened;
   } finally {
     flattening = false;
   }
 }
Example #3
0
  static <T> T set(Class<T> interf, Object value) {
    Properties p = new Properties();
    Method ms[] = interf.getMethods();

    for (Method m : ms) {
      p.put(m.getName(), value);
    }
    return Configurable.createConfigurable(interf, (Map<Object, Object>) p);
  }