예제 #1
0
파일: Rules.java 프로젝트: mimesis/mambalab
  boolean Load(String rulename) {

    if (files.contains(rulename)) {
      log.info(rulename + " already loaded");
      return true;
    }
    files.add(rulename);

    String filename = getFilenameFromClassname(rulename);

    LinkedProperties props = new LinkedProperties(filename); // order is important

    Enumeration<Object> e = props.keys();

    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();

      String[] ar = key.split("\\.");
      String c = rulename; // ar[0].trim();
      String n = ar[0].trim();
      String p = ar[1].trim();

      String prop = props.getProperty(key).trim();
      Rule r = findOrCreateRule(c, n);
      if (p.equals("epl")) {
        if (r.epl == null) r.epl = prop;
        else System.err.println(key + " already assigned");
      } else if (p.equals("description")) r.description = prop;
      else if (p.equals("log")) r.loglevel = prop;
      else if (p.equals("action")) r.action = prop;
      else if (p.equals("sql")) r.sql = prop;
    }

    return true;
  }
예제 #2
0
 public static LinkedHashMap<String, String> loadFromXML(InputStream in) throws IOException {
   LinkedProperties props = new LinkedProperties();
   props.loadFromXML(in);
   return props.list;
 }