001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-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.file;
017:
018: import java.io.IOException;
019: import java.util.Collections;
020: import java.util.Map;
021:
022: import org.geotools.data.DataStore;
023: import org.geotools.data.DataStoreFactorySpi;
024:
025: /**
026: * A factory for VPFFileStore.
027: * The file store is a singleton and the factory
028: * acts as the container.
029: * This class does not do anything special at all
030: * and could easily be circumvented,
031: * but is here for completeness.
032: *
033: * @author jeff yutzler
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/vpf/src/main/java/org/geotools/data/vpf/file/VPFFileFactory.java $
035: */
036: public class VPFFileFactory implements DataStoreFactorySpi {
037: private final VPFFileStore store = new VPFFileStore();
038: private static VPFFileFactory instance = null;
039:
040: /**
041: * Default constructor. Does nothing!
042: */
043: private VPFFileFactory() {
044: }
045:
046: /*
047: * (non-Javadoc)
048: * @see org.geotools.data.DataStoreFactorySpi#createDataStore(java.util.Map)
049: */
050: public DataStore createDataStore(Map params) throws IOException {
051: return store;
052: }
053:
054: /* (non-Javadoc)
055: * @see org.geotools.data.DataStoreFactorySpi#createMetadata(java.util.Map)
056: */
057: // public DataSourceMetadataEnity createMetadata(Map params)
058: // throws IOException {
059: // // TODO Auto-generated method stub
060: // return null;
061: // }
062: /* (non-Javadoc)
063: * @see org.geotools.data.DataStoreFactorySpi#createNewDataStore(java.util.Map)
064: */
065: public DataStore createNewDataStore(Map params) throws IOException {
066: throw new UnsupportedOperationException(
067: "Only existing data stores may be created.");
068: }
069:
070: /* (non-Javadoc)
071: * @see org.geotools.data.DataStoreFactorySpi#getDisplayName()
072: */
073: public String getDisplayName() {
074: // TODO Auto-generated method stub
075: return null;
076: }
077:
078: /* (non-Javadoc)
079: * @see org.geotools.data.DataStoreFactorySpi#getDescription()
080: */
081: public String getDescription() {
082: // TODO Auto-generated method stub
083: return null;
084: }
085:
086: /* (non-Javadoc)
087: * @see org.geotools.data.DataStoreFactorySpi#getParametersInfo()
088: */
089: public Param[] getParametersInfo() {
090: // TODO Auto-generated method stub
091: return null;
092: }
093:
094: /* (non-Javadoc)
095: * @see org.geotools.data.DataStoreFactorySpi#canProcess(java.util.Map)
096: */
097: public boolean canProcess(Map params) {
098: // boolean result = false;
099: // Object object;
100: // File file;
101: // if (params.containsKey("Path Name")){
102: // object = params.get("Path Name");
103: // if(object instanceof File){
104: // file = (File)object;
105: // }else {
106: // file = new File(object.toString());
107: // }
108: // if(file.exists() && file.isFile() && !file.isDirectory()) {
109: // result = true;
110: // }
111: // }
112: // return result;
113: return true;
114: }
115:
116: /* (non-Javadoc)
117: * @see org.geotools.data.DataStoreFactorySpi#isAvailable()
118: */
119: public boolean isAvailable() {
120: return true;
121: }
122:
123: /**
124: * Returns the singleton instance
125: * @return Returns the instance.
126: */
127: public static VPFFileFactory getInstance() {
128: if (instance == null) {
129: instance = new VPFFileFactory();
130: }
131: return instance;
132: }
133:
134: public VPFFile getFile(String pathName) throws IOException {
135: return (VPFFile) store.getSchema(pathName);
136: }
137:
138: /**
139: * Returns the implementation hints. The default implementation returns en empty map.
140: */
141: public Map getImplementationHints() {
142: return Collections.EMPTY_MAP;
143: }
144:
145: /**
146: * Close all currently open files.
147: */
148: public void reset() {
149: store.reset();
150: }
151: }
|