All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.owasp.html.AutoCloseableHtmlStreamRenderer Maven / Gradle / Ivy

There is a newer version: 20240325.1
Show newest version
package org.owasp.html;

import java.io.IOException;
import javax.annotation.WillCloseWhenClosed;

final class AutoCloseableHtmlStreamRenderer extends HtmlStreamRenderer
  implements AutoCloseable {
  private final AutoCloseable closeable;

  static boolean isAutoCloseable(Object o) {
    return o instanceof AutoCloseable;
  }

  static AutoCloseableHtmlStreamRenderer createAutoCloseableHtmlStreamRenderer(
      @WillCloseWhenClosed
      Appendable output, Handler errorHandler,
      Handler badHtmlHandler) {
    return new AutoCloseableHtmlStreamRenderer(
        output, errorHandler, badHtmlHandler);
  }

  private AutoCloseableHtmlStreamRenderer(
      @WillCloseWhenClosed
      Appendable output, Handler errorHandler,
      Handler badHtmlHandler) {
    super(output, errorHandler, badHtmlHandler);
    this.closeable = (AutoCloseable) output;
  }

  public void close() throws Exception {
    if (isDocumentOpen()) { closeDocument(); }
    closeable.close();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy