/** * Create a new {@code MimeType} instance with the same type, subtype and parameters * copied from the original instance and the supplied "{@value #CHARSET_PARAMETER}" parameter. * * @param charset the "{@value #PARAM_CHARSET}" parameter value. If {@code null} or empty * the "{@value #PARAM_CHARSET}" parameter will not be set or updated. * @return copy of the current {@code MimeType} instance with the "{@value #PARAM_CHARSET}" * parameter set to the supplied value. */ public MimeType withCharset(String charset) { return new MimeType(this.type, this.subtype, charset, HeaderElement.createParametersMap(this.parameters)); }
/** * Indicates whether this mime type is concrete, i.e. whether neither the type or * subtype is a wildcard character {@code *}. * @return whether this mime type is concrete */ public boolean isConcreteType() { return !isWildcardType() && !isWildcardSubtype(); }
@Override public String toString() { return build(); }
@Override public HttpRequest addQueryParam(String name, String value) { queryString.add(name, value); return this; }
/** * Returns the content's charset or null if not specified. */ default String getCharset() { MimeType contentType = getContentType(); return null == contentType ? null : contentType.getCharset(); }
public static QueryString parse(String s) { if(null == s || s.length() == 0) { return QueryString.EMPTY; } QueryStringMap params = new QueryStringMap(); parse(s, params); return params; }
@Override public String getMediaType(){ MimeType contentType = getContentType(); return null == contentType ? null : contentType.getMediaType(); }
@Override public String getParameter(String name) { return query.getParameter(name); }
static List<HeaderElement> parseElements(String value){ return parseElements(value.toCharArray(),new Cursor(0,value.length())); }
@Override public String getCharset(){ MimeType contentType = getContentType(); return null == contentType ? null : contentType.getCharset(); }
HeaderElement(String name,String value,Map<String, String> parameters){ this.name = name; this.value = value; this.parameters = createParametersMap(parameters); }
public Cookie get(String name) { for(Cookie cookie : store) { if(cookie.getName().equals(name)) { return cookie; } } return null; }
/** * Checks if the subtype is a wildcard. * * @return true if the subtype is a wildcard. */ public boolean isWildcardSubtype() { return this.getSubtype().equals(WILDCARD_TYPE); }
/** * Checks if the primary type is a wildcard. * * @return true if the primary type is a wildcard. */ public boolean isWildcardType() { return this.getType().equals(WILDCARD_TYPE); }
protected void appendTo(StringBuilder sb) { sb.append(this.type); sb.append('/'); sb.append(this.subtype); appendTo(this.parameters, sb); }
protected State error(Request request, Response response, String code, String message) { errorHandler.responseError(request,response, HTTP.Status.INTERNAL_SERVER_ERROR.value(), code, message); return State.INTERCEPTED; }
public QueryStringBuilder add(String name, String v) { return add(name, v, true); }
@Override public String getParameter(String name) { return query.getParameter(name); }
@Override public THttpRequest addQueryParam(String name, String value) { Args.notEmpty(name, "name"); queryString.add(name, value); return this; }