Search in sources :

Example 1 with Variant

use of org.restlet.representation.Variant in project vcell by virtualcell.

the class AbstractServerResource method getWadlVariants.

@Override
protected List<Variant> getWadlVariants() {
    ArrayList<Variant> variants = new ArrayList<Variant>();
    variants.add(new Variant(MediaType.APPLICATION_WADL));
    return variants;
}
Also used : Variant(org.restlet.representation.Variant) ArrayList(java.util.ArrayList)

Example 2 with Variant

use of org.restlet.representation.Variant in project qi4j-sdk by Qi4j.

the class AbstractResponseWriter method getVariant.

protected Variant getVariant(Request request, List<Language> possibleLanguages, List<MediaType> possibleMediaTypes) {
    Language language = request.getClientInfo().getPreferredLanguage(possibleLanguages);
    if (language == null) {
        language = possibleLanguages.get(0);
    }
    MediaType responseType = request.getClientInfo().getPreferredMediaType(possibleMediaTypes);
    if (responseType == null && request.getClientInfo().getPreferredMediaType(Collections.singletonList(MediaType.ALL)) == MediaType.ALL) {
        responseType = possibleMediaTypes.get(0);
    }
    Variant variant = new Variant(responseType, language);
    variant.setCharacterSet(CharacterSet.UTF_8);
    return variant;
}
Also used : Variant(org.restlet.representation.Variant) Language(org.restlet.data.Language) MediaType(org.restlet.data.MediaType)

Aggregations

Variant (org.restlet.representation.Variant)2 ArrayList (java.util.ArrayList)1 Language (org.restlet.data.Language)1 MediaType (org.restlet.data.MediaType)1