Revision 24366
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataManager.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.gvsig.fmap.data.exceptions.InitializeException; |
6 | 6 |
import org.gvsig.fmap.data.exceptions.ProviderNotRegisteredException; |
7 |
import org.gvsig.fmap.data.resource.ResourceManager; |
|
7 | 8 |
import org.gvsig.tools.evaluator.Evaluator; |
8 | 9 |
|
10 |
/** |
|
11 |
* This class contains all DAL specific services (note that resource management is {@link ResourceManager}'s responsibility) |
|
12 |
* are not related to resources. |
|
13 |
* |
|
14 |
*/ |
|
9 | 15 |
public interface DataManager { |
10 | 16 |
|
11 | 17 |
/** |
... | ... | |
22 | 28 |
*/ |
23 | 29 |
|
24 | 30 |
/** |
25 |
* Start a instance of the solicited parameters inicialize the instance name |
|
26 |
* and returns it. |
|
31 |
* Creates, initializes and returns an instance of the solicited parameters given the name with which they are registered. |
|
27 | 32 |
* |
28 | 33 |
* @param String |
29 |
* name |
|
34 |
* name with which the parameters type were registered
|
|
30 | 35 |
* @throws InitializeException |
31 | 36 |
* TODO |
32 | 37 |
* @throws ProviderNotRegisteredException |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/FeatureIndexes.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import java.util.Iterator; |
31 | 31 |
|
32 |
import org.gvsig.fmap.data.feature.spi.FeatureSetProvider; |
|
33 |
import org.gvsig.tools.evaluator.Evaluator; |
|
32 | 34 |
|
35 |
|
|
33 | 36 |
public interface FeatureIndexes { |
34 | 37 |
|
35 |
/* |
|
36 |
* Returns an Index given the FeatureType and the name of the column. |
|
37 |
* If the column has no index then this method returns <code>null</code>. |
|
38 |
* @param fType FeatureType to which belongs the index |
|
39 |
* @param colName name of the column |
|
40 |
* @return if the index exists then this method returns the index, otherwise it returns null. |
|
38 |
|
|
39 |
/** |
|
40 |
* Returns a FeatureIndex given the name with which it was created. |
|
41 |
* |
|
42 |
* @param name FeatureIndex name |
|
43 |
* |
|
44 |
* @return FeatureIndex or null if it is not found. |
|
41 | 45 |
*/ |
42 |
//public DataIndex getDataIndex(FeatureType fType, String[] attrName); |
|
43 |
|
|
44 | 46 |
public FeatureIndex getFeatureIndex(String name); |
45 | 47 |
|
46 | 48 |
/** |
49 |
* Using the given evaluator attributes, choose and use an appropriate index |
|
50 |
* to obtain a FeatureSetProvider. If no index can be applied, then this method returns null |
|
47 | 51 |
* |
48 |
* @return |
|
52 |
* @param evaluator |
|
53 |
* @return FeatureSetProvider or null if could not find any appropriate index. |
|
54 |
* |
|
49 | 55 |
*/ |
56 |
public FeatureSetProvider getFeatureSet(Evaluator evaluator); |
|
57 |
|
|
58 |
/** |
|
59 |
* Returns an iterator over the indexes. Elements are of type FeatureIndex. |
|
60 |
* |
|
61 |
* @return Iterator over the FeatureIndex(es). |
|
62 |
*/ |
|
50 | 63 |
public Iterator iterator(); |
51 | 64 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/DefaultFeatureIndexes.java | ||
---|---|---|
36 | 36 |
import org.gvsig.fmap.data.exceptions.DataException; |
37 | 37 |
import org.gvsig.fmap.data.feature.FeatureIndex; |
38 | 38 |
import org.gvsig.fmap.data.feature.FeatureIndexes; |
39 |
import org.gvsig.fmap.data.feature.FeatureType; |
|
40 | 39 |
import org.gvsig.fmap.data.feature.exceptions.FeatureIndexException; |
41 | 40 |
import org.gvsig.fmap.data.feature.spi.FeatureSetProvider; |
42 | 41 |
import org.gvsig.fmap.data.feature.spi.index.FeatureIndexProviderServices; |
... | ... | |
44 | 43 |
import org.gvsig.tools.evaluator.EvaluatorFieldValue; |
45 | 44 |
|
46 | 45 |
/** |
47 |
* This class provides access to a FeatureStore local indexes either by |
|
48 |
* FeatureType and attrName or by index name. |
|
46 |
* This class provides access to a FeatureStore local indexes and also |
|
47 |
* decides which index to use given an evaluator containing the filter expression. |
|
48 |
* |
|
49 | 49 |
* @author jyarza |
50 |
*/ |
|
50 |
*/
|
|
51 | 51 |
public class DefaultFeatureIndexes implements FeatureIndexes { |
52 | 52 |
|
53 |
// Access by FeatureType and attribute name |
|
54 |
private Map featureTypes = new HashMap(); |
|
55 |
|
|
56 | 53 |
// Access by index name |
57 |
private Map names = new HashMap();
|
|
58 |
|
|
54 |
private Map names; |
|
55 |
// Store to which this belongs |
|
59 | 56 |
private DefaultFeatureStore store; |
60 | 57 |
|
61 | 58 |
/** |
... | ... | |
67 | 64 |
*/ |
68 | 65 |
public DefaultFeatureIndexes(DefaultFeatureStore store) |
69 | 66 |
throws DataException { |
67 |
names = new HashMap(); |
|
70 | 68 |
this.store = store; |
71 |
Iterator it = store.getFeatureTypes().iterator(); |
|
72 |
while (it.hasNext()) { |
|
73 |
FeatureType type = (FeatureType) it.next(); |
|
74 |
featureTypes.put(type, new HashMap()); |
|
75 |
} |
|
76 | 69 |
} |
77 | 70 |
|
78 |
/** |
|
79 |
* @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(org.gvsig.fmap.data.feature.FeatureType, |
|
80 |
* java.lang.String) |
|
81 |
* @deprecated |
|
82 |
*/ |
|
83 |
public FeatureIndex getFeatureIndex(FeatureType fType, String attrName) { |
|
84 |
Map indexes = (Map) featureTypes.get(fType); |
|
85 |
if (indexes != null) { |
|
86 |
return (FeatureIndex) (indexes.get(attrName)); |
|
87 |
} |
|
88 |
return null; |
|
89 |
} |
|
90 |
|
|
91 | 71 |
/* (non-Javadoc) |
92 | 72 |
* @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(java.lang.String) |
93 | 73 |
*/ |
... | ... | |
99 | 79 |
* @see org.gvsig.fmap.data.index.DataIndexes#addIndex(org.gvsig.fmap.data.feature.FeatureType, java.lang.String, org.gvsig.fmap.data.feature.DataIndex) |
100 | 80 |
*/ |
101 | 81 |
public void addIndex(FeatureIndexProviderServices index) { |
102 |
Map indexes = (Map) featureTypes.get(index.getFeatureType()); |
|
103 |
if (indexes == null) { |
|
104 |
// This would mean that a new feature type has been added to the FeatureStore since this Indexes was created |
|
105 |
indexes = new HashMap(); |
|
106 |
featureTypes.put(index.getFeatureType(), indexes); |
|
107 |
} |
|
108 |
// FIXME Taking into account only the first attribute |
|
109 |
indexes.put(index.getAttributeNames().get(0), index); |
|
110 |
|
|
111 | 82 |
// By name |
112 | 83 |
names.put(index.getName(), index); |
113 | 84 |
} |
114 | 85 |
|
115 |
/** |
|
116 |
* @see org.gvsig.fmap.data.index.DataIndexes#contains(org.gvsig.fmap.data.feature.FeatureType, |
|
117 |
* java.lang.String) |
|
118 |
* @deprecated |
|
119 |
*/ |
|
120 |
public boolean contains(FeatureType fType, String attrName) { |
|
121 |
Map map = (Map) featureTypes.get(fType); |
|
122 |
return map == null ? false : map.containsKey(attrName); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* @deprecated |
|
127 |
*/ |
|
128 |
public boolean contains(String name) { |
|
129 |
return names.containsKey(name); |
|
130 |
} |
|
131 |
|
|
132 | 86 |
public Iterator iterator() { |
133 | 87 |
return names.values().iterator(); |
134 | 88 |
} |
135 | 89 |
|
136 | 90 |
/** |
137 |
* Obtain a FeatureSetProvider over an index with the attributes used in the
|
|
138 |
* evaluator or null if can't apply any index.
|
|
91 |
* Using the given evaluator attributes, choose and use an appropriate index
|
|
92 |
* to obtain a FeatureSetProvider. If no index can be applied, then this method returns null
|
|
139 | 93 |
* |
140 | 94 |
* @param evaluator |
141 |
* @return FeatureSetProvider or null if not has index availables.
|
|
95 |
* @return FeatureSetProvider or null if could not find any appropriate index.
|
|
142 | 96 |
* |
143 | 97 |
*/ |
144 | 98 |
public FeatureSetProvider getFeatureSet(Evaluator evaluator) { |
... | ... | |
232 | 186 |
return index.apply(); |
233 | 187 |
|
234 | 188 |
} catch (Exception e) { |
235 |
this.store.getLogger().error("Error buscando indice que aplicar.",
|
|
189 |
this.store.getLogger().error("Error searching for an index to apply.",
|
|
236 | 190 |
e); |
237 | 191 |
return null; |
238 | 192 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataExplorerParameters.java | ||
---|---|---|
28 | 28 |
package org.gvsig.fmap.data; |
29 | 29 |
|
30 | 30 |
|
31 |
|
|
31 |
/** |
|
32 |
* DataExplorer parameter container. Adds a method to obtain the |
|
33 |
* specific DataExplorerType described by this parameters. |
|
34 |
* |
|
35 |
*/ |
|
32 | 36 |
public interface DataExplorerParameters extends DataParameters { |
33 | 37 |
|
38 |
/** |
|
39 |
* Returns the DataExplorerType which describes the type of the DataExplorer represented |
|
40 |
* by this DataExplorerParameters |
|
41 |
* |
|
42 |
* @return an instance of DataExplorerType |
|
43 |
*/ |
|
34 | 44 |
public DataExplorerType getType(); |
35 | 45 |
|
36 | 46 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DALLocator.java | ||
---|---|---|
5 | 5 |
import org.gvsig.tools.locator.Locator; |
6 | 6 |
import org.gvsig.tools.locator.LocatorException; |
7 | 7 |
|
8 |
/** |
|
9 |
* @see {@link Locator} |
|
10 |
* |
|
11 |
* This locator is the entry point of gvSIG's DAL, providing access to all DAL services. |
|
12 |
* DAL services are grouped in two managers {@link DataManager} and {@link ResourceManager}. |
|
13 |
* |
|
14 |
* This locator offers methods for registering as well as for obtaining both managers' unique instances. |
|
15 |
* |
|
16 |
*/ |
|
8 | 17 |
public class DALLocator extends AbstractLocator { |
9 | 18 |
|
10 | 19 |
private static final String LOCATOR_NAME = "DALLocator"; |
11 | 20 |
|
21 |
/** |
|
22 |
* DataManager name used by the locator to access the instance |
|
23 |
*/ |
|
12 | 24 |
public static final String DATA_MANAGER_NAME = "DataManager"; |
13 | 25 |
|
14 | 26 |
private static final String DATA_MANAGER_DESCRIPTION = "DataManager of gvSIG Data Access Library"; |
15 | 27 |
|
28 |
/** |
|
29 |
* ResourceManager name used by the locator to access the instance |
|
30 |
*/ |
|
16 | 31 |
public static final String RESOURCE_MANAGER_NAME = "ResourceManager"; |
17 | 32 |
|
18 | 33 |
private static final String RESOURCE_MANAGER_DESCRIPTION = "ResourceManager of gvSIG Data Access Library"; |
... | ... | |
31 | 46 |
return instance; |
32 | 47 |
} |
33 | 48 |
|
49 |
/** |
|
50 |
* Returns the Locator name. |
|
51 |
* |
|
52 |
* @return String containing the locator name. |
|
53 |
*/ |
|
34 | 54 |
public String getLocatorName() { |
35 | 55 |
return LOCATOR_NAME; |
36 | 56 |
} |
... | ... | |
59 | 79 |
clazz); |
60 | 80 |
} |
61 | 81 |
|
82 |
/** |
|
83 |
* Registers a class as the default DataManager. |
|
84 |
* |
|
85 |
* @param clazz |
|
86 |
* implementing the DataManager interface |
|
87 |
*/ |
|
62 | 88 |
public static void registerDefaultDataManager(Class clazz) { |
63 | 89 |
getInstance().registerDefault(DATA_MANAGER_NAME, DATA_MANAGER_DESCRIPTION, |
64 | 90 |
clazz); |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DALLibrary.java | ||
---|---|---|
6 | 6 |
import org.gvsig.tools.locator.BaseLibrary; |
7 | 7 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
8 | 8 |
|
9 |
/** |
|
10 |
* Initializes gvSIG's desktop DAL by registering the default implementation for {@link DataManager} |
|
11 |
* and {@link ResourceManager}. |
|
12 |
* |
|
13 |
*/ |
|
9 | 14 |
public class DALLibrary extends BaseLibrary { |
10 | 15 |
|
11 | 16 |
public void initialize() throws ReferenceNotRegisteredException { |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataExplorer.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import org.gvsig.fmap.data.exceptions.DataException; |
6 | 6 |
|
7 |
/** |
|
8 |
* This interface provides a list of the available data stores in a server. |
|
9 |
* As its name indicates, it is used to explore the contents of a server. |
|
10 |
* |
|
11 |
*/ |
|
7 | 12 |
public interface DataExplorer { |
8 | 13 |
|
14 |
/** |
|
15 |
* Returns the DataExplorer's name |
|
16 |
* |
|
17 |
* @return String containing this DataExplorer's name |
|
18 |
*/ |
|
9 | 19 |
public String getName(); |
10 |
|
|
20 |
|
|
21 |
/** |
|
22 |
* Indicates whether this DataExplorer can be created. |
|
23 |
* |
|
24 |
* @return true if this DataExplorer can be created or false otherwise. |
|
25 |
*/ |
|
11 | 26 |
public boolean canCreate(); |
12 | 27 |
|
13 |
public List list() throws DataException; // List of DataStoreParameter |
|
28 |
/** |
|
29 |
* Provides a list of available DataStoreParameters in the server. |
|
30 |
* |
|
31 |
* @return list of DataStoreParameters |
|
32 |
* |
|
33 |
* @throws DataException |
|
34 |
*/ |
|
35 |
public List list() throws DataException; |
|
14 | 36 |
|
37 |
/** |
|
38 |
* Adds a DataStoreParameters to this DataExplorer. |
|
39 |
* |
|
40 |
* @param |
|
41 |
* parameters, an instance of DataStoreParameters. |
|
42 |
* @return true if the DataStoreParameters were successfully added, false otherwise. |
|
43 |
* |
|
44 |
* @throws DataException |
|
45 |
*/ |
|
15 | 46 |
public boolean add(DataStoreParameters parameters) |
16 | 47 |
throws DataException; |
17 | 48 |
|
49 |
/** |
|
50 |
* |
|
51 |
* @param parameters |
|
52 |
* @throws DataException |
|
53 |
*/ |
|
18 | 54 |
void remove(DataStoreParameters parameters) throws DataException; |
19 | 55 |
|
56 |
/** |
|
57 |
* |
|
58 |
* @param storeName |
|
59 |
* @return |
|
60 |
*/ |
|
20 | 61 |
public DataStoreParameters getCreationParameters(String storeName); |
21 | 62 |
|
63 |
/** |
|
64 |
* |
|
65 |
* @throws DataException |
|
66 |
*/ |
|
22 | 67 |
public void dispose() throws DataException; |
23 | 68 |
|
69 |
/** |
|
70 |
* |
|
71 |
* @return |
|
72 |
*/ |
|
24 | 73 |
public DataExplorerParameters getParameters(); |
25 | 74 |
|
26 | 75 |
} |
branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/DataExplorerType.java | ||
---|---|---|
1 | 1 |
package org.gvsig.fmap.data; |
2 | 2 |
|
3 |
/** |
|
4 |
* This interface describes a DataExplorerType |
|
5 |
* by providing its name and description. |
|
6 |
*/ |
|
3 | 7 |
public interface DataExplorerType { |
4 | 8 |
|
9 |
/** |
|
10 |
* Returns the name of this DataExplorerType |
|
11 |
* |
|
12 |
* @return String containing the name of this DataExplorerType |
|
13 |
*/ |
|
5 | 14 |
public String getName(); |
6 | 15 |
|
16 |
/** |
|
17 |
* Returns the description of this DataExplorerType |
|
18 |
* |
|
19 |
* @return String containing the description of this DataExplorerType |
|
20 |
*/ |
|
7 | 21 |
public String getDescription(); |
8 | 22 |
|
9 | 23 |
} |
Also available in: Unified diff