List of usage examples for javax.activation MimeType setParameter
public void setParameter(String name, String value)
From source file:com.googlecode.ddom.frontend.saaj.impl.SwAProfile.java
@Override public String getContentType() { MimeType contentType; try {/*w w w.j a v a2 s . c om*/ contentType = new MimeType("multipart", "related"); } catch (MimeTypeParseException ex) { throw new Error(ex); } contentType.setParameter("type", getSOAPVersion().getContentType()); contentType.setParameter("boundary", boundary); return contentType.toString(); }
From source file:org.mulgara.resolver.http.HttpContent.java
/** * Read the mime type. Should only be done if the Mime type is not already available * as this will close the connection./*from w w w . j a v a 2 s . c o m*/ * @return The MimeType for the URL. * @throws NotModifiedException if the content validates against the cache */ @SuppressWarnings("unchecked") private MimeType readMimeType(HttpMethod method) throws NotModifiedException { MimeType result = null; String contentType = null; try { // obtain connection and retrieve the headers Header header = method.getResponseHeader("Content-Type"); if (header != null) { contentType = header.getValue(); // find the parameter separator so we can protect against bad params int sep = contentType.indexOf(';'); // no params, just create the MimeType if (sep < 0) result = new MimeType(contentType); else { // create the MimeType from the type/subtype result = new MimeType(contentType.substring(0, sep)); // parse parameters separately and set the result accordingly try { MimeTypeParameterList params = new MimeTypeParameterList(contentType.substring(sep + 1)); Enumeration<String> names = (Enumeration<String>) params.getNames(); while (names.hasMoreElements()) { String name = names.nextElement(); result.setParameter(name, params.get(name)); } } catch (MimeTypeParseException e) { logger.warn("Ignoring bad parameters in '" + contentType.substring(sep + 1) + "' from the content type for " + httpUri); } } if (logger.isInfoEnabled()) { logger.info("Obtain content type " + result + " from " + httpUri); } } } catch (java.lang.IllegalStateException e) { logger.info("Unable to obtain content type for " + httpUri); } catch (MimeTypeParseException e) { logger.warn("Unexpected parameters before ; in '" + contentType + "' as a content type for " + httpUri); } return result; }