/** * 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()))); }
private boolean wildcard(final MimeType type) { return type.getSubType().equals("*"); }
/** * Compare two media types according to their relative level of specificity */ public static int compare(MimeType mt1, MimeType mt2) { String st1 = mt1.getSubType(); String st2 = mt2.getSubType(); if (MimeTypeHelper.isMatch(mt1, mt2)) { if (st1.equals("*")) return -1; if (st2.equals("*")) return 1; } return 0; }
/** * 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()))); }
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()); }
public String getBaseType() { return getPrimaryType() + '/' + getSubType(); }
public String getBaseType() { return getPrimaryType() + '/' + getSubType(); }
private boolean isFormRequest(final MimeType contentType) { return "application".equals(contentType.getPrimaryType()) && "x-www-form-urlencoded".equals(contentType.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()); }
@Override public String visitMemoryResource(final MemoryResourceReference memoryResourceReference) throws RuntimeException { try { final String mimeType = memoryResourceReference.getContentType(); if (mimeType == null) { return null; } return new MimeType(mimeType).getSubType(); } catch (final MimeTypeParseException exception) { return null; } }
@Override public String visitMemoryResource(final MemoryResourceReference memoryResourceReference) throws RuntimeException { try { final String mimeType = memoryResourceReference.getContentType(); if (mimeType == null) { return null; } return new MimeType(mimeType).getSubType(); } catch (final MimeTypeParseException exception) { return null; } }
@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")); }