if (mediaType.getMainType().equals("*")) { continue; if (mostSpecific.getMainType().equals("*")) { mostSpecific = mediaType; continue;
final MediaType mediaType = mediaTypes[i]; if (mediaType.getMainType().equals("*")) { continue; if (mostSpecific.getMainType().equals("*")) { mostSpecific = mediaType; continue;
if (mediaType.getMainType().equals("*")) { continue; if (mostSpecific.getMainType().equals("*")) { mostSpecific = mediaType; continue;
private static OrderedMap<ResourceMethod, List<MediaType>> findMethodsSupportType( Collection<ResourceMethod> resourceMethods, ConsOrProdMime inOut, SortedMetadata<MediaType> mediaTypes) { final OrderedMap<ResourceMethod, List<MediaType>> returnMethods = new OrderedMap<>(); for (final ResourceMethod resourceMethod : resourceMethods) { final List<MediaType> mimes = getConsOrProdMimes(resourceMethod, inOut); for (final MediaType resMethMediaType : mimes) { for (final MediaType mediaType : mediaTypes) { final String resMethMainType = resMethMediaType .getMainType(); final String wishedMainType = mediaType.getMainType(); if (resMethMainType.equals(wishedMainType)) { returnMethods.put(resourceMethod, mimes); } } } } return returnMethods; }
/** * 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 (getMainType().equals(included.getMainType())) { if (getSubType().equals(included.getSubType())) { result = true;
/** * 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); }
getQueryType().getMainType());
MediaType includedMediaType = (MediaType) included; if (getMainType().equals(includedMediaType.getMainType())) {
MediaType includedMediaType = (MediaType) included; if (getMainType().equals(includedMediaType.getMainType())) {
/** * Assumes that there is a "callback" query parameter available in the URI * query string, containing the name of the JavaScript callback method. */ @Override public void afterHandle(Request request, Response response) { // Check the presence of the callback parameter String callback = request.getResourceRef().getQueryAsForm() .getFirstValue("callback"); if (callback != null) { Representation entity = response.getEntity(); if (entity != null && ("text".equals(entity.getMediaType().getMainType()) || MediaType.APPLICATION_JSON .equals(entity.getMediaType()))) { response.setEntity(new JsonpRepresentation(callback, response .getStatus(), response.getEntity())); response.setStatus(Status.SUCCESS_OK); } } }
/** * Assumes that there is a "callback" query parameter available in the URI * query string, containing the name of the JavaScript callback method. */ @Override public void afterHandle(Request request, Response response) { // Check the presence of the callback parameter String callback = request.getResourceRef().getQueryAsForm() .getFirstValue("callback"); if (callback != null) { Representation entity = response.getEntity(); if (entity != null && ("text".equals(entity.getMediaType().getMainType()) || MediaType.APPLICATION_JSON .equals(entity.getMediaType()))) { response.setEntity(new JsonpRepresentation(callback, response .getStatus(), response.getEntity())); response.setStatus(Status.SUCCESS_OK); } } }