Package com.santiagolizardo.beobachter.config

Examples of com.santiagolizardo.beobachter.config.PropertySet


    return file.renameTo(newFile);
  }

  public LogType loadFromFile(String name) {
    String path = getPath(name);
    PropertySet configuration = new PropertySet(
        path);

    LogType logType = new LogType(name);
    logType.setRefreshInterval(configuration.getShort(REFRESH_INTERVAL));

    for (short i = 0; configuration.getProperty("rule." + i
        + ".regular_expression") != null; i++) {
      Rule rule = new Rule();
      String pattern = configuration.getProperty("rule." + i
          + ".pattern");
      rule.setPattern(null == pattern ? "" : pattern);
      rule.setRegularExpression(configuration.getBoolean("rule." + i
          + ".regular_expression"));
      rule.setIgnoreCase(configuration.getBoolean("rule." + i
          + ".ignore_case"));
      rule.setBackgroundColor(configuration.getColor("rule." + i
          + ".background_color"));
      rule.setForegroundColor(configuration.getColor("rule." + i
          + ".foreground_color"));

      logType.addRule(rule);
    }
View Full Code Here


    return logType;
  }

  public void saveToFile(LogType logType) throws IOException {
    PropertySet configuration = new PropertySet();

    configuration.setProperty(REFRESH_INTERVAL,
        logType.getRefreshInterval());

    List<Rule> rules = logType.getRules();
    for (int i = 0; i < rules.size(); i++) {
      Rule rule = (Rule) rules.get(i);
      configuration.setProperty("rule." + i + ".pattern",
          rule.getPattern());
      configuration.setProperty("rule." + i + ".regular_expression",
          rule.isRegularExpression());
      configuration.setProperty("rule." + i + ".ignore_case",
          rule.isIgnoreCase());
      configuration.setColor("rule." + i + ".background_color",
          rule.getBackgroundColor());
      configuration.setColor("rule." + i + ".foreground_color",
          rule.getForegroundColor());
    }

    String path = getPath(logType.getName());
    configuration.save(path);
  }
View Full Code Here

TOP

Related Classes of com.santiagolizardo.beobachter.config.PropertySet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.