Пример #1
0
  private String doCommands(String key, Link source) {
    String[] args = commands.split(key);
    if (args == null || args.length == 0) return null;

    for (int i = 0; i < args.length; i++)
      if (args[i].indexOf('\\') >= 0) args[i] = args[i].replaceAll("\\\\;", ";");

    if (args[0].startsWith("^")) {
      String varname = args[0].substring(1).trim();

      Processor parent = source.start.getParent();
      if (parent != null) return parent.getProperty(varname);
      return null;
    }

    Processor rover = domain;
    while (rover != null) {
      String result = doCommand(rover, args[0], args);
      if (result != null) return result;

      rover = rover.getParent();
    }

    for (int i = 0; targets != null && i < targets.length; i++) {
      String result = doCommand(targets[i], args[0], args);
      if (result != null) return result;
    }

    return doCommand(this, args[0], args);
  }
Пример #2
0
  protected String replace(String key, Link link) {
    if (link != null && link.contains(key)) return "${infinite:" + link.toString() + "}";

    if (key != null) {
      key = key.trim();
      if (key.length() > 0) {
        Processor source = domain;
        String value = null;

        if (key.indexOf(';') < 0) {
          Instruction ins = new Instruction(key);
          if (!ins.isLiteral()) {
            SortedList<String> sortedList = SortedList.fromIterator(domain.iterator());
            StringBuilder sb = new StringBuilder();
            String del = "";
            for (String k : sortedList) {
              if (ins.matches(k)) {
                String v = replace(k, new Link(source, link, key));
                if (v != null) {
                  sb.append(del);
                  del = ",";
                  sb.append(v);
                }
              }
            }
            return sb.toString();
          }
        }
        while (value == null && source != null) {
          value = source.getProperties().getProperty(key);
          source = source.getParent();
        }

        if (value != null) return process(value, new Link(source, link, key));

        value = doCommands(key, link);
        if (value != null) return process(value, new Link(source, link, key));

        if (key != null && key.trim().length() > 0) {
          value = System.getProperty(key);
          if (value != null) return value;
        }
        if (!flattening && !key.equals("@"))
          domain.warning("No translation found for macro: " + key);
      } else {
        domain.warning("Found empty macro key");
      }
    } else {
      domain.warning("Found null macro key");
    }
    return "${" + key + "}";
  }
Пример #3
0
 /**
  * Constructs a <code>BlockingControlLink</code> with the specified blocked and control <code>
  * Processor</code>s.
  *
  * <p>The parent {@link Workflow} is set to be the same as the parent of the block <code>Processor
  * </code>.
  *
  * @param block the <code>Processor</code> that is blocked from starting. <strong>Must
  *     not</strong> be <code>null</code>
  * @param untilFinished the <code>Processor</code> that controls the block. Can be <code>null
  *     </code>.
  */
 public BlockingControlLink(Processor block, Processor untilFinished) {
   setUntilFinished(untilFinished);
   setBlock(block);
   setParent(block.getParent());
 }