1 |
alfonx |
420 |
package skrueger.geotools; |
2 |
|
|
|
3 |
alfonx |
464 |
import java.util.ArrayList; |
4 |
|
|
import java.util.List; |
5 |
|
|
import java.util.SortedMap; |
6 |
alfonx |
420 |
import java.util.TreeMap; |
7 |
|
|
|
8 |
alfonx |
464 |
import org.geotools.feature.NameImpl; |
9 |
|
|
import org.opengis.feature.type.Name; |
10 |
alfonx |
420 |
|
11 |
alfonx |
464 |
import skrueger.AttributeMetadata; |
12 |
|
|
|
13 |
alfonx |
420 |
/** |
14 |
alfonx |
464 |
* An extension of TreeMap, that is copyable in the sense of the {@link Copyable} interface |
15 |
alfonx |
420 |
*/ |
16 |
alfonx |
464 |
public class AttributeMetadataMap extends TreeMap<Name, AttributeMetadata> |
17 |
alfonx |
420 |
implements Copyable<AttributeMetadataMap> { |
18 |
|
|
|
19 |
alfonx |
464 |
/** |
20 |
|
|
* @Deprecated use get(Name name) or get(String localName) |
21 |
|
|
*/ |
22 |
|
|
@Deprecated |
23 |
|
|
public AttributeMetadata get(Object key) { |
24 |
|
|
return super.get(key); |
25 |
alfonx |
420 |
} |
26 |
|
|
|
27 |
alfonx |
464 |
public AttributeMetadata get(Name name) { |
28 |
|
|
final AttributeMetadata attributeMetadata = super.get(name); |
29 |
|
|
if (attributeMetadata == null) { |
30 |
|
|
put(name,new AttributeMetadata(name)); |
31 |
|
|
return super.get(name); |
32 |
|
|
} |
33 |
|
|
return attributeMetadata; |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
public AttributeMetadata get(String localName) { |
37 |
|
|
return this.get(new NameImpl(localName)); |
38 |
|
|
} |
39 |
|
|
|
40 |
alfonx |
420 |
@Override |
41 |
|
|
public AttributeMetadataMap copyTo(AttributeMetadataMap amdMap) { |
42 |
|
|
|
43 |
|
|
amdMap.clear(); |
44 |
|
|
|
45 |
alfonx |
464 |
for (Name key : keySet()) { |
46 |
|
|
AttributeMetadata attributeMetaData = get(key); |
47 |
alfonx |
420 |
amdMap.put(key, attributeMetaData.copy()); |
48 |
|
|
} |
49 |
|
|
return amdMap; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
@Override |
53 |
|
|
public AttributeMetadataMap copy() { |
54 |
|
|
AttributeMetadataMap copy = new AttributeMetadataMap(); |
55 |
|
|
return copyTo(copy); |
56 |
|
|
} |
57 |
alfonx |
464 |
|
58 |
|
|
public List<AttributeMetadata> sortedValues() { |
59 |
|
|
ArrayList<AttributeMetadata> list = new ArrayList<AttributeMetadata>(); |
60 |
|
|
list.addAll(values()); |
61 |
|
|
return list; |
62 |
|
|
} |
63 |
alfonx |
420 |
} |