javax.activation.DataHandler.getContent()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(143)

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

DataHandler.getContent介绍

[英]Return the data in its preferred Object form.

If the DataHandler was instantiated with an object, return the object.

If the DataHandler was instantiated with a DataSource, this method uses a DataContentHandler to return the content object for the data represented by this DataHandler. If no DataContentHandler can be found for the the type of this data, the DataHandler returns an InputStream for the data.
[中]以首选对象形式返回数据。
如果DataHandler是使用对象实例化的,则返回该对象。
如果DataHandler是使用数据源实例化的,则此方法使用DataContentHandler返回此DataHandler表示的数据的内容对象。如果找不到此数据类型的DataContentHandler,DataHandler将返回数据的InputStream。

代码示例

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

&& dh.getContent() instanceof Source) {
dh = new DataHandler(createDataSource((Source)dh.getContent(), ct));

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

public Object getContent() throws IOException {
  return parent.getContent();
}

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

try {
  o = dh.getContent();
} catch (IOException e) {
  throw new Fault(e);

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

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

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

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();

代码示例来源: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

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();

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

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: org.apache.geronimo.specs/geronimo-javamail_1.3.1_spec

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

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

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

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

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

代码示例来源:origin: IanDarwin/javasrc

private void process(String fn) throws IOException {
    DataSource ds = new FileDataSource(fn);

    DataHandler dh = new DataHandler(ds);

    DataHandler.setDataContentHandlerFactory(new MyDataContentHandlerFactory());

    Object data = dh.getContent();

    System.out.println("Content=" + data);
    if (data != null)
      System.out.println("Type   =" + data.getClass().getName());
  }
}

代码示例来源:origin: org.apache.camel/camel-mail

private Message extractAttachment(Message inMessage, String attachmentName) throws Exception {
  final Message outMessage = new DefaultMessage(inMessage.getExchange().getContext());
  outMessage.setHeader(HEADER_NAME, attachmentName);
  Object attachment = inMessage.getAttachment(attachmentName).getContent();
  if (attachment instanceof InputStream) {
    outMessage.setBody(readMimePart((InputStream) attachment));
    return outMessage;
  } else if (attachment instanceof String || attachment instanceof byte[]) {
    outMessage.setBody(attachment);
    return outMessage;
  } else {
    return null;
  }
}

代码示例来源:origin: org.jboss.ws.native/jbossws-native-core

public Object getContent() throws SOAPException
{
 if (dataHandler == null)
   throw new SOAPException(BundleUtils.getMessage(bundle, "NO_CONTENT_AVAILABLE"));
 try
 {
   return dataHandler.getContent();
 }
 catch (IOException e)
 {
   throw new SOAPException(e);
 }
}

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

Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
DataHandler dataHandler = message.getDataHandler();
MimeMultipart mimeMultipart = (MimeMultipart) dataHandler.getContent();
for (int k = 0; k < mimeMultipart.getCount(); k++) {
 BodyPart bodyPart = mimeMultipart.getBodyPart(k);
}

代码示例来源:origin: axis/axis

public void startElement(String namespace, String localName,
               String prefix, Attributes attributes,
               DeserializationContext context)
    throws SAXException {

    super.startElement(namespace, localName, prefix, attributes, context);

    if (getValue() instanceof DataHandler) {
      try {
        DataHandler dh = (DataHandler) getValue();
        setValue(dh.getContent());
      }
      catch (IOException ioe) {
      }
    }
  } // startElement
} // class PlainTextDataHandlerDeserializer

代码示例来源:origin: org.apache.axis/axis

public void startElement(String namespace, String localName,
               String prefix, Attributes attributes,
               DeserializationContext context)
    throws SAXException {

    super.startElement(namespace, localName, prefix, attributes, context);

    if (getValue() instanceof DataHandler) {
      try {
        DataHandler dh = (DataHandler) getValue();
        setValue(dh.getContent());
      }
      catch (IOException ioe) {
      }
    }
  } // startElement
} // class PlainTextDataHandlerDeserializer

代码示例来源:origin: wso2/wso2-synapse

public void testClonePartiallyWithAttachments() throws Exception {
  MessageContext origMc = new MessageContext();
  String contentId = origMc.addAttachment(new DataHandler("test", "text/html"));
  MessageContext newMc = MessageHelper.clonePartially(origMc);
  DataHandler dh = newMc.getAttachment(contentId);
  assertNotNull(dh);
  assertEquals("test", dh.getContent());
}

相关文章