Class AbstractEntityBuilder

    • Field Detail

      • fields

        private final java.util.List<Field> fields
      • fieldMap

        private final java.util.Map<java.lang.String,​java.util.List<Field>> fieldMap
      • body

        private Body body
    • Constructor Detail

      • AbstractEntityBuilder

        public AbstractEntityBuilder()
    • Method Detail

      • 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 java.util.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​(java.lang.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​(java.lang.String name,
                                            java.lang.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​(java.lang.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 java.util.List<Field> getFields​(java.lang.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> java.util.List<F> getFields​(java.lang.String name,
                                                             java.lang.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​(java.lang.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.
      • obtainField

        public <F extends ParsedField> F obtainField​(java.lang.String fieldName)
      • getMimeType

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

        public java.lang.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​(java.lang.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 java.lang.String getContentTransferEncoding()
        Returns transfer encoding of this message.
        Returns:
        the transfer encoding.
      • setContentTransferEncoding

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

        public java.lang.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​(java.lang.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​(java.lang.String dispositionType,
                                                           java.lang.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​(java.lang.String dispositionType,
                                                           java.lang.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​(java.lang.String dispositionType,
                                                           java.lang.String filename,
                                                           long size,
                                                           java.util.Date creationDate,
                                                           java.util.Date modificationDate,
                                                           java.util.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 java.lang.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 java.util.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 java.util.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 java.util.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​(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​(Multipart multipart)
        Sets body of this message. Also sets the content type based on properties of the given Multipart.
        Parameters:
        multipart - the body.
      • getBody

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