Package org.restlet.data

Examples of org.restlet.data.Preference


     */
    public static String format(List<? extends Preference> prefs)
            throws IOException {
        StringBuilder sb = new StringBuilder();

        Preference pref;
        for (int i = 0; i < prefs.size(); i++) {
            if (i > 0)
                sb.append(", ");
            pref = prefs.get(i);
            format(pref, sb);
View Full Code Here


            } else {
                try {
                    PreferenceReader pr = new PreferenceReader(
                            PreferenceReader.TYPE_CHARACTER_SET,
                            acceptCharsetHeader);
                    Preference currentPref = pr.readPreference();
                    while (currentPref != null) {
                        client.getAcceptedCharacterSets().add(currentPref);
                        currentPref = pr.readPreference();
                    }
                } catch (IOException ioe) {
                    throw new IllegalArgumentException(
                            "An exception occurred during character set preferences parsing. Header: "
                                    + acceptCharsetHeader
                                    + ". Ignoring header.");
                }
            }
        } else {
            client.getAcceptedCharacterSets().add(
                    new Preference(CharacterSet.ALL));
        }
    }
View Full Code Here

            ClientInfo preference) {
        if (acceptEncodingHeader != null) {
            try {
                PreferenceReader pr = new PreferenceReader(
                        PreferenceReader.TYPE_ENCODING, acceptEncodingHeader);
                Preference currentPref = pr.readPreference();
                while (currentPref != null) {
                    preference.getAcceptedEncodings().add(currentPref);
                    currentPref = pr.readPreference();
                }
            } catch (IOException ioe) {
                throw new IllegalArgumentException(
                        "An exception occurred during encoding preferences parsing. Header: "
                                + acceptEncodingHeader + ". Ignoring header.");
            }
        } else {
            preference.getAcceptedEncodings().add(
                    new Preference(Encoding.IDENTITY));
        }
    }
View Full Code Here

            ClientInfo preference) {
        if (acceptLanguageHeader != null) {
            try {
                PreferenceReader pr = new PreferenceReader(
                        PreferenceReader.TYPE_LANGUAGE, acceptLanguageHeader);
                Preference currentPref = pr.readPreference();
                while (currentPref != null) {
                    preference.getAcceptedLanguages().add(currentPref);
                    currentPref = pr.readPreference();
                }
            } catch (IOException ioe) {
                throw new IllegalArgumentException(
                        "An exception occurred during language preferences parsing. Header: "
                                + acceptLanguageHeader + ". Ignoring header.");
            }
        } else {
            preference.getAcceptedLanguages().add(new Preference(Language.ALL));
        }
    }
View Full Code Here

            ClientInfo preference) {
        if (acceptMediaTypeHeader != null) {
            try {
                PreferenceReader pr = new PreferenceReader(
                        PreferenceReader.TYPE_MEDIA_TYPE, acceptMediaTypeHeader);
                Preference currentPref = pr.readPreference();
                while (currentPref != null) {
                    preference.getAcceptedMediaTypes().add(currentPref);
                    currentPref = pr.readPreference();
                }
            } catch (IOException ioe) {
                throw new IllegalArgumentException(
                        "An exception occurred during media type preferences parsing. Header: "
                                + acceptMediaTypeHeader + ". Ignoring header.");
            }
        } else {
            preference.getAcceptedMediaTypes().add(
                    new Preference(MediaType.ALL));
        }
    }
View Full Code Here

     */
    public ContentType(String headerValue) {
        try {
            PreferenceReader pr = new PreferenceReader(
                    PreferenceReader.TYPE_MEDIA_TYPE, headerValue);
            Preference pref;
            pref = pr.readPreference();
            this.mediaType = (MediaType) pref.getMetadata();

            String charSet = this.mediaType.getParameters().getFirstValue(
                    "charset");
            if (charSet != null) {
                this.characterSet = new CharacterSet(charSet);
View Full Code Here

                        acceptCharsetHeader);
                pr.addValues(clientInfo.getAcceptedCharacterSets());
            }
        } else {
            clientInfo.getAcceptedCharacterSets().add(
                    new Preference(CharacterSet.ALL));
        }
    }
View Full Code Here

            PreferenceReader pr = new PreferenceReader(
                    PreferenceReader.TYPE_ENCODING, acceptEncodingHeader);
            pr.addValues(clientInfo.getAcceptedEncodings());
        } else {
            clientInfo.getAcceptedEncodings().add(
                    new Preference(Encoding.IDENTITY));
        }
    }
View Full Code Here

        if (acceptLanguageHeader != null) {
            PreferenceReader pr = new PreferenceReader(
                    PreferenceReader.TYPE_LANGUAGE, acceptLanguageHeader);
            pr.addValues(clientInfo.getAcceptedLanguages());
        } else {
            clientInfo.getAcceptedLanguages().add(new Preference(Language.ALL));
        }
    }
View Full Code Here

            PreferenceReader pr = new PreferenceReader(
                    PreferenceReader.TYPE_MEDIA_TYPE, acceptMediaTypeHeader);
            pr.addValues(clientInfo.getAcceptedMediaTypes());
        } else {
            clientInfo.getAcceptedMediaTypes().add(
                    new Preference(MediaType.ALL));
        }
    }
View Full Code Here

TOP

Related Classes of org.restlet.data.Preference

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.