Refine search
/** * Set the specified parameter. If this parameter already exists, * it is replaced by this new value. * * @param name parameter name * @param value parameter value */ public void setParameter(String name, String value) { if (list == null) list = new ParameterList(); list.set(name, value); }
/** * Return the specified parameter value. Returns <code>null</code> * if this parameter is absent. * * @param name the parameter name * @return parameter value */ public String getParameter(String name) { if (list == null) return null; return list.get(name); }
/** * Convert this ParameterList into a MIME String. If this is * an empty list, an empty string is returned. * * @return String */ public String toString() { return toString(0); }
/** * Set a parameter. If this parameter already exists, it is * replaced by this new value. If the * <code>mail.mime.encodeparameters</code> System property * is true, and the parameter value is non-ASCII, it will be * encoded with the specified charset, as specified by RFC 2231. * * @param name name of the parameter. * @param value value of the parameter. * @param charset charset of the parameter value. * @since JavaMail 1.4 */ public void set(String name, String value, String charset) { if (encodeParameters) { Value ev = encodeValue(value, charset); // was it actually encoded? if (ev != null) list.put(name.trim().toLowerCase(Locale.ENGLISH), ev); else set(name, value); } else set(name, value); }
Value v = extractCharset(value); try { v.value = decodeBytes(v.value, v.charset); } catch (UnsupportedEncodingException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); v = extractCharset(value); } else { v = new Value();
ParameterList p = cd.getParameterList(); if (p == null) { p = new ParameterList(); cd.setParameterList(p); p.setLiteral("filename", name); else p.set("filename", name, charset); part.setHeader("Content-Disposition", cd.toString()); p = new ParameterList(); cType.setParameterList(p); p.setLiteral("name", name); else p.set("name", name, charset); part.setHeader("Content-Type", cType.toString()); } catch (ParseException pex) { } // ignore it
/** * Constructor that takes a ContentDisposition string. The String * is parsed into its constituents: dispostion and parameters. * A ParseException is thrown if the parse fails. * * @param s the ContentDisposition string. * @exception ParseException if the parse fails. * @since JavaMail 1.2 */ public ContentDisposition(String s) throws ParseException { HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME); HeaderTokenizer.Token tk; // First "disposition" .. tk = h.next(); if (tk.getType() != HeaderTokenizer.Token.ATOM) throw new ParseException("Expected disposition, got " + tk.getValue()); disposition = tk.getValue(); // Then parameters .. String rem = h.getRemainder(); if (rem != null) list = new ParameterList(rem); }
public static ContentType removeCharset(ContentType contentType) { ParameterList orgParamList = contentType.getParameterList(); ParameterList paramList = new ParameterList(); for (Enumeration<?> e = orgParamList.getNames(); e.hasMoreElements(); ) { String name = (String)e.nextElement(); if (!name.equalsIgnoreCase("charset")) { paramList.set(name, orgParamList.get(name)); } } return new ContentType(contentType.getPrimaryType(), contentType.getSubType(), paramList); } }
byte b = r.readByte(); if (b == '(') { list = new ParameterList(); do { String name = r.readString(); if (value == null) // work around buggy servers value = ""; list.set(name, value); } while (r.readByte() != ')'); list.combineSegments(); } else if (b == 'N' || b == 'n') { if (parseDebug)
throw new ParseException("In parameter list <" + s + ">" + ", expected parameter name, " + "got \"" + tk.getValue() + "\""); throw new ParseException("In parameter list <" + s + ">" + ", expected '=', " + "got \"" + tk.getValue() + "\""); throw new ParseException("In parameter list <" + s + ">" + ", expected parameter value, " + "got \"" + tk.getValue() + "\""); lastName = name; if (decodeParameters) putEncodedName(name, value); else list.put(name, value); combineMultisegmentNames(false);
decodeBytes(vv.value, bos); } else { bos.write(ASCIIUtility.getBytes((String)v)); } catch (UnsupportedEncodingException uex) { if (decodeParametersStrict) throw new ParseException(uex.toString()); try { vv.value = decodeBytes(vv.value, vv.charset); } catch (UnsupportedEncodingException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString());
/** * Set a parameter. If this parameter already exists, it is * replaced by this new value. * * @param name name of the parameter. * @param value value of the parameter. */ public void set(String name, String value) { name = name.trim().toLowerCase(Locale.ENGLISH); if (decodeParameters) { try { putEncodedName(name, value); } catch (ParseException pex) { // ignore it list.put(name, value); } } else list.put(name, value); }
/** * Normal users of this class will use simple parameter names. * In some cases, for example, when processing IMAP protocol * messages, individual segments of a multi-segment name * (specified by RFC 2231) will be encountered and passed to * the {@link #set} method. After all these segments are added * to this ParameterList, they need to be combined to represent * the logical parameter name and value. This method will combine * all segments of multi-segment names. <p> * * Normal users should never need to call this method. * * @since JavaMail 1.5 */ public void combineSegments() { /* * If we've accumulated any multi-segment names from calls to * the set method from (e.g.) the IMAP provider, combine the pieces. * Ignore any parse errors (e.g., from decoding the values) * because it's too late to report them. */ if (decodeParameters && multisegmentNames.size() > 0) { try { combineMultisegmentNames(true); } catch (ParseException pex) { // too late to do anything about it } } }
combineMultisegmentNames(true); } catch (ParseException pex) { if (decodeParameters) { try { putEncodedName(name, value); } catch (ParseException pex) {
value = (String)va; sb.addNV(ns, quote(value)); sb.addNV(name, quote(value)); } else if (v instanceof Value) { sb.addNV(name, quote(value)); } else { value = (String)v; name += "*"; while (value.length() > 60) { sb.addNV(name + seg, quote(value.substring(0, 60))); value = value.substring(60); seg++; sb.addNV(name + seg, quote(value)); } else { sb.addNV(name, quote(value));
ParameterList p = cd.getParameterList(); if (p == null) { p = new ParameterList(); cd.setParameterList(p); p.setLiteral("filename", name); else p.set("filename", name, charset); part.setHeader("Content-Disposition", cd.toString()); p = new ParameterList(); cType.setParameterList(p); p.setLiteral("name", name); else p.set("name", name, charset); part.setHeader("Content-Type", cType.toString()); } catch (ParseException pex) { } // ignore it
/** * Set a parameter. If this parameter already exists, it is * replaced by this new value. If the * <code>mail.mime.encodeparameters</code> System property * is true, and the parameter value is non-ASCII, it will be * encoded with the specified charset, as specified by RFC 2231. * * @param name name of the parameter. * @param value value of the parameter. * @param charset charset of the parameter value. * @since JavaMail 1.4 */ public void set(String name, String value, String charset) { if (encodeParameters) { Value ev = encodeValue(value, charset); // was it actually encoded? if (ev != null) list.put(name.trim().toLowerCase(Locale.ENGLISH), ev); else set(name, value); } else set(name, value); }
if (tk.getType() != HeaderTokenizer.Token.ATOM) { if (contentDispositionStrict) { throw new ParseException("Expected disposition, got " + tk.getValue()); if (rem != null) { try { list = new ParameterList(rem); } catch (ParseException px) { if (contentDispositionStrict) {
Value v = extractCharset(value); try { v.value = decodeBytes(v.value, v.charset); } catch (UnsupportedEncodingException ex) { if (decodeParametersStrict) throw new ParseException(ex.toString()); v = extractCharset(value); } else { v = new Value();
byte b = r.readByte(); if (b == '(') { list = new ParameterList(); do { String name = r.readString(); value = ""; list.set(name, value); } while (!r.isNextNonSpace(')')); list.combineSegments(); } else if (b == 'N' || b == 'n') { if (parseDebug)