当前位置: 首页>>代码示例>>Java>>正文


Java ContentType.getParameter方法代码示例

本文整理汇总了Java中javax.mail.internet.ContentType.getParameter方法的典型用法代码示例。如果您正苦于以下问题:Java ContentType.getParameter方法的具体用法?Java ContentType.getParameter怎么用?Java ContentType.getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.mail.internet.ContentType的用法示例。


在下文中一共展示了ContentType.getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRegularPartCharset

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
/**
 * Get the character set of a regular part
 *
 * @param partIndex
 *            the index of the part
 * @return the charset
 * @throws PackageException
 */
@PublicAtsApi
public String getRegularPartCharset(
                                     int partIndex ) throws PackageException {

    // first check if there is part at this position at all
    if (partIndex >= regularPartIndices.size()) {
        throw new NoSuchMimePartException("No regular part at position '" + partIndex + "'");
    }

    try {
        MimePart part = getPart(regularPartIndices.get(partIndex));

        // get the content type header
        ContentType contentType = new ContentType(part.getContentType());
        return contentType.getParameter("charset");
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:28,代码来源:MimePackage.java

示例2: getAttachmentCharset

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
/**
 * Get the attachment character set
 *
 * @param partIndex
 *            the index of the attachment
 * @return the character set for this attachment, null if there is no such
 * @throws PackageException
 */
@PublicAtsApi
public String getAttachmentCharset(
                                    int partIndex ) throws PackageException {

    // first check if there is part at this position at all
    if (partIndex >= attachmentPartIndices.size()) {
        throw new NoSuchMimePartException("No attachment at position '" + partIndex + "'");
    }

    try {
        MimePart part = getPart(attachmentPartIndices.get(partIndex));

        // get the content type header
        ContentType contentType = new ContentType(part.getContentType());
        return contentType.getParameter("charset");
    } catch (MessagingException me) {
        throw new PackageException(me);
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:28,代码来源:MimePackage.java

示例3: processDocument

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
public OMElement processDocument(Reader reader, String contentType,
                                 MessageContext messageContext) throws AxisFault {
    String charset;
    try {
        ContentType ct = new ContentType(contentType);
        charset = ct.getParameter("charset");
    } catch (ParseException ex) {
        charset = null;
    }
    if (charset == null) {
        charset = MessageContext.DEFAULT_CHAR_SET_ENCODING;
    }
    messageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charset);        
    return processDocument(new ReaderInputStream(reader, charset), contentType,
            messageContext);
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:17,代码来源:TextMessageBuilderAdapter.java

示例4: getTextContent

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
/**
 * Extract the text content for a {@link BodyPart}, assuming the default
 * encoding.
 */
public static String getTextContent(BodyPart part) throws MessagingException, IOException {
  ContentType contentType = new ContentType(part.getContentType());
  String charset = contentType.getParameter("charset");
  if (charset == null) {
    // N.B.(schwardo): The MIME spec doesn't seem to provide a
    // default charset, but the default charset for HTTP is
    // ISO-8859-1.  That seems like a reasonable default.
    charset = "ISO-8859-1";
  }

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ByteStreams.copy(part.getInputStream(), baos);
  try {
    return new String(baos.toByteArray(), charset);
  } catch (UnsupportedEncodingException ex) {
    return new String(baos.toByteArray());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:23,代码来源:MultipartMimeUtils.java

示例5: handleInbound

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
@Override
public boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   ContentType contentType = getContentType(msgContext);

   if (contentType != null)
   {
      log.info("contentType="+contentType);
      String startInfo = contentType.getParameter("start-info");
      if (!startInfo.equals(SOAPConstants.SOAP_1_1_CONTENT_TYPE))
      {
         return false;
      }
   }
   else
   {
      return false;
   }
   try
   {
      SOAPEnvelope soapEnvelope = ((SOAPMessageContext)msgContext).getMessage().getSOAPPart().getEnvelope();
      String nsURI = soapEnvelope.getNamespaceURI();

      log.info("nsURI=" + nsURI);

      if (!SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(nsURI))
      {
         return false;
      }
   }
   catch (SOAPException se)
   {
      throw new WebServiceException(se);
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:40,代码来源:SOAP11ServerHandler.java

示例6: handleInbound

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
@Override
public boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   ContentType contentType = getContentType(msgContext);

   if (contentType != null)
   {
      log.info("contentType="+contentType);
      String startInfo = contentType.getParameter("start-info");
      if (!startInfo.equals(SOAPConstants.SOAP_1_2_CONTENT_TYPE))
      {
         return false;
      }
   }
   else
   {
      return false;
   }
   try
   {
      SOAPEnvelope soapEnvelope = ((SOAPMessageContext)msgContext).getMessage().getSOAPPart().getEnvelope();
      String nsURI = soapEnvelope.getNamespaceURI();

      log.info("nsURI=" + nsURI);

      if (!SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(nsURI))
      {
         return false;
      }
   }
   catch (SOAPException se)
   {
      throw new WebServiceException(se);
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:40,代码来源:SOAP12ServerHandler.java

示例7: handleInbound

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
@Override
public boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPEnvelope soapEnvelope = msgContext.getMessage().getSOAPPart().getEnvelope();
      String nsURI = soapEnvelope.getNamespaceURI();

      log.info("nsURI=" + nsURI);

      if (!SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(nsURI))
      {
         return false;
      }
   }
   catch (SOAPException se)
   {
      throw new WebServiceException(se);
   }

   ContentType contentType = getContentType(msgContext);

   if (contentType != null)
   {
      log.info("contentType="+contentType);
      String startInfo = contentType.getParameter("start-info");
      if (!startInfo.equals(SOAPConstants.SOAP_1_1_CONTENT_TYPE))
      {
         return false;
      }
   }
   else
   {
      return false;
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:41,代码来源:SOAP11ClientHandler.java

示例8: handleInbound

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
@Override
public boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPEnvelope soapEnvelope = msgContext.getMessage().getSOAPPart().getEnvelope();
      String nsURI = soapEnvelope.getNamespaceURI();

      log.info("nsURI=" + nsURI);

      if (!SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(nsURI))
      {
         return false;
      }
   }
   catch (SOAPException se)
   {
      throw new WebServiceException(se);
   }

   ContentType contentType = getContentType(msgContext);

   if (contentType != null)
   {
      log.info("contentType="+contentType);
      String startInfo = contentType.getParameter("start-info");
      if (!startInfo.equals(SOAPConstants.SOAP_1_2_CONTENT_TYPE))
      {
         return false;
      }
   }
   else
   {
      return false;
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:41,代码来源:SOAP12ClientHandler.java

示例9: charsetFromMime

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private static String charsetFromMime(String mime) {
  String charset;
  try {
    ContentType parsedType = new ContentType(mime);
    charset = parsedType.getParameter("charset");
  } catch (ParseException e) {
    charset = null;
  }
  if (null == charset || "".equals(charset)) {
    return DATA_URI_DEFAULT_CHARSET;
  } else {
    return charset;
  }
}
 
开发者ID:google,项目名称:caja,代码行数:15,代码来源:DataUriFetcher.java

示例10: outputPostamble

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
static void outputPostamble(LineOutputStream lOut, BodyPart parent, String parentBoundary, BodyPart part)
    throws MessagingException, IOException
{
    InputStream in;

    try
    {
        in = ((MimeBodyPart)parent).getRawInputStream();
    }
    catch (MessagingException e)
    {
        return;   // no underlying content rely on default generation
    }


    MimeMultipart multipart = (MimeMultipart)part.getContent();
    ContentType contentType = new ContentType(multipart.getContentType());
    String boundary = "--" + contentType.getParameter("boundary");
    int count = multipart.getCount() + 1;
    String line;
    while (count != 0 && (line = readLine(in)) != null)
    {
        if (line.startsWith(boundary))
        {
            count--;
        }
    }

    while ((line = readLine(in)) != null)
    {
        if (line.startsWith(parentBoundary))
        {
            break;
        }
        lOut.writeln(line);
    }

    in.close();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:40,代码来源:SMIMEUtil.java

示例11: getParameter

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
/**
 * Returns the value of the parameter with the specified name in the
 * specified content type
 * @param  type the content type
 * @param  name the name of the parameter
 * @return the value of the parameter, or <code>null</code> if
 *          not specified
 * @throws ParseException if parsing failed
 */
public static String getParameter(String type, String name)
        throws ParseException {
    if (type == null)
        throw new NullPointerException("null Content-Type");
    else if (name == null)
        throw new NullPointerException("null parameter name");

    ContentType obj = new ContentType(type);
    return obj.getParameter(name);
}
 
开发者ID:rogersuen,项目名称:jmp,代码行数:20,代码来源:ContentTypeUtil.java

示例12: handleInbound

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
public boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPEnvelope soapEnvelope = (SOAPEnvelope)msgContext.getMessage().getSOAPPart().getEnvelope();
      String nsURI = soapEnvelope.getNamespaceURI();

      log.info("nsURI=" + nsURI);

      if (!SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(nsURI))
      {
         throw new RuntimeException("Wrong NS uri: " + nsURI);
      }
   }
   catch (SOAPException se)
   {
      throw new WebServiceException(se);
   }

   ContentType contentType = getContentType(msgContext);

   if (contentType != null)
   {
      log.info("contentType="+contentType);
      String startInfo = contentType.getParameter("start-info");
      if (!checkMtom) {
         if (startInfo != null) {
            throw new RuntimeException("Unexpected multipart/related message!");
         } else {
            return true;
         }
      }
      if (!startInfo.equals(SOAPConstants.SOAP_1_1_CONTENT_TYPE))
      {
         throw new RuntimeException("Wrong start info: " + startInfo);
      }
   }
   else
   {
      throw new RuntimeException("Missing content type");
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:47,代码来源:ClientHandler.java

示例13: decode

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
public String decode(ContentType contentType, byte[] message) throws Exception {
    String charset = contentType.getParameter("charset");
    return new String(message, charset);
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:5,代码来源:MessageDecoder.java

示例14: doFilter

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
    throws IOException, ServletException {
  HttpServletRequest req = (HttpServletRequest) request;
  if (req.getHeader(UPLOAD_HEADER) != null) {
    Map<String, List<String>> blobKeys = new HashMap<String, List<String>>();
    Map<String, List<Map<String, String>>> blobInfos =
        new HashMap<String, List<Map<String, String>>>();
    Map<String, List<String>> otherParams = new HashMap<String, List<String>>();

    try {
      MimeMultipart multipart = MultipartMimeUtils.parseMultipartRequest(req);

      int parts = multipart.getCount();
      for (int i = 0; i < parts; i++) {
        BodyPart part = multipart.getBodyPart(i);
        String fieldName = MultipartMimeUtils.getFieldName(part);
        if (part.getFileName() != null) {
          ContentType contentType = new ContentType(part.getContentType());
          if ("message/external-body".equals(contentType.getBaseType())) {
            String blobKeyString = contentType.getParameter("blob-key");
            List<String> keys = blobKeys.get(fieldName);
            if (keys == null) {
              keys = new ArrayList<String>();
              blobKeys.put(fieldName, keys);
            }
            keys.add(blobKeyString);
            List<Map<String, String>> infos = blobInfos.get(fieldName);
            if (infos == null) {
              infos = new ArrayList<Map<String, String>>();
              blobInfos.put(fieldName, infos);
            }
            infos.add(getInfoFromBody(MultipartMimeUtils.getTextContent(part), blobKeyString));
          }
        } else {
          List<String> values = otherParams.get(fieldName);
          if (values == null) {
            values = new ArrayList<String>();
            otherParams.put(fieldName, values);
          }
          values.add(MultipartMimeUtils.getTextContent(part));
        }
      }
      req.setAttribute(UPLOADED_BLOBKEY_ATTR, blobKeys);
      req.setAttribute(UPLOADED_BLOBINFO_ATTR, blobInfos);
    } catch (MessagingException ex) {
      logger.log(Level.WARNING, "Could not parse multipart message:", ex);
    }

    chain.doFilter(new ParameterServletWrapper(request, otherParams), response);
  } else {
    chain.doFilter(request, response);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:54,代码来源:ParseBlobUploadFilter.java

示例15: writeBodyPart

import javax.mail.internet.ContentType; //导入方法依赖的package包/类
private void writeBodyPart(
    OutputStream out,
    MimeBodyPart bodyPart)
    throws IOException, MessagingException
{
    if (bodyPart.getContent() instanceof Multipart)
    {
        Multipart mp = (Multipart)bodyPart.getContent();
        ContentType contentType = new ContentType(mp.getContentType());
        String boundary = "--" + contentType.getParameter("boundary");

        SMIMEUtil.LineOutputStream lOut = new SMIMEUtil.LineOutputStream(out);

        Enumeration headers = bodyPart.getAllHeaderLines();
        while (headers.hasMoreElements())
        {
            lOut.writeln((String)headers.nextElement());
        }

        lOut.writeln();      // CRLF separator

        SMIMEUtil.outputPreamble(lOut, bodyPart, boundary);

        for (int i = 0; i < mp.getCount(); i++)
        {
            lOut.writeln(boundary);
            writeBodyPart(out, (MimeBodyPart)mp.getBodyPart(i));
            lOut.writeln();       // CRLF terminator
        }
        
        lOut.writeln(boundary + "--");
    }
    else
    {
        if (SMIMEUtil.isCanonicalisationRequired(bodyPart, defaultContentTransferEncoding))
        {
            out = new CRLFOutputStream(out);
        }

        bodyPart.writeTo(out);
    }
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:43,代码来源:SMIMESignedGenerator.java


注:本文中的javax.mail.internet.ContentType.getParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。