String charset = ct.getParameter("charset"); if (charset == null) return false;
cType.getParameter("charset") == null) {
String charset = ct.getParameter("charset"); if (charset == null) return false;
cType.getParameter("charset") == null) {
private String getCharset(String type) { try { ContentType ct = new ContentType(type); String charset = ct.getParameter("charset"); if (charset == null) // If the charset parameter is absent, use US-ASCII. charset = "us-ascii"; return MimeUtility.javaCharset(charset); } catch (Exception ex) { return null; } } }
private String getCharset(String type) { try { ContentType ct = new ContentType(type); String charset = ct.getParameter("charset"); if (charset == null) // If the charset parameter is absent, use US-ASCII. charset = "us-ascii"; return MimeUtility.javaCharset(charset); } catch (Exception ex) { return null; } } }
/** * Create a ByteArrayDataSource with data from the * specified String and with the specified MIME type. * The MIME type should include a <code>charset</code> * parameter specifying the charset to be used for the * string. If the parameter is not included, the * default charset is used. * * @param data the String * @param type the MIME type * @exception IOException errors reading the String */ public ByteArrayDataSource(String data, String type) throws IOException { String charset = null; try { ContentType ct = new ContentType(type); charset = ct.getParameter("charset"); } catch (ParseException pex) { // ignore parse error } charset = MimeUtility.javaCharset(charset); if (charset == null) charset = MimeUtility.getDefaultJavaCharset(); // XXX - could convert to bytes on demand rather than copying here this.data = data.getBytes(charset); this.type = type; }
/** * Create a ByteArrayDataSource with data from the * specified String and with the specified MIME type. * The MIME type should include a <code>charset</code> * parameter specifying the charset to be used for the * string. If the parameter is not included, the * default charset is used. * * @param data the String * @param type the MIME type * @exception IOException errors reading the String */ public ByteArrayDataSource(String data, String type) throws IOException { String charset = null; try { ContentType ct = new ContentType(type); charset = ct.getParameter("charset"); } catch (ParseException pex) { // ignore parse error } charset = MimeUtility.javaCharset(charset); if (charset == null) charset = MimeUtility.getDefaultJavaCharset(); // XXX - could convert to bytes on demand rather than copying here this.data = data.getBytes(charset); this.type = type; }
String boundary = null; if (!ignoreExistingBoundaryParameter) { String bp = cType.getParameter("boundary"); if (bp != null) boundary = "--" + bp;
String boundary = null; if (!ignoreExistingBoundaryParameter) { String bp = cType.getParameter("boundary"); if (bp != null) boundary = "--" + bp;
(new ContentType(contentType)).getParameter("boundary"); LineOutputStream los = new LineOutputStream(os);
(new ContentType(contentType)).getParameter("boundary"); LineOutputStream los = new LineOutputStream(os);
static String getFileName(MimePart part) throws MessagingException { String filename = null; String s = part.getHeader("Content-Disposition", null); if (s != null) { // Parse the header .. ContentDisposition cd = new ContentDisposition(s); filename = cd.getParameter("filename"); } if (filename == null) { // Still no filename ? Try the "name" ContentType parameter s = part.getHeader("Content-Type", null); s = MimeUtil.cleanContentType(part, s); if (s != null) { try { ContentType ct = new ContentType(s); filename = ct.getParameter("name"); } catch (ParseException pex) { } // ignore it } } if (decodeFileName && filename != null) { try { filename = MimeUtility.decodeText(filename); } catch (UnsupportedEncodingException ex) { throw new MessagingException("Can't decode filename", ex); } } return filename; }
static String getFileName(MimePart part) throws MessagingException { String filename = null; String s = part.getHeader("Content-Disposition", null); if (s != null) { // Parse the header .. ContentDisposition cd = new ContentDisposition(s); filename = cd.getParameter("filename"); } if (filename == null) { // Still no filename ? Try the "name" ContentType parameter s = part.getHeader("Content-Type", null); s = MimeUtil.cleanContentType(part, s); if (s != null) { try { ContentType ct = new ContentType(s); filename = ct.getParameter("name"); } catch (ParseException pex) { } // ignore it } } if (decodeFileName && filename != null) { try { filename = MimeUtility.decodeText(filename); } catch (UnsupportedEncodingException ex) { throw new MessagingException("Can't decode filename", ex); } } return filename; }
public String decode(ContentType contentType, byte[] message) throws Exception { String charset = contentType.getParameter("charset"); return new String(message, charset); } };
public String decode(ContentType contentType, byte[] message) throws Exception { String charset = contentType.getParameter("charset"); return new String(message, charset); } };
public static boolean isContentEnvelopedSignature(ContentType contentType) { if (contentType == null) throw new IllegalArgumentException(); return (SMIMEStandard.isContentCms(contentType) && contentType.getParameter(SMIMEStandard.SmimeTypeParameterKey) != null && contentType.getParameter(SMIMEStandard.SmimeTypeParameterKey).equals(SMIMEStandard.SignedDataSmimeType)); }
public String getFileName() throws MessagingException { String filename = bodyStructure.disposition.getParameter("filename"); if (filename == null) { filename = bodyStructure.mimeType.getParameter("name"); } return filename; }
private String getParameter(String name) { try { return new ContentType(contentType).getParameter(name); } catch (ParseException ex) { // MIMEResource objects are only defined as constants. Therefore we // will never get here under normal conditions. throw new Error(ex); } }
/** * Checks whether the input message is <code>format=flowed</code>. */ public static boolean isFlowedTextMessage(Message m) throws MessagingException { ContentType ct = new ContentType(m.getContentType()); String format = ct.getParameter("format"); return ct.getBaseType().equals("text/plain") && format != null && format.equalsIgnoreCase("flowed"); } }