Package com.google.code.javax.activation

Examples of com.google.code.javax.activation.DataHandler


    public void setContent(Object o, String type)
      throws MessagingException {
  if (o instanceof Multipart)
      setContent((Multipart)o);
  else
      setDataHandler(new DataHandler(o, type));
    }
View Full Code Here


     * @exception  IllegalStateException if this message is
     *      obtained from a READ_ONLY folder.
     * @exception       MessagingException
     */
    public void setContent(Multipart mp) throws MessagingException {
  setDataHandler(new DataHandler(mp, mp.getContentType()));
  mp.setParent(this);
    }
View Full Code Here

   * we're now committed to using this instance of the
   * object and we discard any stream data used to create
   * this object.
   */
  if (cachedContent != null) {
      dh = new DataHandler(cachedContent, getContentType());
      cachedContent = null;
      content = null;
      if (contentStream != null) {
    try {
        contentStream.close();
View Full Code Here

     
    public synchronized DataHandler getDataHandler()
    throws MessagingException {
  if (dh == null) {
     if (bs.isMulti())
    dh = new DataHandler(
      new IMAPMultipartDataSource(
        this, bs.bodies, sectionId, message)
         );
      else if (bs.isNested() && message.isREV1())
    dh = new DataHandler(
      new IMAPNestedMessage(message,
                bs.bodies[0],
                bs.envelope,
                sectionId),
      type
View Full Code Here

    public void setContent(Object o, String type)
    throws MessagingException {
  if (o instanceof Multipart) {
      setContent((Multipart)o);
  } else {
      setDataHandler(new DataHandler(o, type));
  }
    }
View Full Code Here

     *      existing values.
     * @exception  IllegalStateException if this body part is
     *      obtained from a READ_ONLY folder.
     */
    public void setContent(Multipart mp) throws MessagingException {
  setDataHandler(new DataHandler(mp, mp.getContentType()));
  mp.setParent(this);
    }
View Full Code Here

     * @exception  MessagingException  message related errors
     * @since    JavaMail 1.4
     */
    public void attachFile(File file) throws IOException, MessagingException {
      FileDataSource fds = new FileDataSource(file);    
        this.setDataHandler(new DataHandler(fds));
        this.setFileName(fds.getName());
    }
View Full Code Here

   * we're now committed to using this instance of the
   * object and we discard any stream data used to create
   * this object.
   */
  if (cachedContent != null) {
      dh = new DataHandler(cachedContent, getContentType());
      cachedContent = null;
      content = null;
      if (contentStream != null) {
    try {
        contentStream.close();
View Full Code Here

  }
  return encoding;
    }

    static void updateHeaders(MimePart part) throws MessagingException {
  DataHandler dh = part.getDataHandler();
  if (dh == null) // Huh ?
      return;

  try {
      String type = dh.getContentType();
      boolean composite = false;
      boolean needCTHeader = part.getHeader("Content-Type") == null;

      ContentType cType = new ContentType(type);

      /*
       * If this is a multipart, give sub-parts a chance to
       * update their headers.  Even though the data for this
       * multipart may have come from a stream, one of the
       * sub-parts may have been updated.
       */
      if (cType.match("multipart/*")) {
    // If multipart, recurse
    composite = true;
    Object o;
    if (part instanceof MimeBodyPart) {
        MimeBodyPart mbp = (MimeBodyPart)part;
        o = mbp.cachedContent != null ?
        mbp.cachedContent : dh.getContent();
    } else if (part instanceof MimeMessage) {
        MimeMessage msg = (MimeMessage)part;
        o = msg.cachedContent != null ?
        msg.cachedContent : dh.getContent();
    } else
        o = dh.getContent();
    if (o instanceof MimeMultipart)
        ((MimeMultipart)o).updateHeaders();
    else
        throw new MessagingException("MIME part of type \"" +
      type + "\" contains object of type " +
View Full Code Here

      /*
       * If the data for this part comes from a stream,
       * just copy it to the output stream without decoding
       * and reencoding it.
       */
      DataHandler dh = part.getDataHandler();
      if (dh instanceof MimePartDataHandler) {
    // call getContentStream to give subclass a chance to
    // provide the data on demand
    if (part instanceof MimeBodyPart) {
        MimeBodyPart mbp = (MimeBodyPart)part;
View Full Code Here

TOP

Related Classes of com.google.code.javax.activation.DataHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.