javax.mail.internet.MimeBodyPart.getDataHandler()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中javax.mail.internet.MimeBodyPart.getDataHandler()方法的一些代码示例,展示了MimeBodyPart.getDataHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MimeBodyPart.getDataHandler()方法的具体详情如下:
包路径:javax.mail.internet.MimeBodyPart
类名称:MimeBodyPart
方法名:getDataHandler

MimeBodyPart.getDataHandler介绍

[英]Return a DataHandler for this body part's content.

The implementation provided here works just like the the implementation in MimeMessage.
[中]返回此正文部分内容的DataHandler。
这里提供的实现与mimessage中的实现类似。

代码示例

代码示例来源:origin: stackoverflow.com

  1. System.out.println( "HTML = text/html : " + htmlPart.isMimeType( "text/html" ) );
  2. System.out.println( "HTML Content Type: " + htmlPart.getContentType() );
  3. System.out.println( "HTML Data Handler: " + htmlPart.getDataHandler().getContentType() );

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Return a decoded input stream for this body part's "content". <p>
  3. *
  4. * This implementation obtains the input stream from the DataHandler.
  5. * That is, it invokes getDataHandler().getInputStream();
  6. *
  7. * @return an InputStream
  8. * @exception IOException this is typically thrown by the
  9. * DataHandler. Refer to the documentation for
  10. * javax.activation.DataHandler for more details.
  11. * @exception MessagingException for other failures
  12. *
  13. * @see #getContentStream
  14. * @see javax.activation.DataHandler#getInputStream
  15. */
  16. public InputStream getInputStream()
  17. throws IOException, MessagingException {
  18. return getDataHandler().getInputStream();
  19. }

代码示例来源:origin: com.sun.mail/javax.mail

  1. /**
  2. * Return a decoded input stream for this body part's "content". <p>
  3. *
  4. * This implementation obtains the input stream from the DataHandler.
  5. * That is, it invokes getDataHandler().getInputStream();
  6. *
  7. * @return an InputStream
  8. * @exception IOException this is typically thrown by the
  9. * DataHandler. Refer to the documentation for
  10. * javax.activation.DataHandler for more details.
  11. * @exception MessagingException for other failures
  12. *
  13. * @see #getContentStream
  14. * @see javax.activation.DataHandler#getInputStream
  15. */
  16. @Override
  17. public InputStream getInputStream()
  18. throws IOException, MessagingException {
  19. return getDataHandler().getInputStream();
  20. }

代码示例来源:origin: oblac/jodd

  1. @Test
  2. void testTextHtml() throws MessagingException, IOException {
  3. final Email email = Email.create()
  4. .from(FROM_EXAMPLE_COM)
  5. .to(TO_EXAMPLE_COM)
  6. .subject(SUB)
  7. .textMessage(HELLO)
  8. .htmlMessage("<html><body><h1>Hey!</h1></body></html>");
  9. final Message message = createMessage(email);
  10. assertEquals(1, message.getFrom().length);
  11. assertEquals(FROM_EXAMPLE_COM, message.getFrom()[0].toString());
  12. assertEquals(1, message.getRecipients(RecipientType.TO).length);
  13. assertEquals(TO_EXAMPLE_COM, message.getRecipients(RecipientType.TO)[0].toString());
  14. assertEquals(SUB, message.getSubject());
  15. // wrapper
  16. final MimeMultipart multipart = (MimeMultipart) message.getContent();
  17. assertEquals(1, multipart.getCount());
  18. assertTrue(multipart.getContentType().contains("multipart/mixed"));
  19. // inner content
  20. final MimeBodyPart mimeBodyPart = (MimeBodyPart) multipart.getBodyPart(0);
  21. final MimeMultipart mimeMultipart = (MimeMultipart) mimeBodyPart.getContent();
  22. assertEquals(2, mimeMultipart.getCount());
  23. assertTrue(mimeMultipart.getContentType().contains("multipart/alternative"));
  24. MimeBodyPart bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(0);
  25. assertEquals(HELLO, bodyPart.getContent());
  26. assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_PLAIN));
  27. bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(1);
  28. assertEquals("<html><body><h1>Hey!</h1></body></html>", bodyPart.getContent());
  29. assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML));
  30. }

代码示例来源:origin: oblac/jodd

  1. assertTrue(htmlMimeBodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML));
  2. DataSource dataSource = htmlMimeBodyPart.getDataHandler().getDataSource();
  3. assertEquals(IMAGE_PNG, dataSource.getContentType());
  4. assertArrayEquals(BYTES_1_7, read(dataSource));
  5. dataSource = mimeBodyPart.getDataHandler().getDataSource();
  6. assertEquals(APPLICATION_ZIP, dataSource.getContentType());
  7. assertArrayEquals(BYTES_11_15, read(dataSource));

代码示例来源:origin: camunda/camunda-bpm-platform

  1. public synchronized DataHandler getDataHandler()
  2. throws MessagingException {
  3. if (dh == null) {
  4. if (bs.isMulti())
  5. dh = new DataHandler(
  6. new IMAPMultipartDataSource(
  7. this, bs.bodies, sectionId, message)
  8. );
  9. else if (bs.isNested() && message.isREV1() && bs.envelope != null)
  10. dh = new DataHandler(
  11. new IMAPNestedMessage(message,
  12. bs.bodies[0],
  13. bs.envelope,
  14. sectionId),
  15. type
  16. );
  17. }
  18. return super.getDataHandler();
  19. }

