381
382 return (encoding != null) ? encoding : getDefaultTextCharset();
383 }
384
385 /**
386 * Returns the platform's default character encoding.
387 */
388 public static String getDefaultTextCharset() {
389 if (defaultEncoding != null) {
390 return defaultEncoding;
391 }
392 return defaultEncoding = Charset.defaultCharset().name();
393 }
394
395 /**
396 * Tests only whether the flavor's MIME type supports the charset
397 * parameter. Must only be called for flavors with a primary type of
398 * "text".
399 */
400 public static boolean doesSubtypeSupportCharset(DataFlavor flavor) {
401 if (dtLog.isLoggable(PlatformLogger.FINE)) {
402 if (!"text".equals(flavor.getPrimaryType())) {
403 dtLog.fine("Assertion (\"text\".equals(flavor.getPrimaryType())) failed");
404 }
405 }
406
407 String subType = flavor.getSubType();
408 if (subType == null) {
409 return false;
410 }
411
412 Object support = textMIMESubtypeCharsetSupport.get(subType);
413
414 if (support != null) {
415 return (support == Boolean.TRUE);
416 }
417
418 boolean ret_val = (flavor.getParameter("charset") != null);
419 textMIMESubtypeCharsetSupport.put
420 (subType, (ret_val) ? Boolean.TRUE : Boolean.FALSE);
421 return ret_val;
|
381
382 return (encoding != null) ? encoding : getDefaultTextCharset();
383 }
384
385 /**
386 * Returns the platform's default character encoding.
387 */
388 public static String getDefaultTextCharset() {
389 if (defaultEncoding != null) {
390 return defaultEncoding;
391 }
392 return defaultEncoding = Charset.defaultCharset().name();
393 }
394
395 /**
396 * Tests only whether the flavor's MIME type supports the charset
397 * parameter. Must only be called for flavors with a primary type of
398 * "text".
399 */
400 public static boolean doesSubtypeSupportCharset(DataFlavor flavor) {
401 if (dtLog.isLoggable(PlatformLogger.Level.FINE)) {
402 if (!"text".equals(flavor.getPrimaryType())) {
403 dtLog.fine("Assertion (\"text\".equals(flavor.getPrimaryType())) failed");
404 }
405 }
406
407 String subType = flavor.getSubType();
408 if (subType == null) {
409 return false;
410 }
411
412 Object support = textMIMESubtypeCharsetSupport.get(subType);
413
414 if (support != null) {
415 return (support == Boolean.TRUE);
416 }
417
418 boolean ret_val = (flavor.getParameter("charset") != null);
419 textMIMESubtypeCharsetSupport.put
420 (subType, (ret_val) ? Boolean.TRUE : Boolean.FALSE);
421 return ret_val;
|