예제 #1
0
  protected void doFilter(Source source, Result result) {
    if (!(source instanceof StreamSource) && !(source instanceof JavaSource)) {
      throw new IllegalArgumentException(
          source.getClass().getName()
              + " Source types not yet supported by the SAX Filter. Only supports StreamSource and JavaSource at present.");
    }
    if (!(result instanceof FilterResult)) {
      if (!(result instanceof StreamResult) && result != null) {
        throw new IllegalArgumentException(
            result.getClass().getName()
                + " Result types not yet supported by the SAX Filter. Only supports StreamResult at present.");
      }
    }

    try {
      Writer writer = parser.parse(source, result, executionContext);
      writer.flush();
    } catch (Exception e) {
      throw new SmooksException("Failed to filter source.", e);
    } finally {
      if (closeSource) {
        close(source);
      }
      if (closeResult) {
        close(result);
      }
    }
  }
예제 #2
0
 public void cleanup() {
   parser.cleanup();
 }