Source Code Cross Referenced for VPFDataStoreFactory.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » vpf » 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.vpf 
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.vpf;
017:
018:        import java.io.File;
019:        import java.io.IOException;
020:        import java.util.logging.Logger;
021:        import java.util.Collections;
022:        import java.util.Map;
023:        import java.net.URL;
024:        import java.net.URI;
025:
026:        import org.geotools.data.DataStore;
027:        import org.geotools.data.DataStoreFactorySpi;
028:        import org.geotools.data.vpf.ifc.FileConstants;
029:        import org.geotools.feature.SchemaException;
030:
031:        /**
032:         * Class VPFDataSourceFactory.java is responsible for constructing appropriate
033:         * VPFDataStore (actually VPFLibrary) objects.
034:         * VPFDataStoreFactory
035:         * - factory for VPFLibrary
036:         *    - factory for VPFCoverage
037:         *        - factory for VPFFeatureClass
038:         *            - implements FeatureType by delegation to contained DefaultFeatureType
039:         *            - contains VPFFiles
040:         *            - retrieves VPFColumns from VPFFiles for use in constructing DefaultFeatureType
041:         *            - contains joins (column pairs)
042:         *        - factory for VPFFeatureType
043:         *            - implements FeatureType by delegation to contained VPFFeatureClass
044:         * 
045:         * VPFFile
046:         * - contains VPFInputStream
047:         * - factory for VPFColumn
048:         *    - implements AttributeType by delegation to contained DefaultFeatureType
049:         * <p>
050:         * Created: Fri Mar 28 15:54:32 2003
051:         * </p>
052:         *
053:         * @author <a href="mailto:kobit@users.sourceforge.net">Artur Hefczyc</a>
054:         * @author <a href="mailto:knuterik@onemap.org">Knut-Erik Johnsen</a>, Project OneMap
055:         * @author Chris Holmes, Fulbright
056:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/vpf/src/main/java/org/geotools/data/vpf/VPFDataStoreFactory.java $
057:         * @version 2.1.0
058:         */
059:        public class VPFDataStoreFactory implements  DataStoreFactorySpi {
060:            /** The logger for the vpf module. */
061:            protected static final Logger LOGGER = org.geotools.util.logging.Logging
062:                    .getLogger("org.geotools.data.vpf");
063:
064:            /**
065:             * Default Constructor
066:             *
067:             */
068:            public VPFDataStoreFactory() {
069:            }
070:
071:            /*
072:             *  (non-Javadoc)
073:             * @see org.geotools.data.DataStoreFactorySpi#getDisplayName()
074:             */
075:            public String getDisplayName() {
076:                return "Vector Product Format Library";
077:            }
078:
079:            /*
080:             *  (non-Javadoc)
081:             * @see org.geotools.data.DataStoreFactorySpi#getDescription()
082:             */
083:            public String getDescription() {
084:                return "Vector Product Format Library data store implementation.";
085:            }
086:
087:            /*
088:             *  (non-Javadoc)
089:             * @see org.geotools.data.DataStoreFactorySpi#canProcess(java.util.Map)
090:             */
091:            public boolean canProcess(Map params) {
092:                boolean result = false;
093:                try {
094:
095:                    File file = getLhtFile(params);
096:                    //if getLhtFile didn't throw an exception then we're good.
097:                    result = true;
098:
099:                } catch (IOException exc) {
100:                    //catch io exception, false will return
101:                }
102:                return result;
103:            }
104:
105:            /*
106:             *  (non-Javadoc)
107:             * @see org.geotools.data.DataStoreFactorySpi#createDataStore(java.util.Map)
108:             */
109:            public DataStore createDataStore(Map params) throws IOException {
110:                return create(params);
111:            }
112:
113:            /**
114:             * Creates a data store.
115:             * @param params A <code>Map</code> of parameters which must be verified and 
116:             * @throws IOException
117:             */
118:            private DataStore create(Map params) throws IOException {
119:                DataStore result = null;
120:                File file = getLhtFile(params);
121:                //CH I'd like to check existence here, so that geoserver can get
122:                //a better error message, but I've spent way too long on this, so
123:                //I'm giving up for now.  Ideally canProcess just figures out if
124:                //the params are valid, and doesn't throw the not existing error, but
125:                //since we need a directory, not the actual file, it's hard to check
126:                //for anything.
127:                if (!file.exists() || !file.canRead()) {
128:                    throw new IOException(
129:                            "File either doesn't exist or is unreadable : "
130:                                    + file);
131:                }
132:                URI namespace = (URI) NAMESPACEP.lookUp(params); //null if not exist
133:                LOGGER.finer("creating new vpf datastore with params: "
134:                        + params);
135:                try {
136:                    result = new VPFLibrary(file, namespace);
137:                } catch (SchemaException exc) {
138:                    throw new IOException("There was a problem making one of "
139:                            + "the feature classes as a FeatureType.");
140:                }
141:
142:                return result;
143:            }
144:
145:            /*
146:             * private method to get the lht file from the map of params, to avoid
147:             * code duplication in canProcess and create, since they both need the
148:             * file - canProcess just returns true if it's there, and eats the 
149:             * exception, create makes the store.
150:             */
151:            private File getLhtFile(Map params) throws IOException {
152:                URL url = (URL) DIR.lookUp(params);
153:                File file = null;
154:                if (url.getProtocol().equals("file")) {
155:
156:                    if (url.getHost() != null && !url.getHost().equals("")) {
157:                        //win
158:                        file = new File(url.getHost() + ":" + url.getFile());
159:                    } else {
160:                        //linux
161:                        file = new File(url.getFile());
162:                    }
163:                    File lhtFile;
164:                    if (file.isDirectory()) {
165:                        lhtFile = new File(file,
166:                                FileConstants.LIBRARY_HEADER_TABLE);
167:                    } else {
168:                        lhtFile = file;
169:                        if (!lhtFile.getName().equalsIgnoreCase(
170:                                FileConstants.LIBRARY_HEADER_TABLE)) {
171:                            throw new IOException("File: " + file
172:                                    + "is not a lht file");
173:                        }
174:                    }
175:
176:                } else {
177:                    throw new IOException("only file protocol supported");
178:                }
179:                return file;
180:            }
181:
182:            /*
183:             * 
184:             *  (non-Javadoc)
185:             * @see org.geotools.data.DataStoreFactorySpi#createNewDataStore(java.util.Map)
186:             */
187:            public DataStore createNewDataStore(Map params)
188:                    throws java.io.IOException {
189:                return create(params);
190:            }
191:
192:            /**
193:             * A parameter which is the directory containing the LHT file
194:             */
195:            public static final Param DIR = new Param("url", URL.class,
196:                    "Directory containing lht file", true);
197:
198:            public static final Param NAMESPACEP = new Param("namespace",
199:                    URI.class, "uri to a the namespace", false); //not required
200:
201:            /*
202:             *  (non-Javadoc)
203:             * @see org.geotools.data.DataStoreFactorySpi#getParametersInfo()
204:             */
205:            public Param[] getParametersInfo() {
206:                return new Param[] { DIR, };
207:            }
208:
209:            /*
210:             *  (non-Javadoc)
211:             * @see org.geotools.data.DataStoreFactorySpi#isAvailable()
212:             */
213:            public boolean isAvailable() {
214:                return true;
215:            }
216:
217:            /**
218:             * Returns the implementation hints. The default implementation returns en empty map.
219:             */
220:            public Map getImplementationHints() {
221:                return Collections.EMPTY_MAP;
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.