Source Code Cross Referenced for Response.java in  » GIS » GeoServer » org » geoserver » ows » 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 » GIS » GeoServer » org.geoserver.ows 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.geoserver.ows;
006:
007:        import org.geoserver.platform.Operation;
008:        import org.geoserver.platform.ServiceException;
009:        import java.io.IOException;
010:        import java.io.OutputStream;
011:        import java.util.Collections;
012:        import java.util.HashMap;
013:        import java.util.Set;
014:
015:        /**
016:         * Response to an operation, which serializes the result of the operation to an
017:         * output stream.
018:         * <p>
019:         * A response must specify the following information:
020:         * <ul>
021:         *  <li>The type of object it is capable of serializing, the class is bound to.
022:         *  See {@link #getBinding()}.
023:         *  <li>The mime-type of the resulting response. See {@link #getMimeType()}.
024:         * </ul>
025:         * </p>
026:         * <p>
027:         * Optionally, a response may declare a well-known name for it. This well
028:         * known name corresponds to the "outputFormat" parameter which is supported
029:         * on many types of OWS request.
030:         * </p>
031:         *
032:         * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
033:         *
034:         */
035:        public abstract class Response {
036:            /**
037:             * Class of object to serialize
038:             */
039:            final Class binding;
040:
041:            /**
042:             * The well known "outputFormat" of the response
043:             */
044:            final Set outputFormats;
045:
046:            /**
047:             * Constructor which specified the class this response is bound to.
048:             *
049:             * @param binding The class of object the response serializes.
050:             */
051:            public Response(Class binding) {
052:                this (binding, (Set) null);
053:            }
054:
055:            /**
056:             * Constructor which specified the class this response is bound to, and a
057:             * common name for the type of response.
058:             *
059:             * @param binding The class of object the response serializes
060:             * @param outputFormat A common name for the response.
061:             *
062:             */
063:            public Response(Class binding, String outputFormat) {
064:                this (binding, outputFormat == null ? null : Collections
065:                        .singleton(outputFormat));
066:            }
067:
068:            /**
069:             * Constructor which specified the class this response is bound to, and a
070:             * set of common names for the type of response.
071:             *
072:             * @param binding The class of object the response serializes
073:             * @param outputFormats A set of common names for the response.
074:             */
075:            public Response(Class binding, Set outputFormats) {
076:                if (binding == null) {
077:                    throw new NullPointerException("binding may not be null");
078:                }
079:
080:                if (outputFormats == null) {
081:                    outputFormats = Collections.EMPTY_SET;
082:                }
083:
084:                this .binding = binding;
085:                this .outputFormats = outputFormats;
086:            }
087:
088:            /**
089:             * @return The type of object the response can handle.
090:             */
091:            public final Class getBinding() {
092:                return binding;
093:            }
094:
095:            /**
096:             * @deprecated use {@link #getOutputFormats()}.
097:             * 
098:             * @return A common or well-known name for the response, may be <code>null</code>.
099:             */
100:            public final String getOutputFormat() {
101:                if (outputFormats.isEmpty()) {
102:                    return null;
103:                }
104:
105:                return (String) outputFormats.iterator().next();
106:            }
107:
108:            /**
109:             *  
110:             * @return Set of common or well-known name for the response, may be empty.
111:             */
112:            public final Set getOutputFormats() {
113:                return outputFormats;
114:            }
115:
116:            /**
117:             * Determines if the response can handle the operation being performed.
118:             * <p>
119:             * This method is called before {@link #write(Object, OutputStream, Operation)}.
120:             * </p>
121:             * <p>
122:             * Subclasses should override this method to perform additional checks
123:             * against the operation being performed. Example might be checking the
124:             * version of the service.
125:             * </p>
126:             * @param operation The operation being performed.
127:             *
128:             * @return <code>true</code> if the response can handle the operation,
129:             * otherwise <code>false</code>
130:             */
131:            public boolean canHandle(Operation operation) {
132:                return true;
133:            }
134:
135:            /**
136:             * Returns the mime type to be uses when writing the response.
137:             *
138:             * @param value The value to serialize
139:             * @param operation The operation being performed.
140:             *
141:             *
142:             * @return The mime type of the response, must not be <code>null</code>
143:             */
144:            public abstract String getMimeType(Object value, Operation operation)
145:                    throws ServiceException;
146:
147:            /**
148:             * Returns a 2xn array of Strings, each of which is an HTTP header pair
149:             * to be set on the HTTP Response.  Can return null if there are
150:             * no headers to be set on the response.
151:             *
152:             * @param value The value to serialize
153:             * @param operation The operation being performed.
154:             *
155:             * @return 2xn string array containing string-pairs of HTTP headers/values
156:             *
157:             */
158:            public String[][] getHeaders(Object value, Operation operation)
159:                    throws ServiceException {
160:                //default implementation returns null = no headers to set
161:                return null;
162:            }
163:
164:            /**
165:             * Serializes <code>value</code> to <code>output</code>.
166:             * <p>
167:             * The <code>operation</code> bean is provided for context.
168:             * </p>
169:             * @param value The value to serialize.
170:             * @param output The output stream.
171:             * @param operation The operation which resulted in <code>value</code>
172:             *
173:             * @throws IOException Any I/O errors that occur
174:             * @throws ServiceException Any service errors that occur
175:             */
176:            public abstract void write(Object value, OutputStream output,
177:                    Operation operation) throws IOException, ServiceException;
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.