Revision 23893

View differences:

branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/DefaultDataIndexes.java
38 38
import org.gvsig.fmap.data.feature.FeatureType;
39 39

  
40 40
/**
41
 * Renombrar a Indexes--
42
 * 
43
 * TODO Crear interfaz y Default
44
 * 
45
 * 
46
 * API - Index
47
 * 		 AbstractIndex
48
 * Impl   ^
49
 * SPI - IndexProvider (initialize)
50
 *       AbstractIndexProvider
51
 * 
52
 * Eliminar factorias (logica de create index pasa a initialize())
53
 * Eliminar abstractFactory (l?gica pasa a DataManager).
54
 * 
55
 * 
56
 * 	// DATAMANAGER
57
	
58
	public List getIndexProviders(int dataType); (of names)
59
	
60
	public registerIndexProvider(IndexProvider);
61
	
62
	public IndexProvider createIndexProvider(store, ftype, att, [names]);
63
 * 
64
 *  public setDefaultIndexProvider(int dataType, String name);
65
 *  
66
 *  public File getTemporaryDirectory();
67
 *  
68
 *  INDEXES
69
 *  -------
70
 *  
71
 *  Lista plana por nombre.
72
 *  Quitar IndexParameters
73
 * 
74
 * 
75
 * 
76
 * This class provides access to a FeatureStore local indexes.
77
 * This class holds the correspondence (FeatureType, columName) -> Index
78
 * TODO there is not persistence and works only in memory
41
 * This class provides access to a FeatureStore local indexes either by
42
 * FeatureType and attrName or by index name.
79 43
 * @author jyarza
80 44
 */
81 45
public class DefaultDataIndexes implements DataIndexes {
82 46

  
47
	// Access by FeatureType and attribute name
83 48
	private Map featureTypes = new HashMap();
49
	
50
	// Access by DataIndex name
51
	private Map names = new HashMap();
84 52

  
85 53
	/**
86
	 * Creates an empty IndexRegistry for the given FeatureStore
54
	 * Creates an empty DataIndexes for the given FeatureStore
87 55
	 * 
88 56
	 * @param store
89
	 *            FeatureStore to whom this IndexRegistry belongs
57
	 *            FeatureStore to whom this belongs
90 58
	 * @throws DataException
91 59
	 */
92 60
	public DefaultDataIndexes(FeatureStore store) throws DataException {
......
100 68
	/* (non-Javadoc)
101 69
	 * @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(org.gvsig.fmap.data.feature.FeatureType, java.lang.String)
102 70
	 */
103
	public DataIndex getDataIndex(FeatureType fType, String colName) {
71
	public DataIndex getDataIndex(FeatureType fType, String attrName) {
104 72
		Map indexes = (Map) featureTypes.get(fType);
105 73
		if (indexes != null) {
106
			return (DataIndex) (featureTypes.get(fType));
74
			return (DataIndex) (indexes.get(attrName));
107 75
		}
108 76
		return null;
109 77
	}
......
112 80
	 * @see org.gvsig.fmap.data.index.DataIndexes#getDataIndex(java.lang.String)
113 81
	 */
114 82
	public DataIndex getDataIndex(String name) {
115
		//TODO
116
		return null;
83
		return (DataIndex) names.get(name);
117 84
	}
118 85

  
119 86
	/* (non-Javadoc)
120 87
	 * @see org.gvsig.fmap.data.index.DataIndexes#addIndex(org.gvsig.fmap.data.feature.FeatureType, java.lang.String, org.gvsig.fmap.data.feature.DataIndex)
121 88
	 */
122
	public void addIndex(FeatureType fType, String colName, DataIndex index) {
89
	public void addIndex(FeatureType fType, String attrName, DataIndex index) {
123 90
		Map indexes = (Map) featureTypes.get(fType);
124 91
		if (indexes == null) {
125 92
			// This would mean that a new feature type has been added to the FeatureStore since this Indexes was created
126 93
			indexes = new HashMap();
127 94
			featureTypes.put(fType, indexes);
128 95
		}
129
		indexes.put(colName, index);
96
		indexes.put(attrName, index);
97
		
98
		// By name
99
		names.put(index.getName(), index);
130 100
	}
131 101

  
132 102
	/* (non-Javadoc)
133 103
	 * @see org.gvsig.fmap.data.index.DataIndexes#contains(org.gvsig.fmap.data.feature.FeatureType, java.lang.String)
134 104
	 */
135
	public boolean contains(FeatureType fType, String colName) {
105
	public boolean contains(FeatureType fType, String attrName) {
136 106
		Map map = (Map) featureTypes.get(fType);
137
		return map == null ? false : map.containsKey(colName);
107
		return map == null ? false : map.containsKey(attrName);
138 108
	}
109
	
110
	public boolean contains(String name) {
111
		return names.containsKey(name);
112
	}
139 113
}

Also available in: Unified diff