Class Message.AbstractBuilder<R extends Message,B extends Message.AbstractBuilder<R,B>>

java.lang.Object
org.netpreserve.jwarc.Message.AbstractBuilder<R,B>
Direct Known Subclasses:
HttpMessage.AbstractBuilder, WarcRecord.AbstractBuilder
Enclosing class:
Message

public abstract static class Message.AbstractBuilder<R extends Message,B extends Message.AbstractBuilder<R,B>> extends Object
  • Field Details

  • Constructor Details

    • AbstractBuilder

      public AbstractBuilder(MessageVersion defaultVersion)
  • Method Details

    • build

      public abstract R build()
      Finishes building.
    • addHeader

      public B addHeader(String name, String value)
      Adds a header field. Existing headers with the same name are not removed.
    • addHeaders

      public B addHeaders(Map<String,List<String>> headers)
      Appends header fields. Existing headers with the same name are not removed.
    • setHeader

      public B setHeader(String name, String value)
      Sets a header field. Removes any existing headers with the same name. If value is null then simply removes all existing headers with the given name.
    • version

      public B version(MessageVersion version)
      Sets the protocol version of this message or record.
    • body

      public B body(MediaType contentType, byte[] contentBytes)
      Sets the message body. The Content-Length header will be set to the length of contentBytes. The Content-Type header will be set to contentType unless it is null.
    • body

      public B body(MediaType contentType, ReadableByteChannel channel, long length)
      Sets the message body. The Content-Length header will be set to length. The Content-Type header will be set to contentType unless it is null.