Revision 44262 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultStoresRepository.java
DefaultStoresRepository.java | ||
---|---|---|
8 | 8 |
import org.gvsig.fmap.dal.DataStoreParameters; |
9 | 9 |
import org.gvsig.fmap.dal.StoresRepository; |
10 | 10 |
import org.gvsig.tools.util.GetItemByKey; |
11 |
import org.gvsig.tools.util.UnmodifiableBasicMap; |
|
11 | 12 |
import org.gvsig.tools.util.UnmodifiableBasicSet; |
12 | 13 |
import org.gvsig.tools.util.UnmodifiableBasicSetAdapter; |
14 |
import org.gvsig.tools.util.UnmodifiableBasicSetChained; |
|
13 | 15 |
|
14 | 16 |
/** |
15 | 17 |
* |
... | ... | |
19 | 21 |
public class DefaultStoresRepository implements StoresRepository { |
20 | 22 |
|
21 | 23 |
private final Map<String,DataStoreParameters> repository; |
22 |
private final Map<String,GetItemByKey<String,DataStoreParameters>> delegateds;
|
|
24 |
private final Map<String,UnmodifiableBasicMap<String,DataStoreParameters>> delegateds;
|
|
23 | 25 |
|
24 | 26 |
public DefaultStoresRepository() { |
25 | 27 |
this.repository = new HashMap<>(); |
26 | 28 |
this.delegateds = new HashMap<>(); |
27 | 29 |
} |
28 | 30 |
|
29 |
public void add(String name, GetItemByKey<String,DataStoreParameters> repository) {
|
|
31 |
public void add(String name, UnmodifiableBasicMap<String,DataStoreParameters> repository) {
|
|
30 | 32 |
this.delegateds.put(name, repository); |
31 | 33 |
} |
32 | 34 |
|
... | ... | |
65 | 67 |
|
66 | 68 |
@Override |
67 | 69 |
public boolean isEmpty() { |
68 |
return this.repository.isEmpty(); |
|
70 |
if( !this.repository.isEmpty() ) { |
|
71 |
return false; |
|
72 |
} |
|
73 |
for (UnmodifiableBasicMap<String,DataStoreParameters> theRepository : this.delegateds.values()) { |
|
74 |
if( !theRepository.isEmpty() ) { |
|
75 |
return false; |
|
76 |
} |
|
77 |
} |
|
78 |
return true; |
|
69 | 79 |
} |
70 | 80 |
|
71 | 81 |
@Override |
... | ... | |
89 | 99 |
|
90 | 100 |
@Override |
91 | 101 |
public int size() { |
92 |
return this.repository.size(); |
|
102 |
int sz = this.repository.size(); |
|
103 |
for (UnmodifiableBasicMap<String,DataStoreParameters> theRepository : this.delegateds.values()) { |
|
104 |
sz += theRepository.size(); |
|
105 |
} |
|
106 |
return sz; |
|
93 | 107 |
} |
94 | 108 |
|
95 | 109 |
@Override |
... | ... | |
111 | 125 |
|
112 | 126 |
@Override |
113 | 127 |
public UnmodifiableBasicSet<String> keySet() { |
114 |
return new UnmodifiableBasicSetAdapter(this.repository.keySet()); |
|
128 |
UnmodifiableBasicSet[] sets = new UnmodifiableBasicSet[this.delegateds.size()+1]; |
|
129 |
int i=0; |
|
130 |
sets[i++] = new UnmodifiableBasicSetAdapter(this.repository.keySet()); |
|
131 |
for (UnmodifiableBasicMap<String,DataStoreParameters> theRepository : this.delegateds.values()) { |
|
132 |
sets[i++] = theRepository.keySet(); |
|
133 |
} |
|
134 |
return new UnmodifiableBasicSetChained(sets); |
|
115 | 135 |
} |
116 | 136 |
|
117 | 137 |
} |
Also available in: Unified diff