Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2008, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.data;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.geotools.util.KVP;
import org.geotools.util.SimpleInternationalString;
import org.geotools.util.factory.Factory;
import org.opengis.feature.Feature;
import org.opengis.feature.type.FeatureType;
import org.opengis.util.InternationalString;
/**
* Constructs a live DataAccess from a set of connection parameters.
*
*
The following example shows how a user might connect to a PostGIS database, and maintain the
* resulting datastore in a Registry:
*
*
*
* The required parameters are described by the getParameterInfo() method. Client
*
*
Implementation Notes
*
*
An instance of this interface should exist for all DataAccess implementations that want to
* advantage of the dynamic plug-in system. In addition to implementing this interface a DataAccess
* implementation should provide a services file:
*
*
The file should contain a single line which gives the full name of the implementing class.
*
*
Example:
* e.g.
* org.geotools.data.mytype.MyTypeDataSourceFacotry
*
*
The factories are never called directly by client code, instead the DataStoreFinder class is
* used.
*
* @author Jody Garnett (Refractions Research)
*/
public interface DataAccessFactory extends Factory {
/**
* Construct a live DataAccess using the connection parameters provided.
*
*
You can think of this class as setting up a connection to the back end data source. The
* required parameters are described by the getParameterInfo() method.
*
*
Magic Params: the following params are magic and are honoured by convention by the
* GeoServer and uDig application.
*
*
*
"user": is taken to be the user name
*
"passwd": is taken to be the password
*
"namespace": is taken to be the namespace prefix (and will be kept in sync with
* GeoServer namespace management.
*
*
* When we eventually move over to the use of OpperationalParam we will have to find someway to
* codify this convention.
*
* @param params The full set of information needed to construct a live data store. Typical key
* values for the map include: url - location of a resource, used by file reading
* datasources. dbtype - the type of the database to connect to, e.g. postgis, mysql
* @return The created DataStore, this may be null if the required resource was not found or if
* insufficent parameters were given. Note that canProcess() should have returned false if
* the problem is to do with insuficent parameters.
* @throws IOException if there were any problems setting up (creating or connecting) the
* datasource.
*/
DataAccess extends FeatureType, ? extends Feature> createDataStore(
Map params) throws IOException;
/**
* Name suitable for display to end user.
*
*
A non localized display name for this data store type.
*
* @return A short name suitable for display in a user interface.
*/
String getDisplayName();
/**
* Describe the nature of the datasource constructed by this factory.
*
*
A non localized description of this data store type.
*
* @return A human readable description that is suitable for inclusion in a list of available
* datasources.
*/
String getDescription();
/**
* MetaData about the required Parameters (for createDataStore).
*
*
* Interpretation of FeatureDescriptor values:
*
*
*
*
* getDisplayName(): Gets the localized display name of this feature.
*
*
* getName(): Gets the programmatic name of this feature (used as the key
* in params)
*
*
* getShortDescription(): Gets the short description of this feature.
*
*
* @return Param array describing the Map for createDataStore
*/
Param[] getParametersInfo();
/**
* Test to see if this factory is suitable for processing the data pointed to by the params map.
*
*
If this datasource requires a number of parameters then this mehtod should check that they
* are all present and that they are all valid. If the datasource is a file reading data source
* then the extentions or mime types of any files specified should be checked. For example, a
* Shapefile datasource should check that the url param ends with shp, such tests should be case
* insensative.
*
* @param params The full set of information needed to construct a live data source.
* @return booean true if and only if this factory can process the resource indicated by the
* param set and all the required params are pressent.
*/
default boolean canProcess(java.util.Map params) {
if (params == null) {
return false;
}
Param arrayParameters[] = getParametersInfo();
for (int i = 0; i < arrayParameters.length; i++) {
Param param = arrayParameters[i];
Object value;
if (!params.containsKey(param.key)) {
if (param.required) {
return false; // missing required key!
} else {
continue;
}
}
try {
value = param.lookUp(params);
} catch (IOException e) {
// could not upconvert/parse to expected type!
// even if this parameter is not required
// we are going to refuse to process
// these params
return false;
}
if (value == null) {
if (param.required) {
return (false);
}
} else {
if (!param.type.isInstance(value)) {
return false; // value was not of the required type
}
if (param.metadata != null) {
// check metadata
if (param.metadata.containsKey(Param.OPTIONS)) {
java.util.List