Class HtmlWriter

All Implemented Interfaces:
MarkupBuilderWriter, MarkupWriter

public abstract class HtmlWriter extends HtmlBuilder<HtmlWriter> implements MarkupBuilderWriter
Writes HTML using an HtmlBuilder by calling write(Writer).

Example:

        html = new HtmlWriter() {
                protected void build() {
                        html().head().end().body();
                        text("Hello");
                        done();
                }
        };
        //Now write.
        String actual = html.write(writer).getBuffer().toString();
 
See Also:
  • Constructor Details

    • HtmlWriter

      public HtmlWriter()
  • Method Details

    • getSelf

      protected HtmlWriter getSelf()
      Description copied from class: MarkupBuilder
      Needed for fluent style and Java parameterization limitations. Almost all public methods should return whatever this method returns.

      Most implementations only have to do:

       return this;
       
      Specified by:
      getSelf in class MarkupBuilder<HtmlWriter>
      Returns:
      the current builder which is usually this object.
    • write

      public <W extends Writer> W write(W writer)
      Description copied from interface: MarkupWriter
      Writes using the given writer. The writer should not be closed and will not be closed by implementations. Its up to the caller to close the writer.
      Specified by:
      write in interface MarkupWriter
      Type Parameters:
      W - writer type.
      Parameters:
      writer - not null.
      Returns:
      the writer used for fluent style.
    • write

      public <W extends Writer> W write(W writer, int depth)
      Description copied from interface: MarkupBuilderWriter
      Writes using the given writer at the given depth. The writer should not be closed and will not be closed by implementations. Its up to the caller to close the writer.
      Specified by:
      write in interface MarkupBuilderWriter
      Type Parameters:
      W - writer type.
      Parameters:
      writer - not null.
      depth - the indent depth to start at.
      Returns:
      the writer used for fluent style.
      See Also:
    • build

      protected abstract void build()
      Should build the markup and is called by write(Writer).
      See Also: