/** * Converts a MimeType to an IData representation. * * @param mimeType The MimeType to convert. * @return An IData representation of the given MimeType. */ public static IData toIData(MimeType mimeType) { if (mimeType == null) return null; IDataMap output = new IDataMap(); output.put("type", mimeType.getPrimaryType()); output.put("subtype", mimeType.getSubType()); MimeTypeParameterList mimeTypeParameterList = mimeType.getParameters(); if (mimeTypeParameterList.size() > 0) output.put("parameters", toIData(mimeTypeParameterList)); return output; }
/** * Converts a MimeTypeParameterList to an IData representation. * * @param mimeTypeParameterList The MimeTypeParameterList to convert. * @return An IData representation of the given MimeTypeParameterList. */ public static IData toIData(MimeTypeParameterList mimeTypeParameterList) { if (mimeTypeParameterList == null) return null; IDataMap output = new IDataMap(); Enumeration names = mimeTypeParameterList.getNames(); while (names.hasMoreElements()) { String name = (String)names.nextElement(); String value = mimeTypeParameterList.get(name); output.put(name, value); } return output; }
@Test public void testEqualsHashCode() throws MimeTypeParseException { final MimeTypeParameterList listA = new MimeTypeParameterList(";charset=utf-8"); final MimeTypeParameterList listB = new MimeTypeParameterList(";charset=iso-8859-2"); EqualsVerifier.forClass(EnhancedMimeType.class) .suppress(Warning.NULL_FIELDS, Warning.NONFINAL_FIELDS) .withPrefabValues(MimeTypeParameterList.class, listA, listB) .verify(); }
static void setAccessibleNotPublicMemberUpgradeableModule() throws Exception { Method method = MimeTypeParameterList.class.getDeclaredMethod("parse", String.class); method.setAccessible(true); }