Package org.restlet.data

Examples of org.restlet.data.CharacterSet


    @Override
    public void writeTo(Reader reader, Class<?> type, Type genericType,
            Annotation[] annotations, MediaType mediaType,
            MultivaluedMap<String, Object> httpHeaders,
            OutputStream entityStream) throws IOException {
        CharacterSet cs = Response.getCurrent().getEntity().getCharacterSet();
        BioUtils.copy(reader, BioUtils.getWriter(entityStream, cs));
    }
View Full Code Here


            final float quality = extractQuality(parameters);
            result = new Preference<T>(null, quality, parameters);

            switch (this.type) {
            case TYPE_CHARACTER_SET:
                result.setMetadata((T) new CharacterSet(metadata.toString()));
                break;

            case TYPE_ENCODING:
                result.setMetadata((T) new Encoding(metadata.toString()));
                break;
View Full Code Here

            } else if (metadata instanceof MediaType) {
                MediaType mediaType = (MediaType) metadata;
                defaultMetadata = mediaType.equals(getMetadataService()
                        .getDefaultMediaType());
            } else if (metadata instanceof CharacterSet) {
                CharacterSet characterSet = (CharacterSet) metadata;
                defaultMetadata = characterSet.equals(getMetadataService()
                        .getDefaultCharacterSet());
            } else if (metadata instanceof Encoding) {
                Encoding encoding = (Encoding) metadata;
                defaultMetadata = encoding.equals(getMetadataService()
                        .getDefaultEncoding());
View Full Code Here

                    }
                }

                // If no character set is defined, take the default one
                if (variant.getCharacterSet() == null) {
                    final CharacterSet defaultCharacterSet = metadataService
                            .getDefaultCharacterSet();

                    if ((defaultCharacterSet != null)
                            && !defaultCharacterSet.equals(CharacterSet.ALL)) {
                        variant.setCharacterSet(defaultCharacterSet);
                    }
                }
            }
        }
View Full Code Here

     * @return The content type.
     */
    private ContentType createContentType(StringBuilder mediaType,
            Series<Parameter> parameters) {
        // Attempt to extract the character set
        CharacterSet characterSet = null;

        if (parameters != null) {
            String charSet = parameters.getFirstValue("charset");

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

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

        Representation entity = Response.getCurrent().getEntity();

        if (entity == null)
            return null;

        CharacterSet characterSet = entity.getCharacterSet();

        if (characterSet == null)
            return null;

        return characterSet.toString();
    }
View Full Code Here

     * @see HttpHeaders#getMediaType()
     */
    public MediaType getMediaType() {
        if (this.mediaType == null) {
            org.restlet.data.MediaType rmt = request.getEntity().getMediaType();
            CharacterSet rCharSet = request.getEntity().getCharacterSet();
            this.mediaType = Converter.toJaxRsMediaType(rmt, rCharSet);
        }
        return this.mediaType;
    }
View Full Code Here

     * @see #getSupportedCharSet(MultivaluedMap)
     */
    public static String getCharsetName(
            MultivaluedMap<String, Object> httpHeaders, CharacterSet defaultCs) {
        String result = null;
        CharacterSet charSet = null;
        final Object contentType = httpHeaders.getFirst(CONTENT_TYPE);

        if (contentType == null) {
            charSet = defaultCs;
        } else {
            charSet = ContentType.readCharacterSet(contentType.toString());

            if (charSet == null) {
                charSet = defaultCs;
            }
        }

        if (charSet != null) {
            result = charSet.getName();
        }

        return result;
    }
View Full Code Here

        super(mediaType);
        setDataModel(dataModel);
        this.engine = null;
        this.template = new Template();

        CharacterSet charSet = (templateRepresentation.getCharacterSet() == null) ? templateRepresentation
                .getCharacterSet() : CharacterSet.DEFAULT;
        this.template.setEncoding(charSet.getName());
        if (templateRepresentation.getModificationDate() != null) {
            this.template.setLastModified(templateRepresentation
                    .getModificationDate().getTime());
        }
        this.template.setName("org.restlet.resource.representation");
View Full Code Here

            ParseErrorException, IOException {
        super(mediaType);
        this.engine = null;
        this.template = new Template();

        CharacterSet charSet = (templateRepresentation.getCharacterSet() == null) ? templateRepresentation
                .getCharacterSet() : CharacterSet.DEFAULT;
        this.template.setEncoding(charSet.getName());
        this.template.setLastModified((templateRepresentation
                .getModificationDate() == null) ? new Date().getTime()
                : templateRepresentation.getModificationDate().getTime());
        this.template.setName("org.restlet.resource.representation");
        this.template.setRuntimeServices(RuntimeSingleton.getRuntimeServices());
View Full Code Here

TOP

Related Classes of org.restlet.data.CharacterSet

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.