Class BasicBodyFactory.StringBody2

java.lang.Object
org.apache.james.mime4j.dom.SingleBody
org.apache.james.mime4j.dom.TextBody
org.apache.james.mime4j.message.BasicBodyFactory.StringBody2
All Implemented Interfaces:
Body, Disposable
Enclosing class:
BasicBodyFactory

static class BasicBodyFactory.StringBody2 extends TextBody
  • Field Details

    • content

      private final byte[] content
    • charset

      private final Charset charset
  • Constructor Details

    • StringBody2

      StringBody2(byte[] content, Charset charset)
  • Method Details

    • getMimeCharset

      public String getMimeCharset()
      Description copied from class: TextBody
      Returns the MIME charset of this text body.
      Specified by:
      getMimeCharset in class TextBody
      Returns:
      the MIME charset.
    • getCharset

      public Charset getCharset()
      Specified by:
      getCharset in class TextBody
    • getReader

      public Reader getReader() throws IOException
      Description copied from class: TextBody
      Gets a Reader which may be used to read out the contents of this body.
      Specified by:
      getReader in class TextBody
      Returns:
      the Reader.
      Throws:
      IOException - on I/O errors.
    • getInputStream

      public InputStream getInputStream() throws IOException
      Description copied from class: SingleBody
      Gets a InputStream which reads the bytes of the body.
      Specified by:
      getInputStream in class SingleBody
      Returns:
      the stream, transfer decoded
      Throws:
      IOException - on I/O errors.
    • writeTo

      public void writeTo(OutputStream out) throws IOException
      Description copied from class: SingleBody
      Writes this single body to the given stream. The default implementation copies the input stream obtained by SingleBody.getInputStream() to the specified output stream. May be overwritten by a subclass to improve performance.
      Overrides:
      writeTo in class SingleBody
      Parameters:
      out - the stream to write to.
      Throws:
      IOException - in case of an I/O error
    • size

      public long size()
      Overrides:
      size in class SingleBody
    • dispose

      public void dispose()
      Description copied from class: SingleBody
      Subclasses should override this method if they have allocated resources that need to be freed explicitly (e.g. cannot be simply reclaimed by the garbage collector). The default implementation of this method does nothing.
      Specified by:
      dispose in interface Disposable
      Overrides:
      dispose in class SingleBody
      See Also:
    • copy

      public SingleBody copy()
      Description copied from class: SingleBody
      Returns a copy of this SingleBody (optional operation).

      The general contract of this method is as follows:

      • Invoking SingleBody.getParent() on the copy returns null. That means that the copy is detached from the parent entity of this SingleBody. The copy may get attached to a different entity later on.
      • The underlying content does not have to be copied. Instead it may be shared between multiple copies of a SingleBody.
      • If the underlying content is shared by multiple copies the implementation has to make sure that the content gets deleted when the last copy gets disposed of (and not before that).

      This implementation always throws an UnsupportedOperationException.

      Overrides:
      copy in class SingleBody
      Returns:
      a copy of this SingleBody.