Source Code Cross Referenced for ClientInfo.java in  » Web-Services » restlet-1.0.8 » org » restlet » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » restlet 1.0.8 » org.restlet.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 Noelios Consulting.
003:         * 
004:         * The contents of this file are subject to the terms of the Common Development
005:         * and Distribution License (the "License"). You may not use this file except in
006:         * compliance with the License.
007:         * 
008:         * You can obtain a copy of the license at
009:         * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
010:         * language governing permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL HEADER in each file and
013:         * include the License file at http://www.opensource.org/licenses/cddl1.txt If
014:         * applicable, add the following below this CDDL HEADER, with the fields
015:         * enclosed by brackets "[]" replaced with your own identifying information:
016:         * Portions Copyright [yyyy] [name of copyright owner]
017:         */
018:
019:        package org.restlet.data;
020:
021:        import java.util.ArrayList;
022:        import java.util.List;
023:
024:        import org.restlet.resource.Resource;
025:        import org.restlet.resource.Variant;
026:        import org.restlet.util.Engine;
027:
028:        /**
029:         * Client specific data related to a call.
030:         * 
031:         * @author Jerome Louvel (contact@noelios.com)
032:         */
033:        public final class ClientInfo {
034:            /** The IP addresses. */
035:            private List<String> addresses;
036:
037:            /** The agent name. */
038:            private String agent;
039:
040:            /** The port number. */
041:            private int port;
042:
043:            /** The character set preferences. */
044:            private List<Preference<CharacterSet>> characterSetPrefs;
045:
046:            /** The encoding preferences. */
047:            private List<Preference<Encoding>> encodingPrefs;
048:
049:            /** The language preferences. */
050:            private List<Preference<Language>> languagePrefs;
051:
052:            /** The media preferences. */
053:            private List<Preference<MediaType>> mediaTypePrefs;
054:
055:            /**
056:             * Constructor.
057:             */
058:            public ClientInfo() {
059:                this .addresses = null;
060:                this .agent = null;
061:                this .port = -1;
062:                this .characterSetPrefs = null;
063:                this .encodingPrefs = null;
064:                this .languagePrefs = null;
065:                this .mediaTypePrefs = null;
066:            }
067:
068:            /**
069:             * Returns the character set preferences.
070:             * 
071:             * @return The character set preferences.
072:             */
073:            public List<Preference<CharacterSet>> getAcceptedCharacterSets() {
074:                if (this .characterSetPrefs == null)
075:                    this .characterSetPrefs = new ArrayList<Preference<CharacterSet>>();
076:                return this .characterSetPrefs;
077:            }
078:
079:            /**
080:             * Returns the encoding preferences.
081:             * 
082:             * @return The encoding preferences.
083:             */
084:            public List<Preference<Encoding>> getAcceptedEncodings() {
085:                if (this .encodingPrefs == null)
086:                    this .encodingPrefs = new ArrayList<Preference<Encoding>>();
087:                return this .encodingPrefs;
088:            }
089:
090:            /**
091:             * Returns the language preferences.
092:             * 
093:             * @return The language preferences.
094:             */
095:            public List<Preference<Language>> getAcceptedLanguages() {
096:                if (this .languagePrefs == null)
097:                    this .languagePrefs = new ArrayList<Preference<Language>>();
098:                return this .languagePrefs;
099:            }
100:
101:            /**
102:             * Returns the media type preferences.
103:             * 
104:             * @return The media type preferences.
105:             */
106:            public List<Preference<MediaType>> getAcceptedMediaTypes() {
107:                if (this .mediaTypePrefs == null)
108:                    this .mediaTypePrefs = new ArrayList<Preference<MediaType>>();
109:                return this .mediaTypePrefs;
110:            }
111:
112:            /**
113:             * Returns the client's IP address.
114:             * 
115:             * @return The client's IP address.
116:             */
117:            public String getAddress() {
118:                return (this .addresses == null) ? null : (this .addresses
119:                        .isEmpty() ? null : this .addresses.get(0));
120:            }
121:
122:            /**
123:             * Returns the list of client IP addresses.<br/> The first address is the
124:             * one of the immediate client component as returned by the
125:             * getClientAdress() method and the last address should correspond to the
126:             * origin client (frequently a user agent). This is useful when the user
127:             * agent is separated from the origin server by a chain of intermediary
128:             * components.
129:             * 
130:             * @return The client IP addresses.
131:             */
132:            public List<String> getAddresses() {
133:                if (this .addresses == null)
134:                    this .addresses = new ArrayList<String>();
135:                return this .addresses;
136:            }
137:
138:            /**
139:             * Returns the agent name (ex: "Noelios Restlet Engine/1.0").
140:             * 
141:             * @return The agent name.
142:             */
143:            public String getAgent() {
144:                return this .agent;
145:            }
146:
147:            /**
148:             * Returns the port number which sent the call. If no port is specified, -1
149:             * is returned.
150:             * 
151:             * @return The port number which sent the call.
152:             */
153:            public int getPort() {
154:                return this .port;
155:            }
156:
157:            /**
158:             * Returns the best variant for a given resource according the the client
159:             * preferences: accepted languages, accepted character sets, accepted media
160:             * types and accepted encodings.<br/>A default language is provided in case
161:             * the variants don't match the client preferences.
162:             * 
163:             * @param variants
164:             *            The list of variants to compare.
165:             * @param defaultLanguage
166:             *            The default language.
167:             * @return The best variant.
168:             * @see <a
169:             *      href="http://httpd.apache.org/docs/2.2/en/content-negotiation.html#algorithm">Apache
170:             *      content negotiation algorithm</a>
171:             */
172:            public Variant getPreferredVariant(List<Variant> variants,
173:                    Language defaultLanguage) {
174:                return Engine.getInstance().getPreferredVariant(this , variants,
175:                        defaultLanguage);
176:            }
177:
178:            /**
179:             * Returns the best variant for a given resource according the the client
180:             * preferences.<br/>A default language is provided in case the resource's
181:             * variants don't match the client preferences.
182:             * 
183:             * @param resource
184:             *            The resource for which the best representation needs to be
185:             *            set.
186:             * @param defaultLanguage
187:             *            The default language.
188:             * @return The best variant.
189:             * @see <a
190:             *      href="http://httpd.apache.org/docs/2.2/en/content-negotiation.html#algorithm">Apache
191:             *      content negotiation algorithm</a>
192:             */
193:            public Variant getPreferredVariant(Resource resource,
194:                    Language defaultLanguage) {
195:                return getPreferredVariant(resource.getVariants(),
196:                        defaultLanguage);
197:            }
198:
199:            /**
200:             * Sets the client's IP address.
201:             * 
202:             * @param address
203:             *            The client's IP address.
204:             */
205:            public void setAddress(String address) {
206:                if (getAddresses().isEmpty()) {
207:                    getAddresses().add(address);
208:                } else {
209:                    getAddresses().set(0, address);
210:                }
211:            }
212:
213:            /**
214:             * Sets the agent name (ex: "Noelios Restlet Engine/1.0").
215:             * 
216:             * @param agent
217:             *            The agent name.
218:             */
219:            public void setAgent(String agent) {
220:                this .agent = agent;
221:            }
222:
223:            /**
224:             * Sets the port number which sent the call.
225:             * 
226:             * @param port
227:             *            The port number which sent the call.
228:             */
229:            public void setPort(int port) {
230:                this.port = port;
231:            }
232:
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.