Source Code Cross Referenced for Parameter.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.io.IOException;
022:
023:        import org.restlet.util.Engine;
024:
025:        /**
026:         * Multi-usage parameter.
027:         * 
028:         * @author Jerome Louvel (contact@noelios.com)
029:         */
030:        public class Parameter implements  Comparable<Parameter> {
031:            /** The name. */
032:            private String name;
033:
034:            /** The value. */
035:            private String value;
036:
037:            /**
038:             * Default constructor.
039:             */
040:            public Parameter() {
041:                this (null, null);
042:            }
043:
044:            /**
045:             * Preferred constructor.
046:             * 
047:             * @param name
048:             *            The name.
049:             * @param value
050:             *            The value.
051:             */
052:            public Parameter(String name, String value) {
053:                this .name = name;
054:                this .value = value;
055:            }
056:
057:            /**
058:             * Compares this object with the specified object for order.
059:             * 
060:             * @param o
061:             *            The object to be compared.
062:             * @return A negative integer, zero, or a positive integer as this object is
063:             *         less than, equal to, or greater than the specified object.
064:             */
065:            public int compareTo(Parameter o) {
066:                return getName().compareTo(o.getName());
067:            }
068:
069:            /** {@inheritDoc} */
070:            @Override
071:            public boolean equals(Object obj) {
072:                boolean result = (obj == this );
073:
074:                // if obj == this no need to go further
075:                if (!result) {
076:                    // if obj isn't a parameter or is null don't evaluate further
077:                    if ((obj instanceof  Parameter) && obj != null) {
078:                        Parameter that = (Parameter) obj;
079:
080:                        if (!(this .name == null)) // compare names taking care of
081:                        // nulls
082:                        {
083:                            result = (this .name.equals(that.name));
084:                        } else {
085:                            result = (that.name == null);
086:                        }
087:
088:                        if (result) // if names are equal test the values
089:                        {
090:                            if (!(this .value == null)) // compare values taking care of
091:                            // nulls
092:                            {
093:                                result = (this .value.equals(that.value));
094:                            } else {
095:                                result = (that.value == null);
096:                            }
097:                        }
098:                    }
099:                }
100:
101:                return result;
102:            }
103:
104:            /**
105:             * Returns the name of this parameter.
106:             * 
107:             * @return The name of this parameter.
108:             */
109:            public String getName() {
110:                return this .name;
111:            }
112:
113:            /**
114:             * Returns the value.
115:             * 
116:             * @return The value.
117:             */
118:            public String getValue() {
119:                return this .value;
120:            }
121:
122:            /** {@inheritDoc} */
123:            @Override
124:            public int hashCode() {
125:                return Engine.hashCode(getName(), getValue());
126:            }
127:
128:            /**
129:             * Sets the name.
130:             * 
131:             * @param name
132:             *            The name.
133:             */
134:            public void setName(String name) {
135:                this .name = name;
136:            }
137:
138:            /**
139:             * Sets the value.
140:             * 
141:             * @param value
142:             *            The value.
143:             */
144:            public void setValue(String value) {
145:                this .value = value;
146:            }
147:
148:            /**
149:             * Returns a string with the name and value of the parameter.
150:             * 
151:             * @return A string with the name and value of the parameter.
152:             */
153:            @Override
154:            public String toString() {
155:                return getName() + ": " + getValue();
156:            }
157:
158:            /**
159:             * Encodes the parameter using the standard URI encoding mechanism.
160:             * 
161:             * @param characterSet
162:             *            The supported character encoding.
163:             * @return The encoded string.
164:             * @throws IOException
165:             */
166:            public String encode(CharacterSet characterSet) throws IOException {
167:                StringBuilder sb = new StringBuilder();
168:                encode(sb, characterSet);
169:                return sb.toString();
170:            }
171:
172:            /**
173:             * Encodes the parameter and appends the result to the given buffer. Uses
174:             * the standard URI encoding mechanism.
175:             * 
176:             * @param buffer
177:             *            The buffer to append.
178:             * @param characterSet
179:             *            The supported character encoding
180:             * @throws IOException
181:             */
182:            public void encode(Appendable buffer, CharacterSet characterSet)
183:                    throws IOException {
184:                if (getName() != null) {
185:                    buffer.append(Reference.encode(getName(), characterSet));
186:
187:                    if (getValue() != null) {
188:                        buffer.append('=');
189:                        buffer.append(Reference
190:                                .encode(getValue(), characterSet));
191:                    }
192:                }
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.