MimeTypeUtils { public static boolean belongsTo(String mimeType, String otherType, String otherStructuredSyntaxSuffix) { String mediaParts[] = mimeType.split("/"); if (mediaParts.length != 2) { return false; } String type = mediaParts[0]; String subtype = mediaParts[1]; if (!type.equals(otherType)) { return false; } if (subtype.equals(otherStructuredSyntaxSuffix)) { return true; } String subtypeParts[] = subtype.split("\\+"); if (subtypeParts.length != 2) { return false; } String structuredSyntaxSuffix = subtypeParts[1]; return structuredSyntaxSuffix.equals(otherStructuredSyntaxSuffix); }  static boolean belongsTo(String mimeType, String otherType,
      String otherStructuredSyntaxSuffix); static String detect(File f); static String detect(File f, boolean gzip); static final String XML; static final String JSON; }
@Test public void testBelongsTo() { assertTrue(belongsTo("application/gml+xml", "application", "xml")); assertTrue(belongsTo("application/exp+xml", "application", "xml")); assertTrue(belongsTo("application/xml", "application", "xml")); assertFalse(belongsTo("application/exp+xml", "text", "xml")); assertFalse(belongsTo("application/exp+xml", "application", "json")); }