public MediaType normalize(MediaType type) { if (type == null) { return null; } MediaType canonical = registry.get(type.getBaseType()); if (canonical == null) { return type; } else if (type.hasParameters()) { return new MediaType(canonical, type.getParameters()); } else { return canonical; } }
private DataURIScheme build(String mediaTypeString, String isBase64, String dataString) { byte[] data = null; //strip out back slashes as you might have in css dataString = (dataString != null) ? dataString.replaceAll("\\\\", " ") : dataString; if (dataString == null || dataString.length() == 0) { data = new byte[0]; } else if (isBase64 != null) { data = base64.decode(dataString); } else { //TODO: handle encodings MediaType mediaType = MediaType.parse(mediaTypeString); Charset charset = StandardCharsets.UTF_8; if (mediaType.hasParameters()) { String charsetName = mediaType.getParameters().get("charset"); if (charsetName != null && Charset.isSupported(charsetName)) { try { charset = Charset.forName(charsetName); } catch (IllegalCharsetNameException e) { //swallow and default to UTF-8 } } } data = dataString.getBytes(charset); } return new DataURIScheme(mediaTypeString, (isBase64 != null), data); }
return candidate; if (normalisedType.hasParameters()) { return types.get(normalisedType.getBaseType());
} else if (inheritance.containsKey(type)) { return inheritance.get(type); } else if (type.hasParameters()) { return type.getBaseType(); } else if (type.getSubtype().endsWith("+xml")) {
public MediaType normalize(MediaType type) { if (type == null) { return null; } MediaType canonical = registry.get(type.getBaseType()); if (canonical == null) { return type; } else if (type.hasParameters()) { return new MediaType(canonical, type.getParameters()); } else { return canonical; } }
public MediaType normalize(MediaType type) { if (type == null) { return null; } MediaType canonical = registry.get(type.getBaseType()); if (canonical == null) { return type; } else if (type.hasParameters()) { return new MediaType(canonical, type.getParameters()); } else { return canonical; } }
private DataURIScheme build(String mediaTypeString, String isBase64, String dataString) { byte[] data = null; //strip out back slashes as you might have in css dataString = (dataString != null) ? dataString.replaceAll("\\\\", " ") : dataString; if (dataString == null || dataString.length() == 0) { data = new byte[0]; } else if (isBase64 != null) { data = base64.decode(dataString); } else { //TODO: handle encodings MediaType mediaType = MediaType.parse(mediaTypeString); Charset charset = StandardCharsets.UTF_8; if (mediaType.hasParameters()) { String charsetName = mediaType.getParameters().get("charset"); if (charsetName != null && Charset.isSupported(charsetName)) { try { charset = Charset.forName(charsetName); } catch (IllegalCharsetNameException e) { //swallow and default to UTF-8 } } } data = dataString.getBytes(charset); } return new DataURIScheme(mediaTypeString, (isBase64 != null), data); }
return candidate; if (normalisedType.hasParameters()) { return types.get(normalisedType.getBaseType());
return candidate; if (normalisedType.hasParameters()) { return types.get(normalisedType.getBaseType());
} else if (inheritance.containsKey(type)) { return inheritance.get(type); } else if (type.hasParameters()) { return type.getBaseType(); } else if (type.getSubtype().endsWith("+xml")) {
} else if (inheritance.containsKey(type)) { return inheritance.get(type); } else if (type.hasParameters()) { return type.getBaseType(); } else if (type.getSubtype().endsWith("+xml")) {