java.lang.Object
i2p.susi.webmail.Attachment

public class Attachmentextends Object
Represents an email attachment with metadata and file data.
  • Field Details

    • _nextId

      private static final AtomicInteger _nextId
      Unique per-process id, used as the attachment id in the compose UI.
    • id

      public final int id
      The id of this attachment, unique per process.
    • fileName

      private final String fileName
      Suggested file name for the attachment.
    • contentType

      private final String contentType
      MIME content type of the attachment.
    • transferEncoding

      private final String transferEncoding
      MIME transfer encoding of the attachment.
    • data

      private final File data
      The file containing the attachment data.
  • Constructor Details

    • Attachment

      Attachment(String name, String type, String encoding, File data)
      Reference a file to be attached to an email.
      Parameters:
      name - the file name
      type - the content type
      encoding - the transfer encoding, non-null
      data - the file containing the attachment data
  • Method Details

    • getFileName

      public String getFileName()
      The attachment's suggested file name.
      Returns:
      the file name, may be null
    • getTransferEncoding

      public String getTransferEncoding()
      The MIME transfer encoding of the attachment data.
      Returns:
      the transfer encoding, non-null
    • getContentType

      public String getContentType()
      The MIME content type of the attachment.
      Returns:
      the content type, or null if the part had no Content-Type header
    • getData

      public InputStream getData() throws IOException
      Returns an input stream for reading the attachment data.
      Returns:
      an input stream for reading the attachment data
      Throws:
      IOException - if the file cannot be opened for reading
    • getPath

      public String getPath()
      Returns the absolute path to the data file.
      Returns:
      absolute path to the data file
    • getSize

      public long getSize()
      The unencoded size.
      Returns:
      the unencoded size
    • deleteData

      public void deleteData()
      Delete the data file.
    • hashCode

      public int hashCode()
      Returns a hash code based on the file name and data file.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object o)
      Compares this attachment to another for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if the attachments are equal