protected boolean isXml(MediaType type) { String isxml = type.getSubType(); return MediaType.APPLICATION_XML.equals(type) || isxml.endsWith("+xml"); }
protected boolean isXml(MediaType type) { String isxml = type.getSubType(); return MediaType.APPLICATION_XML.equals(type) || isxml.endsWith("+xml"); }
/** * Returns the specificness of the given {@link org.restlet.data.MediaType}: * <ul> * <li>1 for any concrete type (contains no star)</li> * <li>0 for the types (anything/*)</li> * <li>-1 for '*<!---->/*</li> * </ul> * * @param mediaType * @return 1, 0 or -1 * @see #isConcrete(org.restlet.data.MediaType) * @see #sortByConcreteness(Collection) */ public static int specificness(org.restlet.data.MediaType mediaType) { if (mediaType.equals(org.restlet.data.MediaType.ALL, true)) { return -1; } if (mediaType.getSubType().equals("*")) { return 0; } return 1; }
if (getSubType().equals(included.getSubType())) { result = true; } else if (getSubType().equals("*")) { result = true; } else if (getSubType().startsWith("*+") && included.getSubType().endsWith( getSubType().substring(2))) { result = true;
if (mostSpecific.getSubType().contains("*")) { mostSpecific = mediaType; continue;
if (mostSpecific.getSubType().contains("*")) { mostSpecific = mediaType; continue;
if (mostSpecific.getSubType().contains("*")) { mostSpecific = mediaType; continue;
/** * Test the equality of two media types, with the possibility to ignore the * parameters. * * @param obj * The object to compare to. * @param ignoreParameters * Indicates if parameters should be ignored during comparison. * @return True if both media types are equal. */ public boolean equals(Object obj, boolean ignoreParameters) { boolean result = (obj == this); // if obj == this no need to go further if (!result) { // if obj isn't a mediatype or is null don't evaluate further if (obj instanceof MediaType) { final MediaType that = (MediaType) obj; if (getMainType().equals(that.getMainType()) && getSubType().equals(that.getSubType())) { result = ignoreParameters || getParameters().equals(that.getParameters()); } } } return result; }
if (getSubType().equals(includedMediaType.getSubType())) { if (ignoreParameters) { result = true; } else if (getSubType().equals("*")) { result = true; } else if (getSubType().startsWith("*+") && includedMediaType.getSubType().endsWith( getSubType().substring(2))) { result = true;
if (getSubType().equals(includedMediaType.getSubType())) { if (ignoreParameters) { result = true; } else if (getSubType().equals("*")) { result = true; } else if (getSubType().startsWith("*+") && includedMediaType.getSubType().endsWith( getSubType().substring(2))) { result = true;
String type = null; if ((getType() != null) && (getType().getSubType() != null)) { if (getType().getSubType().contains("xhtml")) { type = "xhtml"; } else if (getType().getSubType().contains("html")) { type = "html";
String type = null; if ((getType() != null) && (getType().getSubType() != null)) { if (getType().getSubType().contains("xhtml")) { type = "xhtml"; } else if (getType().getSubType().contains("html")) { type = "html";
String type = null; if ((getType() != null) && (getType().getSubType() != null)) { if (getType().getSubType().contains("xhtml")) { type = "xhtml"; } else if (getType().getSubType().contains("html")) { type = "html";
/** * Test the equality of two media types, with the possibility to ignore the * parameters. * * @param obj * The object to compare to. * @param ignoreParameters * Indicates if parameters should be ignored during comparison. * @return True if both media types are equal. */ public boolean equals(Object obj, boolean ignoreParameters) { boolean result = (obj == this); // if obj == this no need to go further if (!result) { // if obj isn't a mediatype or is null don't evaluate further if (obj instanceof MediaType) { final MediaType that = (MediaType) obj; if (getMainType().equals(that.getMainType()) && getSubType().equals(that.getSubType())) { result = ignoreParameters || getParameters().equals(that.getParameters()); } } } return result; }
/** * {@inheritDoc}<br> * In case the media type has parameters, this method returns the * concatenation of the main type and the subtype. If the subtype is not * equal to "*", it returns the concatenation of the main type and "*". * Otherwise, it returns either the {@link #ALL} media type if it is already * the {@link #ALL} media type, or null. */ @Override public MediaType getParent() { MediaType result = null; if (getParameters().size() > 0) { result = MediaType.valueOf(getMainType() + "/" + getSubType()); } else { if (getSubType().equals("*")) { result = equals(ALL) ? null : ALL; } else { result = MediaType.valueOf(getMainType() + "/*"); } } return result; }
/** * {@inheritDoc}<br> * In case the media type has parameters, this method returns the * concatenation of the main type and the subtype. If the subtype is not * equal to "*", it returns the concatenation of the main type and "*". * Otherwise, it returns either the {@link #ALL} media type if it is already * the {@link #ALL} media type, or null. */ @Override public MediaType getParent() { MediaType result = null; if (getParameters().size() > 0) { result = MediaType.valueOf(getMainType() + "/" + getSubType()); } else { if (getSubType().equals("*")) { result = equals(ALL) ? null : ALL; } else { result = MediaType.valueOf(getMainType() + "/*"); } } return result; }
/** * Convert a Restlet MediaType to a JAX-RS MediaType. * * @param restletMediaType * the MediaType to convert. * @param restletCharacterSet * the CharacterSet for the MediaType; may be null. * @return the converted MediaType */ public static MediaType toJaxRsMediaType( org.restlet.data.MediaType restletMediaType, org.restlet.data.CharacterSet restletCharacterSet) { if (restletMediaType == null) { return null; } final Map<String, String> parameters = toMap(restletMediaType .getParameters()); if (restletCharacterSet != null) { parameters.put(Converter.CHARSET_PARAM, restletCharacterSet.getName()); } return new MediaType(restletMediaType.getMainType(), restletMediaType.getSubType(), parameters); }
String type = null; if ((mediaType != null) && (mediaType.getSubType() != null)) { if (mediaType.getSubType().contains("xhtml")) { type = "xhtml"; } else if (mediaType.getSubType().contains("html")) { type = "html"; } else {
String type = null; if ((mediaType != null) && (mediaType.getSubType() != null)) { if (mediaType.getSubType().contains("xhtml")) { type = "xhtml"; } else if (mediaType.getSubType().contains("html")) { type = "html"; } else {
String type = null; if ((mediaType != null) && (mediaType.getSubType() != null)) { if (mediaType.getSubType().contains("xhtml")) { type = "xhtml"; } else if (mediaType.getSubType().contains("html")) { type = "html"; } else {