/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
public String getPrimaryType() { return mimeType.getPrimaryType(); }
public static int countWildChars(MimeType m) { if (m.getPrimaryType().equals("*")) { return 2; } if (m.getSubType().equals("*")) { return 1; } return 0; }
private boolean isFormRequest(final MimeType contentType) { return "application".equals(contentType.getPrimaryType()) && "x-www-form-urlencoded".equals(contentType.getSubType()); }
private boolean isFormRequest(final MimeType contentType) { return "application".equals(contentType.getPrimaryType()) && "x-www-form-urlencoded".equals(contentType.getSubType()); }
public String getBaseType() { return getPrimaryType() + '/' + getSubType(); }
public String getBaseType() { return getPrimaryType() + '/' + getSubType(); }
public String getBaseType() { return getPrimaryType() + '/' + getSubType(); }
@Override public int compare(final MimeType a, final MimeType b) { final int p = a.getPrimaryType().compareTo(b.getPrimaryType()); return p != 0?p:compare(a.getSubType(), b.getSubType()); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Determine if the primary and sub type of this object is * the same as what is in the given type. * * @param type the MimeType object to compare with * @return true if they match */ public boolean match(MimeType type) { return primaryType.equals(type.getPrimaryType()) && (subType.equals("*") || type.getSubType().equals("*") || (subType.equals(type.getSubType()))); }
/** * Returns true if media type a matches application/xml, text/xml or application/*+xml */ public static boolean isXml(String a) { boolean answer = isMatch(Constants.XML_MEDIA_TYPE, a) || isMatch("text/xml", a); if (!answer) { try { MimeType mta = new MimeType(a); answer = (("application".equalsIgnoreCase(mta.getPrimaryType()) || "text".equalsIgnoreCase(mta .getPrimaryType())) && mta.getSubType().equals("xml") || mta.getSubType().endsWith("+xml")); } catch (Exception e) { } } return answer; }
String contentTypeInbound = message.getProperty("content-type", PropertyScope.INBOUND); MimeType mt = new MimeType(contentTypeInbound); String mimeType = mt.getPrimaryType() + "/" + mt.getSubType(); assertEquals(expectedMimeType, mimeType);
@Test public void testEncode_and_decode() { String encoded = value.toEncodedString(blob); assertEquals("myfile1.docx:application/vnd.ms-word:AQIDBA==", encoded); Blob decoded = value.fromEncodedString(encoded); assertThat(decoded.getName(), is("myfile1.docx")); assertThat(decoded.getMimeType().getPrimaryType(), is("application")); assertThat(decoded.getMimeType().getSubType(), is("vnd.ms-word")); assertThat(decoded.getBytes().length, is(4)); }
@Test public void testEncode_and_decode() { String encoded = value.toEncodedString(clob); assertEquals("myfile1.xml:application/xml:abcdef", encoded); Clob decoded = value.fromEncodedString(encoded); assertThat(decoded.getName(), is("myfile1.xml")); assertThat(decoded.getMimeType().getPrimaryType(), is("application")); assertThat(decoded.getMimeType().getSubType(), is("xml")); assertThat(decoded.getChars(), is((CharSequence)"abcdef")); }