/** * Decode a content Type header line into types and parameters pairs */ void decodeContentType(String rawLine) { int slash = rawLine.indexOf('/'); if (slash == -1) { // if (DEBUG) getLogger().debug("decoding ... no slash found"); return; } else { primaryType = rawLine.substring(0, slash).trim(); } int semicolon = rawLine.indexOf(';'); if (semicolon == -1) { // if (DEBUG) getLogger().debug("decoding ... no semicolon found"); secondaryType = rawLine.substring(slash + 1).trim(); return; } // have parameters secondaryType = rawLine.substring(slash + 1, semicolon).trim(); Header h = new Header(rawLine); parameters = h.getParams(); }
public Header(String line) { String[] strs = line.split(";"); if (0 != strs.length) { value = strs[0]; params = new HashSet<>(strs.length); for (int i = 1; i < strs.length; i++) { String p = strs[i].trim(); int e = p.indexOf('='); String key = p.substring(0, e); String val = p.substring(e + 1); p = Q + strip(key) + Q + SP + Q + strip(val) + Q; params.add(p); } } }
contentDisposition = Header.create(part.getHeader("Content-Disposition")); } catch (MessagingException me) { if (log.isDebugEnabled()) {
public static Header create(String[] header) { if (null == header || 0 == header.length) { return null; } if (header.length > 1) { throw new IllegalArgumentException("Header creation assumes only one occurrence of header instead of " + header.length); } return new Header(header[0]); } }