@Test public void isTextLike() { boolean actual = ContentTypes.isTextLike(testCase.contentType); String message = String.format("expect text-like %s for \"%s\"", testCase.expected, StringEscapeUtils.escapeJava(testCase.contentType)); System.out.format("%s; actual = %s%n", message, actual); assertEquals(message, testCase.expected, actual); try { if (testCase.contentType != null) { boolean actualWithoutParams = ContentTypes.isTextLike(MediaType.parse(testCase.contentType).toString()); assertEquals(message + " without parameters", testCase.expected, actualWithoutParams); } } catch (IllegalArgumentException ignore) { } }
public static boolean isTextLike(@Nullable String contentType) { if (contentType == null) { return false; } MediaType mime = null; try { mime = MediaType.parse(contentType).withoutParameters(); } catch (IllegalArgumentException e) { log.debug("failed to parse mime type from {}", contentType); } if (mime != null) { if (mime.is(MediaType.ANY_TEXT_TYPE)) { return true; } if (isSubtypeXmlish(mime)) { return true; } if (isSubtypeJsonish(mime)) { return true; } if (TEXT_LIKE_TYPES.contains(mime)) { return true; } } return false; }
ContentTypes { public static boolean isTextLike(@Nullable String contentType) { if (contentType == null) { return false; } MediaType mime = null; try { mime = MediaType.parse(contentType).withoutParameters(); } catch (IllegalArgumentException e) { log.debug("failed to parse mime type from {}", contentType); } if (mime != null) { if (mime.is(MediaType.ANY_TEXT_TYPE)) { return true; } if (isSubtypeXmlish(mime)) { return true; } if (isSubtypeJsonish(mime)) { return true; } if (TEXT_LIKE_TYPES.contains(mime)) { return true; } } return false; } }
ContentTypes { public static boolean isTextLike(@Nullable String contentType) { if (contentType == null) { return false; } MediaType mime = null; try { mime = MediaType.parse(contentType).withoutParameters(); } catch (IllegalArgumentException e) { log.debug("failed to parse mime type from {}", contentType); } if (mime != null) { if (mime.is(MediaType.ANY_TEXT_TYPE)) { return true; } if (isSubtypeXmlish(mime)) { return true; } if (isSubtypeJsonish(mime)) { return true; } if (TEXT_LIKE_TYPES.contains(mime)) { return true; } } return false; } private  ContentTypes(); }
ContentTypes { public static boolean isTextLike(@Nullable String contentType) { if (contentType == null) { return false; } MediaType mime = null; try { mime = MediaType.parse(contentType).withoutParameters(); } catch (IllegalArgumentException e) { log.debug("failed to parse mime type from {}", contentType); } if (mime != null) { if (mime.is(MediaType.ANY_TEXT_TYPE)) { return true; } if (isSubtypeXmlish(mime)) { return true; } if (isSubtypeJsonish(mime)) { return true; } if (TEXT_LIKE_TYPES.contains(mime)) { return true; } } return false; } private  ContentTypes(); static boolean isTextLike(@Nullable String contentType); }
ContentTypes { public static boolean isTextLike(@Nullable String contentType) { if (contentType == null) { return false; } MediaType mime = null; try { mime = MediaType.parse(contentType).withoutParameters(); } catch (IllegalArgumentException e) { log.debug("failed to parse mime type from {}", contentType); } if (mime != null) { if (mime.is(MediaType.ANY_TEXT_TYPE)) { return true; } if (isSubtypeXmlish(mime)) { return true; } if (isSubtypeJsonish(mime)) { return true; } if (TEXT_LIKE_TYPES.contains(mime)) { return true; } } return false; } private  ContentTypes(); static boolean isTextLike(@Nullable String contentType);  }