Lines Matching defs:is

5  * This code is free software; you can redistribute it and/or modify it
11 * This code is distributed in the hope that it will be useful, but WITHOUT
14 * version 2 for more details (a copy is included in the LICENSE file that
45 * This is a utility class that provides various MIME related
49 * per RFC 2047. A brief description on handling such headers is
58 * In Java, Strings contain (16 bit) Unicode characters. ASCII is a
60 * that contains only ASCII characters is already mail-safe. If the
62 * additional complexity in this step is that since Unicode is not
94 * If the <code>mail.mime.decodetext.strict</code> System property is
96 * illegal encoded words. The default is true. <p>
101 * an encoding that allows normal end of line conventions is appropriate.
105 * System property is set to <code>"true"</code>, such an encoding will
106 * be used when necessary. The default is false. <p>
111 * default MIME charset is derived from the default Java charset, as
115 * mail messages is different than the charset used for files stored on
160 * The algorithm used here is: <br>
163 * If the primary type of this datasource is "text" and if all
165 * is "7bit". If more than half of the bytes are non-US-ASCII, then
166 * the encoding is "base64". If less than half of the bytes are
167 * non-US-ASCII, then the encoding is "quoted-printable".
169 * If the primary type of this datasource is not "text", then if
171 * is "7bit". If there is even one non-US-ASCII character, the
172 * encoding is "base64".
176 * @return the encoding. This is either "7bit",
181 InputStream is = null;
186 is = ds.getInputStream();
193 int i = checkAscii(is, ALL, !isText);
208 is.close();
217 * <code>writeTo</code> method to examine the data. This is more
220 * "text/plain" String) because all the I/O is done in this
234 * the getEncoding(DataSource) method is typically faster. If
235 * the DataHandler was created with an object, this method is
241 * XXX - This is actually quite a disgusting hack, but it makes
288 * Decode the given input stream. The Input stream returned is
291 * "7bit", "8bit", and "binary". In addition, "uuencode" is also
294 * @param is input stream
298 public static InputStream decode(InputStream is, String encoding)
301 return new BASE64DecoderStream(is);
303 return new QPDecoderStream(is);
307 return new UUDecoderStream(is);
311 return is;
320 * "binary". In addition, "uuencode" is also supported.
351 * "binary". In addition, "uuencode" is also supported.
352 * The <code>filename</code> parameter is used with the "uuencode"
353 * encoding and is included in the encoded output.
388 * The given Unicode string is examined for non US-ASCII
390 * it is returned as-is. If the string contains non US-ASCII
391 * characters, it is first character-encoded using the platform's
429 * The given Unicode string is examined for non US-ASCII
431 * it is returned as-is. If the string contains non US-ASCII
432 * characters, it is first character-encoded using the specified
441 * @param charset the charset. If this parameter is null, the
442 * platform's default chatset is used.
444 * values are "B" and "Q". If this parameter is null, then
445 * the "Q" encoding is used if most of characters to be
447 * is used.
457 * Decode "unstructured" headers, that is, headers that are defined
460 * The string is decoded using the algorithm specified in
462 * for any sequence, an UnsupportedEncodingException is thrown.
463 * If the String is not an RFC 2047 style encoded header, it is
464 * returned as-is <p>
502 * return the string as-is, without suffering thru the later
525 // Check if token is an 'encoded-word' ..
538 // This is NOT an 'encoded-word'.
559 * The given Unicode string is examined for non US-ASCII
561 * it is returned as-is. If the string contains non US-ASCII
562 * characters, it is first character-encoded using the platform's
567 * This method is meant to be used when creating RFC 822 "phrases".
585 * The given Unicode string is examined for non US-ASCII
587 * it is returned as-is. If the string contains non US-ASCII
588 * characters, it is first character-encoded using the specified
596 * values are "B" and "Q". If this parameter is null, then
597 * the "Q" encoding is used if most of characters to be
599 * is used.
611 * be true if a RFC 822 "word" token is being encoded and false if a
612 * RFC 822 "text" token is being encoded. This is because the
634 // If no transfer-encoding is specified, figure one out.
679 // If the length is greater than 'avail', split 'string'
716 * The string is parsed using the rules in RFC 2047 for parsing
717 * an "encoded-word". If the parse fails, a ParseException is
718 * thrown. Otherwise, it is transfer-decoded, and then
720 * fails, an UnsupportedEncodingException is thrown.<p>
723 * @exception ParseException if the string is not an
758 InputStream is;
760 is = new BASE64DecoderStream(bis);
762 is = new QDecoderStream(bis);
769 // is certainly more efficient than writing bytes into a
774 // count is set to the actual number of decoded bytes
775 count = is.read(bytes, 0, count);
844 * This method is typically used during the generation of
896 * Fold a string at linear whitespace so that each line is no longer
898 * non-whitespace characters consecutively, the string is folded at
901 * the current line; it is usually the length of the header name. <p>
1046 * @return the Java charset equivalent. If a suitable mapping is
1047 * not available, the passed in charset is itself returned.
1051 // no mapping table, or charset parameter is null
1067 * is not possible, the passed in charset itself
1068 * is returned.
1073 // no mapping table or charset param is null
1086 * is set, a system charset corresponding to this MIME charset will be
1096 * If mail.mime.charset is set, it controls the default
1153 InputStream is =
1157 if (is != null) {
1158 is = new LineInputStream(is);
1161 loadMappings((LineInputStream)is, java2mime);
1164 loadMappings((LineInputStream)is, mime2java);
1232 private static void loadMappings(LineInputStream is, Hashtable table) {
1237 currLine = is.readLine();
1252 // A valid entry is of the form <key><separator><value>
1302 * XXX - this method is no longer used
1310 // so that the resulting value is not a negative integer.
1327 * Upto <code>max</code> bytes are checked. If <code>max</code> is
1329 * input stream are checked. If <code>breakOnNonAscii</code> is true
1330 * the check terminates when the first non-US-ASCII character is
1331 * found and MOSTLY_NONASCII is returned. Else, the check continues
1334 * @param is the input stream
1340 * is found.
1346 static int checkAscii(InputStream is, int max, boolean breakOnNonAscii) {
1360 if ((len = is.read(buf, 0, block)) == -1)
1366 // bytes in the int so that the resulting value is
1400 // cannot say for sure that this input stream is ALL_ASCII,
1430 * it is all ASCII, mostly ASCII, or mostly non-ASCII.