Beispiel #1
0
  /** {@inheritDoc} */
  @Override
  public boolean executeCommand(final String args) {
    final int index = args.indexOf('=');
    final String dots = args.substring(0, index).trim();
    String value = args.substring(index + 1).trim();

    final PropertyEntry entry = PropertyConstraints.getInstance().findEntry(dots);

    if (entry == null) {
      throw new AnalystError("Unknown property: " + args.toUpperCase());
    }

    // strip quotes
    if (value.charAt(0) == '\"') {
      value = value.substring(1);
    }
    if (value.endsWith("\"")) {
      value = value.substring(0, value.length() - 1);
    }

    final String[] cols = dots.split("\\.");
    final String section = cols[0];
    final String subSection = cols[1];
    final String name = cols[2];

    entry.validate(section, subSection, name, value);
    getProp().setProperty(entry.getKey(), value);

    return false;
  }
 /**
  * Save a subsection.
  *
  * @param out The output file.
  * @param section The section.
  * @param subSection The subsection.
  */
 private void saveSubSection(
     final EncogWriteHelper out, final String section, final String subSection) {
   if (!section.equals(out.getCurrentSection())) {
     out.addSection(section);
   }
   out.addSubSection(subSection);
   final List<PropertyEntry> list =
       PropertyConstraints.getInstance().getEntries(section, subSection);
   Collections.sort(list);
   for (final PropertyEntry entry : list) {
     final String key = section + ":" + subSection + "_" + entry.getName();
     final String value = this.script.getProperties().getPropertyString(key);
     if (value != null) {
       out.writeProperty(entry.getName(), value);
     } else {
       out.writeProperty(entry.getName(), "");
     }
   }
 }