Message (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.taskdefs.email, class: Message

Package org.apache.tools.ant.taskdefs.email

# Class Message

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.taskdefs.email.Message

All Implemented Interfaces:
  `Cloneable`

public class Message extends ProjectComponent
Class representing an email message.

Since:
  Ant 1.5

- ## Field Summary

  ### Fields inherited from class org.apache.tools.ant.ProjectComponent

  `description, location, project`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Message()`
  Creates a new empty message
  `Message​(File file)`
  Creates a new message using the contents of the given file.
  `Message​(String text)`
  Creates a new message based on the given string

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addText​(String text)`
  Adds a textual part of the message
  `String`
  `getCharset()`
  Returns the charset of mail message.
  `String`
  `getMimeType()`
  Returns the content type
  `boolean`
  `isMimeTypeSpecified()`
  Returns true if the mimeType has been set.
  `void`
  `print​(PrintStream ps)`
  Prints the message onto an output stream
  `void`
  `setCharset​(String charset)`
  Sets the character set of mail message.
  `void`
  `setInputEncoding​(String encoding)`
  Sets the encoding to expect when reading the message from a file.
  `void`
  `setMimeType​(String mimeType)`
  Sets the content type for the message
  `void`
  `setSrc​(File src)`
  Sets the source file of the message

  ### Methods inherited from class org.apache.tools.ant.ProjectComponent

  `clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Message

    public Message()
    Creates a new empty message

  - ### Message

    public Message​(String text)
    Creates a new message based on the given string
    Parameters:
      `text` - the message

  - ### Message

    public Message​(File file)
    Creates a new message using the contents of the given file.
    Parameters:
      `file` - the source of the message

- ## Method Details

  - ### addText

    public void addText​(String text)
    Adds a textual part of the message
    Parameters:
      `text` - some text to add

  - ### setSrc

    public void setSrc​(File src)
    Sets the source file of the message
    Parameters:
      `src` - the source of the message

  - ### setMimeType

    public void setMimeType​(String mimeType)
    Sets the content type for the message
    Parameters:
      `mimeType` - a mime type e.g. "text/plain"

  - ### getMimeType

    public String getMimeType()
    Returns the content type
    Returns:
      the mime type

  - ### print

    public void print​(PrintStream ps) throws IOException
    Prints the message onto an output stream
    Parameters:
      `ps` - The print stream to write to
    Throws:
      `IOException` - if an error occurs

  - ### isMimeTypeSpecified

    public boolean isMimeTypeSpecified()
    Returns true if the mimeType has been set.
    Returns:
      false if the default value is in use

  - ### setCharset

    public void setCharset​(String charset)
    Sets the character set of mail message. Will be ignored if mimeType contains ....; Charset=... substring.
    Parameters:
      `charset` - the character set name.
    Since:
      Ant 1.6

  - ### getCharset

    public String getCharset()
    Returns the charset of mail message.
    Returns:
      Charset of mail message.
    Since:
      Ant 1.6

  - ### setInputEncoding

    public void setInputEncoding​(String encoding)
    Sets the encoding to expect when reading the message from a file.

    Will be ignored if the message has been specified inline.

    Parameters:
      `encoding` - the name of the charset used
    Since:
      Ant 1.9.4