Package javax.mail.internet

Examples of javax.mail.internet.ContentType


     * @param reportType
     * @throws MessagingException
     */
    public void setReportType(String reportType) throws MessagingException
    {
        ContentType contentType = new ContentType(getContentType());
        contentType.setParameter("report-type", reportType);
        setContentType(contentType);
    }
View Full Code Here


    protected String getCharacterSet(String aType)
    {
        String characterSet = null;
        try
        {
            characterSet = new ContentType(aType).getParameter("charset");
        }
        catch (ParseException e)
        {
            // no-op
        }
View Full Code Here

        StringBuilder sb = new StringBuilder();
        Object content = message.getContent(); // throws ME
        if (content instanceof Multipart) {
            Multipart multipart = (Multipart) content;
            String contentType = multipart.getContentType();
            ContentType ct = new ContentType(contentType);
            String boundary=ct.getParameter("boundary");
            for (int i = 0; i < multipart.getCount(); i++) { // throws ME
                sb.append("--");
                sb.append(boundary);
                sb.append("\n");
                BodyPart bodyPart = multipart.getBodyPart(i); // throws ME
View Full Code Here

                                                                                          IOException,
                                                                                          ExtractorException {
        if (msg.isMimeType("text/plain")) {
            processContent(msg.getContent(), buffer, rdf);
        } else if (msg.isMimeType("text/html")) {
            String encoding = getContentEncoding(new ContentType(msg.getContentType()));
            logger.debug("HTML encoding: {}", encoding);
            if (msg.getContent() instanceof String) {
                String text = extractTextFromHtml(((String) msg.getContent()).trim(), encoding, rdf);
                rdf.add(NMO.htmlMessageContent, (String) msg.getContent());
                processContent(text, buffer, rdf);
View Full Code Here

                    if (encoding != null) {
                        m.addStatement(attachURI, NFO.encoding, encoding);
                    }
                }
                if (contentType != null) {
                    contentType = (new ContentType(contentType)).getBaseType();
                    m.addStatement(attachURI, NIE.mimeType, contentType.trim());
                }
                // TODO: encoding?
            }
           
            // append the content, if any
            content = bodyPart.getContent();
           
            // remove any html markup if necessary
            if (contentType != null && content instanceof String) {
                contentType = contentType.toLowerCase();
                if (contentType.indexOf("text/html") >= 0) {
                    if (encoding != null) {
                        encoding = MimeUtility.javaCharset(encoding);
                    }
                    content = extractTextFromHtml((String) content, encoding, rdf);
                }
            }
           
            processContent(content, buffer, rdf);
        } else if (content instanceof Multipart) {
            Multipart multipart = (Multipart) content;
            String subType = null;
           
            String contentType = multipart.getContentType();
            if (contentType != null) {
                ContentType ct = new ContentType(contentType);
                subType = ct.getSubType();
                if (subType != null) {
                    subType = subType.trim().toLowerCase();
                }
            }
           
View Full Code Here

    }
   
    protected String getMimeType(Part mailPart) throws MessagingException {
        String contentType = mailPart.getContentType();
        if (contentType != null) {
            ContentType ct = new ContentType(contentType);
            return ct.getBaseType();
        }
       
        return null;
    }
View Full Code Here

        StringBuilder sb = new StringBuilder();
        Object content = message.getContent(); // throws ME
        if (content instanceof Multipart) {
            Multipart multipart = (Multipart) content;
            String contentType = multipart.getContentType();
            ContentType ct = new ContentType(contentType);
            String boundary=ct.getParameter("boundary");
            for (int i = 0; i < multipart.getCount(); i++) { // throws ME
                sb.append("--");
                sb.append(boundary);
                sb.append("\n");
                BodyPart bodyPart = multipart.getBodyPart(i); // throws ME
View Full Code Here

     *             if an error occurs while processing the content type information from the
     *             {@link Attachments} object
     */
    public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory,
            StAXParserConfiguration configuration, Attachments attachments) {
        ContentType contentType;
        try {
            contentType = new ContentType(attachments.getRootPartContentType());
        } catch (ParseException ex) {
            throw new OMException(ex);
        }
        InputSource rootPart = getRootPartInputSource(attachments, contentType);
        return omFactory.getMetaFactory().createOMBuilder(configuration, omFactory,
View Full Code Here

     *             if an error occurs while processing the content type information from the
     *             {@link Attachments} object
     */
    public static SOAPModelBuilder createSOAPModelBuilder(OMMetaFactory metaFactory,
            Attachments attachments) {
        ContentType contentType;
        try {
            contentType = new ContentType(attachments.getRootPartContentType());
        } catch (ParseException ex) {
            throw new OMException(ex);
        }
        String type = contentType.getParameter("type");
        SOAPFactory soapFactory;
        if ("text/xml".equalsIgnoreCase(type)) {
            soapFactory = metaFactory.getSOAP11Factory();
        } else if ("application/soap+xml".equalsIgnoreCase(type)) {
            soapFactory = metaFactory.getSOAP12Factory();
View Full Code Here

  }
    }

    private boolean isXmlType(String type) {
  try {
      ContentType ct = new ContentType(type);
      return ct.getSubType().equals("xml") &&
        (ct.getPrimaryType().equals("text") ||
        ct.getPrimaryType().equals("application"));
  } catch (Exception ex) {
      return false;
  }
    }
View Full Code Here

TOP

Related Classes of javax.mail.internet.ContentType

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.