static String getDefaultMIMECharset() { if (defaultMIMECharset == null) { try { defaultMIMECharset = System.getProperty("mail.mime.charset"); } catch (SecurityException ex) { } // ignore it } if (defaultMIMECharset == null) defaultMIMECharset = mimeCharset(getDefaultJavaCharset()); return defaultMIMECharset; }
/** * Gets the encoding set for this handler, mime encoding, or file encoding. * @return the java charset name, never null. * @since JavaMail 1.4.5 */ private String getEncodingName() { String charset = getEncoding(); if (charset == null) { charset = MimeUtility.getDefaultJavaCharset(); } return charset; }
/** * Gets the encoding set for this handler, mime encoding, or file encoding. * @return the java charset name, never null. * @since JavaMail 1.4.5 */ private String getEncodingName() { String charset = getEncoding(); if (charset == null) { charset = MimeUtility.getDefaultJavaCharset(); } return charset; }
static String getDefaultMIMECharset() { if (defaultMIMECharset == null) { try { defaultMIMECharset = System.getProperty("mail.mime.charset"); } catch (SecurityException ex) { } // ignore it } if (defaultMIMECharset == null) defaultMIMECharset = mimeCharset(getDefaultJavaCharset()); return defaultMIMECharset; }
/** * Constructor for debugging. * * @param in the InputStream from which to read * @param out the PrintStream to which to write * @param props Properties object used by this protocol * @param debug true to enable debugging output * @exception IOException for I/O errors */ public IMAPProtocol(InputStream in, PrintStream out, Properties props, boolean debug) throws IOException { super(in, out, props, debug); this.name = "imap"; noauthdebug = !PropUtil.getBooleanProperty(props, "mail.debug.auth", false); if (capabilities == null) capabilities = new HashMap<String, String>(); searchCharsets = new String[2]; // 2, for now. searchCharsets[0] = "UTF-8"; searchCharsets[1] = MimeUtility.mimeCharset( MimeUtility.getDefaultJavaCharset() ); connected = true; // must be last statement in constructor }
/** * Constructor for debugging. * * @param in the InputStream from which to read * @param out the PrintStream to which to write * @param props Properties object used by this protocol * @param debug true to enable debugging output * @exception IOException for I/O errors */ public IMAPProtocol(InputStream in, PrintStream out, Properties props, boolean debug) throws IOException { super(in, out, props, debug); this.name = "imap"; noauthdebug = !PropUtil.getBooleanProperty(props, "mail.debug.auth", false); if (capabilities == null) capabilities = new HashMap<>(); searchCharsets = new String[2]; // 2, for now. searchCharsets[0] = "UTF-8"; searchCharsets[1] = MimeUtility.mimeCharset( MimeUtility.getDefaultJavaCharset() ); connected = true; // must be last statement in constructor }
jcharset = getDefaultJavaCharset(); // the java charset
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuffer sb = new StringBuffer(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
jcharset = getDefaultJavaCharset(); // the java charset
/** * A special wrapper for a StringBuffer that keeps track of the * number of characters used in a line, wrapping to a new line * as necessary; for use by the toString method. */ private static class ToStringBuffer { private int used; // keep track of how much used on current line private StringBuilder sb = new StringBuilder(); public ToStringBuffer(int used) { this.used = used; } public void addNV(String name, String value) { sb.append("; "); used += 2; int len = name.length() + value.length() + 1; if (used + len > 76) { // overflows ... sb.append("\r\n\t"); // .. start new continuation line used = 8; // account for the starting <tab> char } sb.append(name).append('='); used += name.length() + 1; if (used + value.length() > 76) { // still overflows ... // have to fold value String s = MimeUtility.fold(used, value); sb.append(s); int lastlf = s.lastIndexOf('\n'); if (lastlf >= 0) // always true used += s.length() - lastlf - 1;
/** * 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; }
charset = MimeUtility.javaCharset(charset); if (charset == null || charset.length() == 0) charset = MimeUtility.getDefaultJavaCharset(); if (charset != null) mv.value = bos.toString(charset);
charset = MimeUtility.javaCharset(charset); if (charset == null || charset.length() == 0) charset = MimeUtility.getDefaultJavaCharset(); if (charset != null) mv.value = bos.toString(charset);
searchCharsets[0] = "UTF-8"; searchCharsets[1] = MimeUtility.mimeCharset( MimeUtility.getDefaultJavaCharset() );
searchCharsets[0] = "UTF-8"; searchCharsets[1] = MimeUtility.mimeCharset( MimeUtility.getDefaultJavaCharset() );
static String getDefaultMIMECharset() { if (defaultMIMECharset == null) { try { defaultMIMECharset = System.getProperty("mail.mime.charset"); } catch (SecurityException ex) { } // ignore it } if (defaultMIMECharset == null) defaultMIMECharset = mimeCharset(getDefaultJavaCharset()); return defaultMIMECharset; }
static String getDefaultMIMECharset() { if (defaultMIMECharset == null) { try { defaultMIMECharset = System.getProperty("mail.mime.charset"); } catch (SecurityException ex) { } // ignore it } if (defaultMIMECharset == null) defaultMIMECharset = mimeCharset(getDefaultJavaCharset()); return defaultMIMECharset; }
static String getDefaultMIMECharset() { if (defaultMIMECharset == null) { try { defaultMIMECharset = System.getProperty("mail.mime.charset"); } catch (SecurityException ex) { } // ignore it } if (defaultMIMECharset == null) defaultMIMECharset = mimeCharset(getDefaultJavaCharset()); return defaultMIMECharset; }
/** * Gets the encoding set for this handler, mime encoding, or file encoding. * @return the java charset name, never null. * @since JavaMail 1.4.5 */ private String getEncodingName() { String charset = getEncoding(); if (charset == null) { charset = MimeUtility.getDefaultJavaCharset(); } return charset; }