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

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

本文整理了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

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

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

/**
 * Return a decoded input stream for this body part's "content". <p>
 *
 * This implementation obtains the input stream from the DataHandler.
 * That is, it invokes getDataHandler().getInputStream();
 *
 * @return         an InputStream
 * @exception       IOException this is typically thrown by the
 *            DataHandler. Refer to the documentation for
 *            javax.activation.DataHandler for more details.
 * @exception    MessagingException for other failures
 *
 * @see    #getContentStream
 * @see     javax.activation.DataHandler#getInputStream
 */
public InputStream getInputStream() 
  throws IOException, MessagingException {
return getDataHandler().getInputStream();
}

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

/**
 * Return a decoded input stream for this body part's "content". <p>
 *
 * This implementation obtains the input stream from the DataHandler.
 * That is, it invokes getDataHandler().getInputStream();
 *
 * @return         an InputStream
 * @exception       IOException this is typically thrown by the
 *            DataHandler. Refer to the documentation for
 *            javax.activation.DataHandler for more details.
 * @exception    MessagingException for other failures
 *
 * @see    #getContentStream
 * @see     javax.activation.DataHandler#getInputStream
 */
@Override
public InputStream getInputStream() 
  throws IOException, MessagingException {
return getDataHandler().getInputStream();
}

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

@Test
void testTextHtml() throws MessagingException, IOException {
  final Email email = Email.create()
    .from(FROM_EXAMPLE_COM)
    .to(TO_EXAMPLE_COM)
    .subject(SUB)
    .textMessage(HELLO)
    .htmlMessage("<html><body><h1>Hey!</h1></body></html>");
  final Message message = createMessage(email);
  assertEquals(1, message.getFrom().length);
  assertEquals(FROM_EXAMPLE_COM, message.getFrom()[0].toString());
  assertEquals(1, message.getRecipients(RecipientType.TO).length);
  assertEquals(TO_EXAMPLE_COM, message.getRecipients(RecipientType.TO)[0].toString());
  assertEquals(SUB, message.getSubject());
  // wrapper
  final MimeMultipart multipart = (MimeMultipart) message.getContent();
  assertEquals(1, multipart.getCount());
  assertTrue(multipart.getContentType().contains("multipart/mixed"));
  // inner content
  final MimeBodyPart mimeBodyPart = (MimeBodyPart) multipart.getBodyPart(0);
  final MimeMultipart mimeMultipart = (MimeMultipart) mimeBodyPart.getContent();
  assertEquals(2, mimeMultipart.getCount());
  assertTrue(mimeMultipart.getContentType().contains("multipart/alternative"));
  MimeBodyPart bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(0);
  assertEquals(HELLO, bodyPart.getContent());
  assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_PLAIN));
  bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(1);
  assertEquals("<html><body><h1>Hey!</h1></body></html>", bodyPart.getContent());
  assertTrue(bodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML));
}

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

assertTrue(htmlMimeBodyPart.getDataHandler().getContentType().contains(MimeTypes.MIME_TEXT_HTML));
DataSource dataSource = htmlMimeBodyPart.getDataHandler().getDataSource();
assertEquals(IMAGE_PNG, dataSource.getContentType());
assertArrayEquals(BYTES_1_7, read(dataSource));
dataSource = mimeBodyPart.getDataHandler().getDataSource();
assertEquals(APPLICATION_ZIP, dataSource.getContentType());
assertArrayEquals(BYTES_11_15, read(dataSource));

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

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() && bs.envelope != null)
  dh = new DataHandler(
    new IMAPNestedMessage(message, 
           bs.bodies[0],
           bs.envelope,
           sectionId),
    type
     );
}
return super.getDataHandler();
}

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

@Override
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() && bs.envelope != null)
  dh = new DataHandler(
    new IMAPNestedMessage(message, 
           bs.bodies[0],
           bs.envelope,
           sectionId),
    type
     );
}
return super.getDataHandler();
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * Return a decoded input stream for this body part's "content". <p>
 *
 * This implementation obtains the input stream from the DataHandler.
 * That is, it invokes getDataHandler().getInputStream();
 *
 * @return         an InputStream
 * @exception       IOException this is typically thrown by the
 *            DataHandler. Refer to the documentation for
 *            javax.activation.DataHandler for more details.
 * @exception    MessagingException for other failures
 *
 * @see    #getContentStream
 * @see     javax.activation.DataHandler#getInputStream
 */
@Override
public InputStream getInputStream() 
  throws IOException, MessagingException {
return getDataHandler().getInputStream();
}

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

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

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

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

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

private void initMultipart(MimeMultipart multipart) throws MessagingException
{
  this.mimeMP = multipart;
  
  MimeBodyPart part = (MimeBodyPart) multipart.getBodyPart(0);
  setSoapMessage(new SimpleAttachment(part.getContentID(), part.getDataHandler()));
  
  for ( int i = 1; i < multipart.getCount(); i++ )
  {
    part = (MimeBodyPart) multipart.getBodyPart(i);
    String id = part.getContentID();
    if (id.startsWith("<"))
    {
      id = id.substring(1, id.length() - 1);
    }
    
    addPart(new SimpleAttachment(id, part.getDataHandler()));
  }
}

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

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() && bs.envelope != null)
  dh = new DataHandler(
    new IMAPNestedMessage(message, 
           bs.bodies[0],
           bs.envelope,
           sectionId),
    type
     );
}
return super.getDataHandler();
}

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

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
     );
}
return super.getDataHandler();
}

相关文章