Package org.restlet.data

Examples of org.restlet.data.MediaType


                     URI location = text.getElement().getBaseURI().resolve(text.getSourceLink());
                  }
               } else {
                  query = queryT.getFirstValue();
               }
               MediaType mediaType = mediaTypeT==null ? null : MediaType.valueOf(mediaTypeT.getFirstValue());
               if (info!=null) {
                  getLogger().info("Reloading resource entry "+id+" named "+name);
                  resourceManager.reload(id,entry.getEdited(),name,pathT==null ? null : pathT.getFirstValue(),relationT==null ? null : relationT.getFirstValue(),mediaType,query);
               } else {
                  getLogger().info("Configuring resource entry "+id+" named "+name);
View Full Code Here


        assertEquals(clientInfo.getAcceptedMediaTypes().get(2).getMetadata(),
                MediaType.IMAGE_JPEG);
        assertEquals(clientInfo.getAcceptedMediaTypes().get(2).getQuality(),
                1.0F);
        assertEquals(clientInfo.getAcceptedMediaTypes().get(3).getMetadata(),
                new MediaType("*"));
        assertEquals(clientInfo.getAcceptedMediaTypes().get(3).getQuality(),
                0.2F);
        assertEquals(clientInfo.getAcceptedMediaTypes().get(4).getMetadata(),
                MediaType.ALL);
        assertEquals(clientInfo.getAcceptedMediaTypes().get(4).getQuality(),
View Full Code Here

        final MultivaluedMap<String, Object> httpResponseHeaders = new WrappedRequestForHttpHeaders(
                tlContext.get().getResponse(), jaxRsRespHeaders);
        final Representation repr;

        if (entity != null) {
            final MediaType respMediaType = determineMediaType(
                    jaxRsResponseMediaType, resourceMethod, entityClass,
                    genericReturnType);

            final MessageBodyWriterSubSet mbws;
            mbws = providers.writerSubSet(entityClass, genericReturnType);
View Full Code Here

            ResourceMethod resourceMethod) {
        Response restletResponse = tlContext.get().getResponse();
        restletResponse.setStatus(Status.valueOf(jaxRsResponse.getStatus()));
        MultivaluedMap<String, Object> httpHeaders = jaxRsResponse
                .getMetadata();
        MediaType respMediaType = getMediaType(httpHeaders);
        Object jaxRsEntity = jaxRsResponse.getEntity();
        SortedMetadata<MediaType> accMediaType;
        if (respMediaType != null)
            accMediaType = SortedMetadata.get(respMediaType);
        else
View Full Code Here

        RroRemPathAndMatchedPath rrm = identifyRootResource(u);
        // Part 2
        ResObjAndRemPath resourceObjectAndPath = obtainObject(rrm);
        Representation entity = restletRequest.getEntity();
        // Part 3
        MediaType givenMediaType;
        if (entity != null)
            givenMediaType = entity.getMediaType();
        else
            givenMediaType = null;
        ResObjAndMeth method = identifyMethod(resourceObjectAndPath,
View Full Code Here

                new Preference<MediaType>(MediaType.ALL, 1.0F));

        List<MediaType> types = new ArrayList<MediaType>();
        types.add(MediaType.TEXT_XML);
        types.add(MediaType.APPLICATION_JSON);
        MediaType pmt = ci.getPreferredMediaType(types);

        assertEquals(MediaType.TEXT_XML, pmt);
    }
View Full Code Here

            if (charSet != null) {
                parameters.removeAll("charset");
                characterSet = new CharacterSet(charSet);
            }

            return new ContentType(new MediaType(mediaType.toString(),
                    parameters), characterSet);
        }

        return new ContentType(new MediaType(mediaType.toString()), null);
    }
View Full Code Here

    public void writeElement(XmlWriter writer) throws SAXException {
        final AttributesImpl attributes = new AttributesImpl();
        String strContent = null;

        if (getInlineContent() != null) {
            final MediaType mediaType = getInlineContent().getMediaType();
            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 {
                    type = mediaType.getName();
                }
            }

            if (type == null) {
                type = "text";
View Full Code Here

     * @param type
     *            The Atom type attribute.
     * @return The media type.
     */
    private MediaType getMediaType(String type) {
        MediaType result = null;

        if (type == null) {
            // No type defined
        } else if (type.equals("text")) {
            result = MediaType.TEXT_PLAIN;
        } else if (type.equals("html")) {
            result = MediaType.TEXT_HTML;
        } else if (type.equals("xhtml")) {
            result = MediaType.APPLICATION_XHTML;
        } else {
            result = new MediaType(type);
        }

        return result;
    }
View Full Code Here

                        "href")));
                this.currentLink.setRel(Relation.valueOf(attrs.getValue("",
                        "rel")));
                String type = attrs.getValue("", "type");
                if (type != null && type.length() > 0) {
                    this.currentLink.setType(new MediaType(type));
                }
                this.currentLink.setHrefLang(new Language(attrs.getValue("",
                        "hreflang")));
                this.currentLink.setTitle(attrs.getValue("", "title"));
                final String attr = attrs.getValue("", "length");
View Full Code Here

TOP

Related Classes of org.restlet.data.MediaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.