public String getContentType() throws MessagingException { String value = getSingleHeader("Content-Type"); if (value == null) { value = "text/plain"; } return value; }
/** * Retrieve the value of the "Content-ID" header. Returns null * if the header does not exist. * * @return The current header value or null. * @exception MessagingException */ public String getContentID() throws MessagingException { return getSingleHeader("Content-ID"); }
public String getContentType() throws MessagingException { String value = getSingleHeader("Content-Type"); if (value == null) { value = "text/plain"; } return value; }
/** * Retrieve the value of the "Content-ID" header. Returns null * if the header does not exist. * * @return The current header value or null. * @exception MessagingException */ public String getContentID() throws MessagingException { return getSingleHeader("Content-ID"); }
public String getContentMD5() throws MessagingException { return getSingleHeader("Content-MD5"); }
public String getContentMD5() throws MessagingException { return getSingleHeader("Content-MD5"); }
public String getDescription() throws MessagingException { String description = getSingleHeader("Content-Description"); if (description != null) { try { // this could be both folded and encoded. Return this to usable form. return MimeUtility.decodeText(MimeUtility.unfold(description)); } catch (UnsupportedEncodingException e) { // ignore } } // return the raw version for any errors. return description; }
public String getDescription() throws MessagingException { String description = getSingleHeader("Content-Description"); if (description != null) { try { // this could be both folded and encoded. Return this to usable form. return MimeUtility.decodeText(ASCIIUtil.unfold(description)); } catch (UnsupportedEncodingException e) { // ignore } } // return the raw version for any errors. return description; }
/** * Retrieve the message "Content-Disposition" header field. * This value represents how the part should be represented to * the user. * * @return The string value of the Content-Disposition field. * @exception MessagingException */ public String getDisposition() throws MessagingException { String disp = getSingleHeader("Content-Disposition"); if (disp != null) { return new ContentDisposition(disp).getDisposition(); } return null; }
/** * Retrieve the message "Content-Disposition" header field. * This value represents how the part should be represented to * the user. * * @return The string value of the Content-Disposition field. * @exception MessagingException */ public String getDisposition() throws MessagingException { String disp = getSingleHeader("Content-Disposition"); if (disp != null) { return new ContentDisposition(disp).getDisposition(); } return null; }
public String getFileName() throws MessagingException { // see if there is a disposition. If there is, parse off the filename parameter. String disposition = getSingleHeader("Content-Disposition"); String filename = null; if (disposition != null) { filename = new ContentDisposition(disposition).getParameter("filename"); } // if there's no filename on the disposition, there might be a name parameter on a // Content-Type header. if (filename == null) { String type = getSingleHeader("Content-Type"); if (type != null) { try { filename = new ContentType(type).getParameter("name"); } catch (ParseException e) { } } } // if we have a name, we might need to decode this if an additional property is set. if (filename != null && SessionUtil.getBooleanProperty(MIME_DECODEFILENAME, false)) { try { filename = MimeUtility.decodeText(filename); } catch (UnsupportedEncodingException e) { throw new MessagingException("Unable to decode filename", e); } } return filename; }
public String getFileName() throws MessagingException { // see if there is a disposition. If there is, parse off the filename parameter. String disposition = getSingleHeader("Content-Disposition"); String filename = null; if (disposition != null) { filename = new ContentDisposition(disposition).getParameter("filename"); } // if there's no filename on the disposition, there might be a name parameter on a // Content-Type header. if (filename == null) { String type = getSingleHeader("Content-Type"); if (type != null) { try { filename = new ContentType(type).getParameter("name"); } catch (ParseException e) { } } } // if we have a name, we might need to decode this if an additional property is set. if (filename != null && SessionUtil.getBooleanProperty(MIME_DECODEFILENAME, false)) { try { filename = MimeUtility.decodeText(filename); } catch (UnsupportedEncodingException e) { throw new MessagingException("Unable to decode filename", e); } } return filename; }
/** * Retrieves the current value of the "Content-Transfer-Encoding" * header. Returns null if the header does not exist. * * @return The current header value or null. * @exception MessagingException */ public String getEncoding() throws MessagingException { // this might require some parsing to sort out. String encoding = getSingleHeader("Content-Transfer-Encoding"); if (encoding != null) { // we need to parse this into ATOMs and other constituent parts. We want the first // ATOM token on the string. HeaderTokenizer tokenizer = new HeaderTokenizer(encoding, HeaderTokenizer.MIME); Token token = tokenizer.next(); while (token.getType() != Token.EOF) { // if this is an ATOM type, return it. if (token.getType() == Token.ATOM) { return token.getValue(); } } // not ATOMs found, just return the entire header value....somebody might be able to make sense of // this. return encoding; } // no header, nothing to return. return null; }
/** * Retrieves the current value of the "Content-Transfer-Encoding" * header. Returns null if the header does not exist. * * @return The current header value or null. * @exception MessagingException */ public String getEncoding() throws MessagingException { // this might require some parsing to sort out. String encoding = getSingleHeader("Content-Transfer-Encoding"); if (encoding != null) { // we need to parse this into ATOMs and other constituent parts. We want the first // ATOM token on the string. HeaderTokenizer tokenizer = new HeaderTokenizer(encoding, HeaderTokenizer.MIME); Token token = tokenizer.next(); while (token.getType() != Token.EOF) { // if this is an ATOM type, return it. if (token.getType() == Token.ATOM) { return token.getValue(); } } // not ATOMs found, just return the entire header value....somebody might be able to make sense of // this. return encoding; } // no header, nothing to return. return null; }
/** * Set a new dispostion value for the "Content-Disposition" field. * If the new value is null, the header is removed. * * @param disposition * The new disposition value. * * @exception MessagingException */ public void setDisposition(String disposition) throws MessagingException { if (disposition == null) { removeHeader("Content-Disposition"); } else { // the disposition has parameters, which we'll attempt to preserve in any existing header. String currentHeader = getSingleHeader("Content-Disposition"); if (currentHeader != null) { ContentDisposition content = new ContentDisposition(currentHeader); content.setDisposition(disposition); setHeader("Content-Disposition", content.toString()); } else { // set using the raw string. setHeader("Content-Disposition", disposition); } } }
/** * Set a new dispostion value for the "Content-Disposition" field. * If the new value is null, the header is removed. * * @param disposition * The new disposition value. * * @exception MessagingException */ public void setDisposition(String disposition) throws MessagingException { if (disposition == null) { removeHeader("Content-Disposition"); } else { // the disposition has parameters, which we'll attempt to preserve in any existing header. String currentHeader = getSingleHeader("Content-Disposition"); if (currentHeader != null) { ContentDisposition content = new ContentDisposition(currentHeader); content.setDisposition(disposition); setHeader("Content-Disposition", content.toString()); } else { // set using the raw string. setHeader("Content-Disposition", disposition); } } }
if (getSingleHeader("Content-Transfer-Encoding") == null) { setHeader("Content-Transfer-Encoding", MimeUtility.getEncoding(handler)); if (getSingleHeader("Content-Type") == null) {
String explicitType = getSingleHeader("Content-Type"); if (getSingleHeader("Content-Transfer-Encoding") == null) { setHeader("Content-Transfer-Encoding", MimeUtility.getEncoding(handler));