Example #1
0
  private void expandAttribute(ChainReader reader, String attribute) throws IOException {
    if (!getTemplate().hasAttribute(attribute)) {
      return;
    }

    List<AttributeValue> values = getTemplate().getAttributeValues(attribute);
    for (AttributeValue value : values) {
      reader.addReader(value.getReader());
    }
  }
Example #2
0
  protected void expandLine(ChainReader reader, String line) throws IOException {
    String prefix;
    String attribute;
    String remaining;

    int start = line.indexOf("${");
    if (start != -1) {
      prefix = line.substring(0, start);

      int end = line.indexOf("}", start + 2);
      if (end != -1) {
        // ${attribute} found
        attribute = line.substring(start + 2, end);
        remaining = line.substring(end + 1);
      } else {
        // start ${ but no } then assume that no attribute was found
        prefix = line;
        attribute = null;
        remaining = null;
      }
    } else {
      // no attribute found
      prefix = line;
      attribute = null;
      remaining = null;
    }

    reader.addReader(new StringReader(prefix));

    if (attribute != null) {
      expandAttribute(reader, attribute);
    }

    if (remaining == null) {
      return;
    }

    expandLine(reader, remaining);
  }