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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-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;
009:         *    version 2.1 of the License.
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.property;
017:
018:        import org.geotools.data.DataStore;
019:        import org.geotools.data.DataStoreFactorySpi;
020:        import java.io.File;
021:        import java.io.FileNotFoundException;
022:        import java.io.IOException;
023:        import java.util.HashMap;
024:        import java.util.Map;
025:        import java.util.logging.Level;
026:        import java.util.logging.Logger;
027:
028:        /**
029:         * DataStore factory that creates {@linkplain org.geotools.data.property.PropertyDataStore}s
030:         *
031:         * @author jgarnett
032:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/demo/property/src/main/java/org/geotools/data/property/PropertyDataStoreFactory.java $
033:         * @version $Id: PropertyDataStoreFactory.java 27862 2007-11-12 19:51:19Z desruisseaux $
034:         */
035:        public class PropertyDataStoreFactory implements  DataStoreFactorySpi {
036:            private static final Logger LOGGER = org.geotools.util.logging.Logging
037:                    .getLogger(PropertyDataStoreFactory.class.getPackage()
038:                            .getName());
039:
040:            //    public DataSourceMetadataEnity createMetadata( Map params )
041:            //            throws IOException {
042:            //        if( !canProcess( params )){
043:            //            throw new IOException( "Provided params cannot be used to connect");
044:            //        }
045:            //        File dir = (File) DIRECTORY.lookUp( params );
046:            //        return new DataSourceMetadataEnity( dir, "Property file access for " + dir );        
047:            //    }    
048:
049:            /** DOCUMENT ME!  */
050:            public static final Param DIRECTORY = new Param("directory",
051:                    File.class, "Directory containting property files", true);
052:
053:            public static final Param NAMESPACE = new Param("namespace",
054:                    String.class, "namespace of datastore", false);
055:
056:            /**
057:             * DOCUMENT ME!
058:             *
059:             * @param params DOCUMENT ME!
060:             *
061:             * @return DOCUMENT ME!
062:             *
063:             * @throws IOException DOCUMENT ME!
064:             */
065:            public DataStore createDataStore(Map params) throws IOException {
066:                File dir = directoryLookup(params);
067:                String namespaceURI = (String) NAMESPACE.lookUp(params);
068:                if (dir.exists() && dir.isDirectory()) {
069:                    return new PropertyDataStore(dir, namespaceURI);
070:                } else {
071:                    throw new IOException("Directory is required");
072:                }
073:            }
074:
075:            /**
076:             * DOCUMENT ME!
077:             *
078:             * @param params DOCUMENT ME!
079:             *
080:             * @return DOCUMENT ME!
081:             *
082:             * @throws IOException DOCUMENT ME!
083:             */
084:            public DataStore createNewDataStore(Map params) throws IOException {
085:                File dir = directoryLookup(params);
086:
087:                if (dir.exists()) {
088:                    throw new IOException(dir + " already exists");
089:                }
090:
091:                boolean created;
092:
093:                created = dir.mkdir();
094:
095:                if (!created) {
096:                    throw new IOException("Could not create the directory"
097:                            + dir);
098:                }
099:
100:                String namespaceURI = (String) NAMESPACE.lookUp(params);
101:                return new PropertyDataStore(dir, namespaceURI);
102:            }
103:
104:            /**
105:             * DOCUMENT ME!
106:             *
107:             * @return DOCUMENT ME!
108:             */
109:            public String getDisplayName() {
110:                return "Properties";
111:            }
112:
113:            /**
114:             * DOCUMENT ME!
115:             *
116:             * @return DOCUMENT ME!
117:             */
118:            public String getDescription() {
119:                return "Allows access to Java Property files containing Feature information";
120:            }
121:
122:            /**
123:             * DOCUMENT ME!
124:             *
125:             * @return DOCUMENT ME!
126:             */
127:            public Param[] getParametersInfo() {
128:                return new Param[] { DIRECTORY, };
129:            }
130:
131:            /**
132:             * Test to see if this datastore is available, if it has all the
133:             * appropriate libraries to construct a datastore.  This datastore just
134:             * returns true for now.  This method is used for gui apps, so as to not
135:             * advertise data store capabilities they don't actually have.
136:             *
137:             * @return <tt>true</tt> if and only if this factory is available to create
138:             *         DataStores.
139:             *
140:             * @task REVISIT: I'm just adding this method to compile, maintainer should
141:             *       revisit to check for any libraries that may be necessary for
142:             *       datastore creations. ch.
143:             */
144:            public boolean isAvailable() {
145:                return true;
146:            }
147:
148:            /**
149:             * DOCUMENT ME!
150:             *
151:             * @param params DOCUMENT ME!
152:             *
153:             * @return DOCUMENT ME!
154:             */
155:            public boolean canProcess(Map params) {
156:                try {
157:                    directoryLookup(params);
158:                    return true;
159:                } catch (Exception erp) {
160:                    if (LOGGER.isLoggable(Level.FINE)) {
161:                        LOGGER.log(Level.FINE, "can't process parameters", erp);
162:                    }
163:                    return false;
164:                }
165:            }
166:
167:            /**
168:             */
169:            public Map getImplementationHints() {
170:                return java.util.Collections.EMPTY_MAP;
171:            }
172:
173:            /**
174:             * Lookups the directory containing property files in the params argument, and
175:             * returns the corresponding <code>java.io.File</code>.
176:             * <p>
177:             * The file is first checked for existence as an absolute path in the filesystem. If
178:             * such a directory is not found, then it is treated as a relative path, taking Java
179:             * system property <code>"user.dir"</code> as the base.
180:             * </p>
181:             * @param params
182:             * @throws IllegalArgumentException if directory is not a directory.
183:             * @throws FileNotFoundException if directory does not exists
184:             * @throws IOException if {@linkplain #DIRECTORY} doesn't find parameter in <code>params</code>
185:             * file does not exists.
186:             */
187:            private File directoryLookup(Map params) throws IOException,
188:                    FileNotFoundException, IllegalArgumentException {
189:                File directory = (File) DIRECTORY.lookUp(params);
190:                if (!directory.exists()) {
191:                    File currentDir = new File(System.getProperty("user.dir"));
192:                    directory = new File(currentDir, (String) params
193:                            .get(DIRECTORY.key));
194:                    if (!directory.exists()) {
195:                        throw new FileNotFoundException(directory
196:                                .getAbsolutePath());
197:                    }
198:                    if (!directory.isDirectory()) {
199:                        throw new IllegalArgumentException(directory
200:                                .getAbsolutePath()
201:                                + " is not a directory");
202:                    }
203:                }
204:                return directory;
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.