Class AbstractEntityBuilder

java.lang.Object
org.apache.james.mime4j.internal.AbstractEntityBuilder
Direct Known Subclasses:
BodyPartBuilder, Message.Builder

public abstract class AbstractEntityBuilder extends Object
  • Field Details

  • Constructor Details

    • AbstractEntityBuilder

      public AbstractEntityBuilder()
  • Method Details

    • addField

      public AbstractEntityBuilder addField(Field field)
      Adds a field to the end of the list of fields.
      Parameters:
      field - the field to add.
    • getFields

      public List<Field> getFields()
      Gets the fields of this header. The returned list will not be modifiable.
      Returns:
      the list of Field objects.
    • getField

      public Field getField(String name)
      Gets a Field given a field name. If there are multiple such fields defined in this header the first one will be returned.
      Parameters:
      name - the field name (e.g. From, Subject).
      Returns:
      the field or null if none found.
    • getField

      public <F extends Field> F getField(String name, Class<F> clazz)
      Gets a Field given a field name and of the given type. If there are multiple such fields defined in this header the first one will be returned.
      Parameters:
      name - the field name (e.g. From, Subject).
      clazz - the field class.
      Returns:
      the field or null if none found.
    • containsField

      public boolean containsField(String name)
      Returns true if there is at least one explicitly set field with the given name.
      Parameters:
      name - the field name (e.g. From, Subject).
      Returns:
      true if there is at least one explicitly set field with the given name, false otherwise.
    • getFields

      public List<Field> getFields(String name)
      Gets all Fields having the specified field name.
      Parameters:
      name - the field name (e.g. From, Subject).
      Returns:
      the list of fields.
    • getFields

      public <F extends Field> List<F> getFields(String name, Class<F> clazz)
      Gets all Fields having the specified field name and of the given type.
      Parameters:
      name - the field name (e.g. From, Subject).
      clazz - the field class.
      Returns:
      the list of fields.
    • removeFields

      public AbstractEntityBuilder removeFields(String name)
      Removes all Fields having the specified field name.
      Parameters:
      name - the field name (e.g. From, Subject).
    • setField

      public AbstractEntityBuilder setField(Field field)
      Sets or replaces a field. This method is useful for header fields such as Subject or Message-ID that should not occur more than once in a message. If this builder does not already contain a header field of the same name as the given field then it is added to the end of the list of fields (same behavior as addField(org.apache.james.mime4j.stream.Field)). Otherwise the first occurrence of a field with the same name is replaced by the given field and all further occurrences are removed.
      Parameters:
      field - the field to set.
    • clearFields

      public AbstractEntityBuilder clearFields()
      Clears all fields.
    • obtainField

      public <F extends ParsedField> F obtainField(String fieldName)
    • getMimeType

      public String getMimeType()
      Returns MIME type of this message.
      Returns:
      the MIME type or null if no MIME type has been set.
    • getCharset

      public String getCharset()
      Returns MIME character set encoding of this message.
      Returns:
      the MIME character set encoding or null if no charset type has been set.
    • setContentType

      public AbstractEntityBuilder setContentType(String mimeType, NameValuePair... parameters)
      Sets transfer encoding of this message.
      Parameters:
      mimeType - MIME type of this message the MIME type to use.
      parameters - content type parameters to use.
    • getContentTransferEncoding

      public String getContentTransferEncoding()
      Returns transfer encoding of this message.
      Returns:
      the transfer encoding.
    • setContentTransferEncoding

      public AbstractEntityBuilder setContentTransferEncoding(String contentTransferEncoding)
      Sets transfer encoding of this message.
      Parameters:
      contentTransferEncoding - transfer encoding to use.
    • getDispositionType

      public String getDispositionType()
      Return disposition type of this message.
      Returns:
      the disposition type or null if no disposition type has been set.
    • setContentDisposition

      public AbstractEntityBuilder setContentDisposition(String dispositionType)
      Sets content disposition of this message to the specified disposition type. No filename, size or date parameters are included in the content disposition.
      Parameters:
      dispositionType - disposition type value (usually inline or attachment).
    • setContentDisposition

      public AbstractEntityBuilder setContentDisposition(String dispositionType, String filename)
      Sets content disposition of this message to the specified disposition type and filename. No size or date parameters are included in the content disposition.
      Parameters:
      dispositionType - disposition type value (usually inline or attachment).
      filename - filename parameter value or null if the parameter should not be included.
    • setContentDisposition

      public AbstractEntityBuilder setContentDisposition(String dispositionType, String filename, long size)
      Sets content disposition of this message to the specified values. No date parameters are included in the content disposition.
      Parameters:
      dispositionType - disposition type value (usually inline or attachment).
      filename - filename parameter value or null if the parameter should not be included.
      size - size parameter value or -1 if the parameter should not be included.
    • setContentDisposition

      public AbstractEntityBuilder setContentDisposition(String dispositionType, String filename, long size, Date creationDate, Date modificationDate, Date readDate)
      Sets content disposition of this message to the specified values.
      Parameters:
      dispositionType - disposition type value (usually inline or attachment).
      filename - filename parameter value or null if the parameter should not be included.
      size - size parameter value or -1 if the parameter should not be included.
      creationDate - creation-date parameter value or null if the parameter should not be included.
      modificationDate - modification-date parameter value or null if the parameter should not be included.
      readDate - read-date parameter value or null if the parameter should not be included.
    • getFilename

      public String getFilename()
      Returns filename of the content disposition of this message.
      Returns:
      the filename parameter of the content disposition or null if the filename has not been set.
    • getSize

      public long getSize()
      Returns size of the content disposition of this message.
      Returns:
      the size parameter of the content disposition or -1 if the filename has not been set.
    • getCreationDate

      public Date getCreationDate()
      Returns creation date of the content disposition of this message.
      Returns:
      the creation date parameter of the content disposition or null if the filename has not been set.
    • getModificationDate

      public Date getModificationDate()
      Returns modification date of the content disposition of this message.
      Returns:
      the modification date parameter of the content disposition or null if the filename has not been set.
    • getReadDate

      public Date getReadDate()
      Returns read date of the content disposition of this message.
      Returns:
      the read date parameter of the content disposition or null if the filename has not been set.
    • setBody

      public AbstractEntityBuilder setBody(Body body)
      Sets body of this message. Also sets the content type based on properties of the given Body.
      Parameters:
      body - the body.
    • setBody

      public AbstractEntityBuilder setBody(SingleBodyBuilder body) throws IOException
      Throws:
      IOException
    • setBody

      public AbstractEntityBuilder setBody(TextBody textBody)
      Sets body of this message. Also sets the content type based on properties of the given Body.
      Parameters:
      textBody - the body.
    • setBody

      public AbstractEntityBuilder setBody(BinaryBody binaryBody)
      Sets binaryBody of this message. Also sets the content type based on properties of the given Body.
      Parameters:
      binaryBody - the binaryBody.
    • setBody

      public AbstractEntityBuilder setBody(Message message)
      Sets body of this message. Also sets the content type based on properties of the given Message.
      Parameters:
      message - the body.
    • setBody

      public AbstractEntityBuilder setBody(Message.Builder message)
    • setBody

      public AbstractEntityBuilder setBody(Multipart multipart)
      Sets body of this message. Also sets the content type based on properties of the given Multipart.
      Parameters:
      multipart - the body.
    • setBody

      public AbstractEntityBuilder setBody(MultipartBuilder multipart)
    • getBody

      public Body getBody()
      Returns message body.
      Returns:
      the message body.