Source Code Cross Referenced for WFSDataStoreFactory.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » wfs » 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 » GeoTools 2.4.1 » org.geotools.data.wfs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.data.wfs;
017:
018:        import java.io.IOException;
019:        import java.net.URL;
020:        import java.util.HashMap;
021:        import java.util.Map;
022:        import java.util.logging.Logger;
023:
024:        import org.geotools.data.AbstractDataStoreFactory;
025:        import org.geotools.data.DataStore;
026:        import org.xml.sax.SAXException;
027:
028:        /**
029:         * <p>
030:         * DOCUMENT ME!
031:         * </p>
032:         *
033:         * @author dzwiers
034:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wfs/src/main/java/org/geotools/data/wfs/WFSDataStoreFactory.java $
035:         */
036:        public class WFSDataStoreFactory extends AbstractDataStoreFactory {
037:
038:            /**
039:             * url
040:             */
041:            public static final Param URL = new Param(
042:                    "WFSDataStoreFactory:GET_CAPABILITIES_URL",
043:                    URL.class,
044:                    "Represents a URL to the getCapabilities document or a server instance.",
045:                    true);
046:
047:            /**
048:             * boolean
049:             */
050:            public static final Param PROTOCOL = new Param(
051:                    "WFSDataStoreFactory:PROTOCOL",
052:                    Boolean.class,
053:                    "Sets a preference for the HTTP protocol to use when requesting WFS functionality. Set this value to Boolean.TRUE for POST, Boolean.FALSE for GET or NULL for AUTO",
054:                    false);
055:
056:            // password stuff -- see java.net.Authentication
057:            // either both or neither
058:            /**
059:             * String
060:             */
061:            public static final Param USERNAME = new Param(
062:                    "WFSDataStoreFactory:USERNAME",
063:                    String.class,
064:                    "This allows the user to specify a username. This param should not be used without the PASSWORD param.",
065:                    false);
066:            /**
067:             * String
068:             */
069:            public static final Param PASSWORD = new Param(
070:                    "WFSDataStoreFactory:PASSWORD",
071:                    String.class,
072:                    "This allows the user to specify a username. This param should not be used without the USERNAME param.",
073:                    false);
074:
075:            /**
076:             * String
077:             */
078:            public static final Param ENCODING = new Param(
079:                    "WFSDataStoreFactory:ENCODING",
080:                    String.class,
081:                    "This allows the user to specify the Encoding of the XML of the XML-Requests sent to the Server.",
082:                    false);
083:
084:            // timeout -- optional
085:            /**
086:             * Integer
087:             */
088:            public static final Param TIMEOUT = new Param(
089:                    "WFSDataStoreFactory:TIMEOUT",
090:                    Integer.class,
091:                    "This allows the user to specify a timeout in milliseconds. This param has a default value of 3000ms.",
092:                    false);
093:
094:            // buffer size -- optional
095:            /**
096:             * Integer
097:             */
098:            public static final Param BUFFER_SIZE = new Param(
099:                    "WFSDataStoreFactory:BUFFER_SIZE",
100:                    Integer.class,
101:                    "This allows the user to specify a buffer size in features. This param has a default value of 10 features.",
102:                    false);
103:            // use gzip -- optional
104:            /**
105:             * Boolean
106:             */
107:            public static final Param TRY_GZIP = new Param(
108:                    "WFSDataStoreFactory:TRY_GZIP",
109:                    Boolean.class,
110:                    "Indicates that datastore should use gzip to transfer data if the server supports it.  Default is true",
111:                    false);
112:            // be lenient about parsing data -- optional
113:            /**
114:             * Boolean
115:             */
116:            public static final Param LENIENT = new Param(
117:                    "WFSDataStoreFactory:LENIENT",
118:                    Boolean.class,
119:                    "Indicates that datastore should do its best to create features from the provided data even if it does not accurately match the schema.  Errors will be logged but the parsing will continue if this is true.  Default is false",
120:                    false);
121:
122:            protected Map cache = new HashMap();
123:            protected static final Logger logger = logger();
124:
125:            private static Logger logger() {
126:                Logger r = org.geotools.util.logging.Logging
127:                        .getLogger("org.geotools.data.wfs");
128:                return r;
129:            }
130:
131:            /**
132:             * @see org.geotools.data.DataStoreFactorySpi#createDataStore(java.util.Map)
133:             */
134:            public DataStore createDataStore(Map params) throws IOException {
135:                // TODO check that we can use hashcodes in this manner -- think it's ok, particularily for regular usage
136:                if (cache.containsKey(params)) {
137:                    return (DataStore) cache.get(params);
138:                }
139:
140:                return createNewDataStore(params);
141:            }
142:
143:            /**
144:             * DOCUMENT ME!
145:             *
146:             * @param params DOCUMENT ME!
147:             *
148:             * @return DOCUMENT ME!
149:             *
150:             * @throws IOException
151:             *
152:             * @see org.geotools.data.DataStoreFactorySpi#createNewDataStore(java.util.Map)
153:             */
154:            public DataStore createNewDataStore(Map params) throws IOException {
155:                URL host = null;
156:
157:                if (params.containsKey(URL.key)) {
158:                    host = (URL) URL.lookUp(params);
159:                }
160:
161:                Boolean protocol = null;
162:                if (params.containsKey(PROTOCOL.key)) {
163:                    protocol = (Boolean) PROTOCOL.lookUp(params);
164:                }
165:
166:                String user, pass;
167:                user = pass = null;
168:
169:                int timeout = 3000;
170:                int buffer = 10;
171:                boolean tryGZIP = true;
172:                boolean lenient = false;
173:                String encoding = null;
174:
175:                if (params.containsKey(TIMEOUT.key)) {
176:                    Integer i = (Integer) TIMEOUT.lookUp(params);
177:                    if (i != null)
178:                        timeout = i.intValue();
179:                }
180:
181:                if (params.containsKey(BUFFER_SIZE.key)) {
182:                    Integer i = (Integer) BUFFER_SIZE.lookUp(params);
183:                    if (i != null)
184:                        buffer = i.intValue();
185:                }
186:
187:                if (params.containsKey(TRY_GZIP.key)) {
188:                    Boolean b = (Boolean) TRY_GZIP.lookUp(params);
189:                    if (b != null)
190:                        tryGZIP = b.booleanValue();
191:                }
192:
193:                if (params.containsKey(LENIENT.key)) {
194:                    Boolean b = (Boolean) LENIENT.lookUp(params);
195:                    if (b != null)
196:                        lenient = b.booleanValue();
197:                }
198:
199:                if (params.containsKey(USERNAME.key)) {
200:                    user = (String) USERNAME.lookUp(params);
201:                }
202:
203:                if (params.containsKey(PASSWORD.key)) {
204:                    pass = (String) PASSWORD.lookUp(params);
205:                }
206:
207:                if (params.containsKey(ENCODING.key)) {
208:                    encoding = (String) ENCODING.lookUp(params);
209:                }
210:
211:                if (((user == null) && (pass != null))
212:                        || ((pass == null) && (user != null))) {
213:                    throw new IOException(
214:                            "Cannot define only one of USERNAME or PASSWORD, muct define both or neither");
215:                }
216:
217:                DataStore ds = null;
218:
219:                try {
220:                    ds = new WFSDataStore(host, protocol, user, pass, timeout,
221:                            buffer, tryGZIP, lenient, encoding);
222:                    cache.put(params, ds);
223:                } catch (SAXException e) {
224:                    logger.warning(e.toString());
225:                    throw new IOException(e.toString());
226:                }
227:
228:                return ds;
229:            }
230:
231:            /**
232:             * @see org.geotools.data.DataStoreFactorySpi#getDescription()
233:             */
234:            public String getDescription() {
235:                return "The WFSDataStore represents a connection to a Web Feature Server. This connection provides access to the Features published by the server, and the ability to perform transactions on the server (when supported / allowed).";
236:            }
237:
238:            /**
239:             * @see org.geotools.data.DataStoreFactorySpi#getParametersInfo()
240:             */
241:            public Param[] getParametersInfo() {
242:                return new Param[] { URL, PROTOCOL, USERNAME, PASSWORD,
243:                        TIMEOUT, BUFFER_SIZE };
244:            }
245:
246:            /**
247:             * @see org.geotools.data.DataStoreFactorySpi#canProcess(java.util.Map)
248:             */
249:            public boolean canProcess(Map params) {
250:                if (params == null) {
251:                    return false;
252:                }
253:
254:                // check url
255:                if (!params.containsKey(URL.key)) {
256:                    return false; // cannot have both
257:                }
258:
259:                // check password / username
260:                if (params.containsKey(USERNAME.key)) {
261:                    if (!params.containsKey(PASSWORD.key)) {
262:                        return false; // must have both
263:                    }
264:                } else {
265:                    if (params.containsKey(PASSWORD.key)) {
266:                        return false; // must have both
267:                    }
268:                }
269:
270:                // check for type
271:                if (params.containsKey(PROTOCOL.key)) {
272:                    try {
273:                        PROTOCOL.lookUp(params);
274:                    } catch (IOException e) {
275:                        return false;
276:                    }
277:                }
278:
279:                // check for type
280:                if (params.containsKey(TIMEOUT.key)) {
281:                    try {
282:                        TIMEOUT.lookUp(params);
283:                    } catch (IOException e) {
284:                        return false;
285:                    }
286:                }
287:
288:                if (params.containsKey(BUFFER_SIZE.key)) {
289:                    try {
290:                        BUFFER_SIZE.lookUp(params);
291:                    } catch (IOException e) {
292:                        return false;
293:                    }
294:                }
295:
296:                return true;
297:            }
298:
299:            /**
300:             * @see org.geotools.data.DataStoreFactorySpi#getDisplayName()
301:             */
302:            public String getDisplayName() {
303:                return "Web Feature Server";
304:            }
305:
306:            /**
307:             * @see org.geotools.data.DataStoreFactorySpi#isAvailable()
308:             */
309:            public boolean isAvailable() {
310:                return true;
311:            }
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.