Source Code Cross Referenced for Form.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:        import java.util.List;
023:        import java.util.logging.Logger;
024:
025:        import org.restlet.resource.Representation;
026:        import org.restlet.resource.StringRepresentation;
027:        import org.restlet.util.Engine;
028:        import org.restlet.util.Series;
029:
030:        /**
031:         * Form which is a specialized modifiable list of parameters.
032:         * 
033:         * @author Jerome Louvel (contact@noelios.com)
034:         */
035:        public class Form extends Series<Parameter> {
036:            /**
037:             * Empty constructor.
038:             */
039:            public Form() {
040:                super ();
041:            }
042:
043:            /**
044:             * Constructor.
045:             * 
046:             * @param initialCapacity
047:             *            The initial list capacity.
048:             */
049:            public Form(int initialCapacity) {
050:                super (initialCapacity);
051:            }
052:
053:            /**
054:             * Constructor.
055:             * 
056:             * @param delegate
057:             *            The delegate list.
058:             */
059:            public Form(List<Parameter> delegate) {
060:                super (delegate);
061:            }
062:
063:            /**
064:             * Constructor.
065:             * 
066:             * @param logger
067:             *            The logger to use.
068:             * @param representation
069:             *            The representation to parse (URL encoded Web form supported).
070:             * @throws IOException
071:             */
072:            public Form(Logger logger, Representation representation) {
073:                Engine.getInstance().parse(logger, this , representation);
074:            }
075:
076:            /**
077:             * Constructor.
078:             * 
079:             * @param logger
080:             *            The logger to use.
081:             * @param queryString
082:             *            The Web form parameters as a string.
083:             * @param characterSet
084:             *            The supported character encoding.
085:             * @throws IOException
086:             */
087:            public Form(Logger logger, String queryString,
088:                    CharacterSet characterSet) {
089:                Engine.getInstance().parse(logger, this , queryString,
090:                        characterSet);
091:            }
092:
093:            /**
094:             * Constructor.
095:             * 
096:             * @param webForm
097:             *            The URL encoded Web form.
098:             * @throws IOException
099:             */
100:            public Form(Representation webForm) {
101:                this (Logger.getLogger(Form.class.getCanonicalName()), webForm);
102:            }
103:
104:            /**
105:             * Constructor. Uses UTF-8 as the character set for encoding non-ASCII
106:             * characters.
107:             * 
108:             * @param queryString
109:             *            The Web form parameters as a string.
110:             * @throws IOException
111:             */
112:            public Form(String queryString) {
113:                this (Logger.getLogger(Form.class.getCanonicalName()),
114:                        queryString, CharacterSet.UTF_8);
115:            }
116:
117:            /**
118:             * Constructor.
119:             * 
120:             * @param queryString
121:             *            The Web form parameters as a string.
122:             * @param characterSet
123:             *            The supported character encoding.
124:             * @throws IOException
125:             */
126:            public Form(String queryString, CharacterSet characterSet) {
127:                this (Logger.getLogger(Form.class.getCanonicalName()),
128:                        queryString, characterSet);
129:            }
130:
131:            @Override
132:            public Parameter createEntry(String name, String value) {
133:                return new Parameter(name, value);
134:            }
135:
136:            @Override
137:            public Series<Parameter> createSeries(List<Parameter> delegate) {
138:                if (delegate != null)
139:                    return new Form(delegate);
140:                else
141:                    return new Form();
142:            }
143:
144:            /**
145:             * Formats the form as a query string. Uses UTF-8 as the character set for
146:             * encoding non-ASCII characters.
147:             * 
148:             * @return The form as a query string.
149:             */
150:            public String getQueryString() {
151:                return getQueryString(CharacterSet.UTF_8);
152:            }
153:
154:            /**
155:             * Formats the form as a query string.
156:             * 
157:             * @param characterSet
158:             *            The supported character encoding.
159:             * @return The form as a query string.
160:             */
161:            public String getQueryString(CharacterSet characterSet) {
162:                try {
163:                    return encode(characterSet);
164:                } catch (IOException ioe) {
165:                    return null;
166:                }
167:            }
168:
169:            /**
170:             * Returns the form as a Web representation
171:             * (MediaType.APPLICATION_WWW_FORM). Uses UTF-8 as the character set for
172:             * encoding non-ASCII characters.
173:             * 
174:             * @return The form as a Web representation.
175:             */
176:            public Representation getWebRepresentation() {
177:                return getWebRepresentation(CharacterSet.UTF_8);
178:            }
179:
180:            /**
181:             * Returns the form as a Web representation
182:             * (MediaType.APPLICATION_WWW_FORM).
183:             * 
184:             * @param characterSet
185:             *            The supported character encoding.
186:             * @return The form as a Web representation.
187:             */
188:            public Representation getWebRepresentation(CharacterSet characterSet) {
189:                return new StringRepresentation(getQueryString(characterSet),
190:                        MediaType.APPLICATION_WWW_FORM, null, characterSet);
191:            }
192:
193:            /**
194:             * Encodes the form using the standard URI encoding mechanism and the UTF-8
195:             * character set.
196:             * 
197:             * @return The encoded form.
198:             * @throws IOException
199:             */
200:            public String encode() throws IOException {
201:                return encode(CharacterSet.UTF_8);
202:            }
203:
204:            /**
205:             * URL encodes the form.
206:             * 
207:             * @param characterSet
208:             *            The supported character encoding.
209:             * @return The encoded form.
210:             * @throws IOException
211:             */
212:            public String encode(CharacterSet characterSet) throws IOException {
213:                StringBuilder sb = new StringBuilder();
214:                for (int i = 0; i < size(); i++) {
215:                    if (i > 0)
216:                        sb.append('&');
217:                    get(i).encode(sb, characterSet);
218:                }
219:                return sb.toString();
220:            }
221:
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.