Source Code Cross Referenced for DescribeLayerTransformer.java in  » GIS » GeoServer » org » vfny » geoserver » wms » responses » helpers » 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.vfny.geoserver.wms.responses.helpers 
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.vfny.geoserver.wms.responses.helpers;
006:
007:        import org.geoserver.ows.util.RequestUtils;
008:        import org.geoserver.platform.GeoServerExtensions;
009:        import org.geotools.xml.transform.TransformerBase;
010:        import org.geotools.xml.transform.Translator;
011:        import org.springframework.context.ApplicationContext;
012:        import org.vfny.geoserver.global.GeoServer;
013:        import org.vfny.geoserver.global.MapLayerInfo;
014:        import org.vfny.geoserver.wms.requests.DescribeLayerRequest;
015:        import org.xml.sax.ContentHandler;
016:        import org.xml.sax.helpers.AttributesImpl;
017:        import java.util.Iterator;
018:        import javax.xml.transform.OutputKeys;
019:        import javax.xml.transform.Transformer;
020:        import javax.xml.transform.TransformerException;
021:
022:        /**
023:         * <code>org.geotools.xml.transform.TransformerBase</code> specialized in
024:         * producing a WMS DescribeLayer response.
025:         *
026:         * @author Gabriel Roldan, Axios Engineering
027:         * @version $Id: DescribeLayerTransformer.java 7522 2007-09-12 22:00:10Z saul.farber $
028:         */
029:        public class DescribeLayerTransformer extends TransformerBase {
030:            /** The base url upon URLs which point to 'me' should be based. */
031:            private String baseUrl;
032:
033:            private GeoServer geoserver;
034:
035:            /**
036:             * Creates a new DescribeLayerTransformer object.
037:             *
038:             * @param baseUrl the url string wich holds the validation
039:             * schemas and DTD's on this server instance.
040:             */
041:            public DescribeLayerTransformer(String baseUrl, GeoServer gs) {
042:                super ();
043:
044:                if (baseUrl == null) {
045:                    throw new NullPointerException();
046:                }
047:
048:                this .baseUrl = baseUrl;
049:                this .geoserver = gs;
050:            }
051:
052:            /**
053:             * Creates and returns a Translator specialized in producing
054:             * a DescribeLayer response document.
055:             *
056:             * @param handler the content handler to send sax events to.
057:             *
058:             * @return a new <code>DescribeLayerTranslator</code>
059:             */
060:            public Translator createTranslator(ContentHandler handler) {
061:                return new DescribeLayerTranslator(handler);
062:            }
063:
064:            /**
065:             * Gets the <code>Transformer</code> created by the overriden method in
066:             * the superclass and adds it the DOCTYPE token pointing to the
067:             * DescribeLayer DTD on this server instance.
068:             *
069:             * <p>
070:             * The DTD is set at the fixed location given by the <code>schemaBaseUrl</code>
071:             * passed to the constructor <code>+ "wms/1.1.1/WMS_DescribeLayerResponse.dtd</code>.
072:             * </p>
073:             *
074:             * @return a Transformer propoerly configured to produce DescribeLayer responses.
075:             *
076:             * @throws TransformerException if it is thrown by <code>super.createTransformer()</code>
077:             */
078:            public Transformer createTransformer() throws TransformerException {
079:                Transformer transformer = super .createTransformer();
080:                String dtdUrl = RequestUtils.proxifiedBaseURL(baseUrl,
081:                        geoserver.getProxyBaseUrl())
082:                        + "schemas/wms/1.1.1/WMS_DescribeLayerResponse.dtd";
083:                transformer
084:                        .setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, dtdUrl);
085:
086:                return transformer;
087:            }
088:
089:            /**
090:             * Sends SAX events to produce a DescribeLayer response document.
091:             *
092:             * @author Gabriel Roldan, Axios Engineering
093:             * @version $Id: DescribeLayerTransformer.java 7522 2007-09-12 22:00:10Z saul.farber $
094:             */
095:            private static class DescribeLayerTranslator extends
096:                    TranslatorSupport {
097:                /**
098:                 * Creates a new DescribeLayerTranslator object.
099:                 *
100:                 * @param handler DOCUMENT ME!
101:                 */
102:                public DescribeLayerTranslator(ContentHandler handler) {
103:                    super (handler, null, null);
104:                }
105:
106:                /**
107:                 * Encode the object.
108:                 *
109:                 * @param o The Object to encode.
110:                 *
111:                 * @throws IllegalArgumentException if the Object is not encodeable.
112:                 */
113:                public void encode(Object o) throws IllegalArgumentException {
114:                    if (!(o instanceof  DescribeLayerRequest)) {
115:                        throw new IllegalArgumentException();
116:                    }
117:
118:                    DescribeLayerRequest req = (DescribeLayerRequest) o;
119:
120:                    AttributesImpl version = new AttributesImpl();
121:                    version.addAttribute("", "version", "version", "", "1.0.0");
122:
123:                    start("WMS_DescribeLayerResponse", version);
124:
125:                    handleLayers(req);
126:
127:                    end("WMS_DescribeLayerResponse");
128:                }
129:
130:                /**
131:                 * As currently GeoServer does not have support for nested layers, this
132:                 * method declares a <code>LayerDescription</code> element for each
133:                 * featuretype requested.
134:                 *
135:                 * @param req
136:                 */
137:                private void handleLayers(DescribeLayerRequest req) {
138:                    MapLayerInfo layer;
139:
140:                    String url = RequestUtils.proxifiedBaseURL(
141:                            req.getBaseUrl(), req.getServiceRef()
142:                                    .getGeoServer().getProxyBaseUrl())
143:                            + "wfs/WfsDispatcher?";
144:
145:                    AttributesImpl layerAtts = new AttributesImpl();
146:                    layerAtts.addAttribute("", "name", "name", "", "");
147:                    layerAtts.addAttribute("", "wfs", "wfs", "", url);
148:
149:                    AttributesImpl queryAtts = new AttributesImpl();
150:                    queryAtts.addAttribute("", "typeName", "typeName", "", "");
151:
152:                    for (Iterator it = req.getLayers().iterator(); it.hasNext();) {
153:                        layer = (MapLayerInfo) it.next();
154:                        layerAtts.setAttribute(0, "", "name", "name", "", layer
155:                                .getName());
156:                        start("LayerDescription", layerAtts);
157:
158:                        queryAtts.setAttribute(0, "", "typeName", "typeName",
159:                                "", layer.getName());
160:                        element("Query", null, queryAtts);
161:
162:                        end("LayerDescription");
163:                    }
164:                }
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.