代码示例来源:origin: com.sun.mail/javax.mail

  1. @Override
  2. public synchronized DataHandler getDataHandler()
  3. throws MessagingException {
  4. if (dh == null) {
  5. if (bs.isMulti())
  6. dh = new DataHandler(
  7. new IMAPMultipartDataSource(
  8. this, bs.bodies, sectionId, message)
  9. );
  10. else if (bs.isNested() && message.isREV1() && bs.envelope != null)
  11. dh = new DataHandler(
  12. new IMAPNestedMessage(message,
  13. bs.bodies[0],
  14. bs.envelope,
  15. sectionId),
  16. type
  17. );
  18. }
  19. return super.getDataHandler();
  20. }

代码示例来源:origin: camunda/camunda-bpm-platform

  1. Object c;
  2. try {
  3. c = getDataHandler().getContent();
  4. } catch (FolderClosedIOException fex) {
  5. throw new FolderClosedException(fex.getFolder(), fex.getMessage());

代码示例来源:origin: com.sun.mail/javax.mail

  1. Object c;
  2. try {
  3. c = getDataHandler().getContent();
  4. } catch (FolderClosedIOException fex) {
  5. throw new FolderClosedException(fex.getFolder(), fex.getMessage());

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

  1. public Object getContent() throws MessagingException, IOException {
  2. return getDataHandler().getContent();
  3. }

代码示例来源:origin: OpenAS2/OpenAs2App

  1. public static MimeMultipart createMimeMultipart(MimeBodyPart bodypart)
  2. throws MessagingException {
  3. return new MimeMultipart(bodypart.getDataHandler().getDataSource());
  4. }

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

  1. public InputStream getInputStream() throws MessagingException, IOException {
  2. return getDataHandler().getInputStream();
  3. }

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

  1. public InputStream getInputStream() throws MessagingException, IOException {
  2. return getDataHandler().getInputStream();
  3. }

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

  1. public Object getContent() throws MessagingException, IOException {
  2. return getDataHandler().getContent();
  3. }

代码示例来源:origin: javax.mail/javax.mail-api

  1. /**
  2. * Return a decoded input stream for this body part's "content". <p>
  3. *
  4. * This implementation obtains the input stream from the DataHandler.
  5. * That is, it invokes getDataHandler().getInputStream();
  6. *
  7. * @return an InputStream
  8. * @exception IOException this is typically thrown by the
  9. * DataHandler. Refer to the documentation for
  10. * javax.activation.DataHandler for more details.
  11. * @exception MessagingException for other failures
  12. *
  13. * @see #getContentStream
  14. * @see javax.activation.DataHandler#getInputStream
  15. */
  16. @Override
  17. public InputStream getInputStream()
  18. throws IOException, MessagingException {
  19. return getDataHandler().getInputStream();
  20. }

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec

  1. public void writeTo(OutputStream out) throws IOException, MessagingException {
  2. headers.writeTo(out, null);
  3. // add the separater between the headers and the data portion.
  4. out.write('\r');
  5. out.write('\n');
  6. // we need to process this using the transfer encoding type
  7. OutputStream encodingStream = MimeUtility.encode(out, getEncoding());
  8. getDataHandler().writeTo(encodingStream);
  9. encodingStream.flush();
  10. }

代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

  1. public void writeTo(OutputStream out) throws IOException, MessagingException {
  2. headers.writeTo(out, null);
  3. // add the separater between the headers and the data portion.
  4. out.write('\r');
  5. out.write('\n');
  6. // we need to process this using the transfer encoding type
  7. OutputStream encodingStream = MimeUtility.encode(out, getEncoding());
  8. getDataHandler().writeTo(encodingStream);
  9. encodingStream.flush();
  10. }

代码示例来源:origin: org.codehaus.xfire/xfire-core

  1. private void initMultipart(MimeMultipart multipart) throws MessagingException
  2. {
  3. this.mimeMP = multipart;
  4. MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0);
  5. setSoapMessage(new SimpleAttachment(part.getContentID(), part.getDataHandler()));
  6. for ( int i = 1; i < multipart.getCount(); i++ )
  7. {
  8. part = (MimeBodyPart) multipart.getBodyPart(i);
  9. String id = part.getContentID();
  10. if (id.startsWith("<"))
  11. {
  12. id = id.substring(1, id.length() - 1);
  13. }
  14. addPart(new SimpleAttachment(id, part.getDataHandler()));
  15. }
  16. }

代码示例来源:origin: javax.mail/com.springsource.javax.mail

  1. public synchronized DataHandler getDataHandler()
  2. throws MessagingException {
  3. if (dh == null) {
  4. if (bs.isMulti())
  5. dh = new DataHandler(
  6. new IMAPMultipartDataSource(
  7. this, bs.bodies, sectionId, message)
  8. );
  9. else if (bs.isNested() && message.isREV1() && bs.envelope != null)
  10. dh = new DataHandler(
  11. new IMAPNestedMessage(message,
  12. bs.bodies[0],
  13. bs.envelope,
  14. sectionId),
  15. type
  16. );
  17. }
  18. return super.getDataHandler();
  19. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax.mail

  1. public synchronized DataHandler getDataHandler()
  2. throws MessagingException {
  3. if (dh == null) {
  4. if (bs.isMulti())
  5. dh = new DataHandler(
  6. new IMAPMultipartDataSource(
  7. this, bs.bodies, sectionId, message)
  8. );
  9. else if (bs.isNested() && message.isREV1())
  10. dh = new DataHandler(
  11. new IMAPNestedMessage(message,
  12. bs.bodies[0],
  13. bs.envelope,
  14. sectionId),
  15. type
  16. );
  17. }
  18. return super.getDataHandler();
  19. }

相关文章