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