private AcceptType(final String type, final String subtype, final Map<String, String> parameters, final Float quality) { this.type = type; this.subtype = subtype; this.parameters = TypeUtil.createParameterMap(); this.parameters.putAll(parameters); this.quality = quality; }
private AcceptType(final String type, final String subtype, final Map<String, String> parameters, final Float quality) { this.type = type; this.subtype = subtype; this.parameters = TypeUtil.createParameterMap(); this.parameters.putAll(parameters); this.quality = quality; }
private AcceptType(final String type) { List<String> typeSubtype = new ArrayList<String>(); parameters = TypeUtil.createParameterMap(); parse(type, typeSubtype, parameters); this.type = typeSubtype.get(0); subtype = typeSubtype.get(1); if (TypeUtil.MEDIA_TYPE_WILDCARD.equals(this.type) && !TypeUtil.MEDIA_TYPE_WILDCARD.equals(subtype)) { throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD " + "subtype in accept header:" + type); } final String q = parameters.get(TypeUtil.PARAMETER_Q); if (q == null) { quality = 1F; } else if (Q_PATTERN.matcher(q).matches()) { quality = Float.valueOf(q); } else { throw new IllegalArgumentException("Illegal quality parameter '" + q + "' in accept header:" + type); } }
private AcceptType(final String type) { List<String> typeSubtype = new ArrayList<String>(); parameters = TypeUtil.createParameterMap(); parse(type, typeSubtype, parameters); this.type = typeSubtype.get(0); subtype = typeSubtype.get(1); if (TypeUtil.MEDIA_TYPE_WILDCARD.equals(this.type) && !TypeUtil.MEDIA_TYPE_WILDCARD.equals(subtype)) { throw new IllegalArgumentException("Illegal combination of WILDCARD type with NONE WILDCARD " + "subtype in accept header:" + type); } final String q = parameters.get(TypeUtil.PARAMETER_Q); if (q == null) { quality = 1F; } else if (Q_PATTERN.matcher(q).matches()) { quality = Float.valueOf(q); } else { throw new IllegalArgumentException("Illegal quality parameter '" + q + "' in accept header:" + type); } }
/** * Creates a content type from type, subtype, and parameters. * @param type type * @param subtype subtype * @param parameters parameters as map from names to values */ private ContentType(final String type, final String subtype, final Map<String, String> parameters) { this.type = validateType(type); this.subtype = validateType(subtype); if (parameters == null) { this.parameters = Collections.emptyMap(); } else { this.parameters = TypeUtil.createParameterMap(); this.parameters.putAll(parameters); } }
/** * Creates a content type from type, subtype, and parameters. * @param type type * @param subtype subtype * @param parameters parameters as map from names to values */ private ContentType(final String type, final String subtype, final Map<String, String> parameters) { this.type = validateType(type); this.subtype = validateType(subtype); if (parameters == null) { this.parameters = Collections.emptyMap(); } else { this.parameters = TypeUtil.createParameterMap(); this.parameters.putAll(parameters); } }
private AcceptCharset(final String charset) { parameters = TypeUtil.createParameterMap(); this.charset = parse(charset, parameters); if (!(UTF8_CHARSET.equalsIgnoreCase(this.charset)) && !(UTF8_CHARSET1.equalsIgnoreCase(this.charset)) && !(TypeUtil.MEDIA_TYPE_WILDCARD.equals(this.charset))) { if (CHARSET_PATTERN.matcher(this.charset).matches()) { throw new UnsupportedCharsetException("Unsupported charset in accept charset header:" + charset); } else { throw new IllegalArgumentException("Illegal charset in accept charset header:" + charset); } } for (Entry<String, String> param : parameters.entrySet()) { if (!param.getKey().equals(TypeUtil.PARAMETER_Q)) { throw new IllegalArgumentException("Illegal parameters in accept charset header:" + charset); } } final String q = parameters.get(TypeUtil.PARAMETER_Q); if (q == null) { quality = 1F; } else if (Q_PATTERN.matcher(q).matches()) { quality = Float.valueOf(q); } else { throw new IllegalArgumentException("Illegal quality parameter '" + q + "' in accept charset header:" + charset); } }
private AcceptCharset(final String charset) { parameters = TypeUtil.createParameterMap(); this.charset = parse(charset, parameters); if (!(UTF8_CHARSET.equalsIgnoreCase(this.charset)) && !(UTF8_CHARSET1.equalsIgnoreCase(this.charset)) && !(TypeUtil.MEDIA_TYPE_WILDCARD.equals(this.charset))) { if (CHARSET_PATTERN.matcher(this.charset).matches()) { throw new UnsupportedCharsetException("Unsupported charset in accept charset header:" + charset); } else { throw new IllegalArgumentException("Illegal charset in accept charset header:" + charset); } } for (Entry<String, String> param : parameters.entrySet()) { if (!param.getKey().equals(TypeUtil.PARAMETER_Q)) { throw new IllegalArgumentException("Illegal parameters in accept charset header:" + charset); } } final String q = parameters.get(TypeUtil.PARAMETER_Q); if (q == null) { quality = 1F; } else if (Q_PATTERN.matcher(q).matches()) { quality = Float.valueOf(q); } else { throw new IllegalArgumentException("Illegal quality parameter '" + q + "' in accept charset header:" + charset); } }