2 |
|
|
3 |
import java.util.ArrayList; |
import java.util.ArrayList; |
4 |
import java.util.Collections; |
import java.util.Collections; |
5 |
|
import java.util.LinkedHashSet; |
6 |
import java.util.List; |
import java.util.List; |
7 |
import java.util.Map; |
import java.util.Map; |
8 |
import java.util.TreeMap; |
import java.util.TreeMap; |
9 |
|
import java.util.TreeSet; |
10 |
|
|
11 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
12 |
import org.geotools.feature.NameImpl; |
import org.geotools.feature.NameImpl; |
13 |
import org.opengis.feature.type.Name; |
import org.opengis.feature.type.Name; |
14 |
|
|
15 |
import skrueger.AbstractAttributeMetadata; |
import skrueger.AttributeMetadataInterface; |
|
import skrueger.AttributeMetadata; |
|
16 |
import skrueger.QualityQuantizable; |
import skrueger.QualityQuantizable; |
17 |
import skrueger.i8n.Translation; |
import skrueger.i8n.Translation; |
18 |
|
|
23 |
* The {@link #get(Name)} and {@link #get(String)} methods will never return |
* The {@link #get(Name)} and {@link #get(String)} methods will never return |
24 |
* <code>null</code>, but rather create a default {@link AMD_IMPL} on-the-fly. |
* <code>null</code>, but rather create a default {@link AMD_IMPL} on-the-fly. |
25 |
*/ |
*/ |
26 |
public abstract class AttributeMetadataMap<AMD_IMPL extends AttributeMetadata> |
public abstract class AttributeMetadataMap<AMD_IMPL extends AttributeMetadataInterface> |
27 |
extends TreeMap<NameImpl, AMD_IMPL> implements |
extends TreeMap<Name, AMD_IMPL> implements |
28 |
Copyable<AttributeMetadataMap>, QualityQuantizable { |
Copyable<AttributeMetadataMap>, QualityQuantizable { |
29 |
|
|
30 |
private static final long serialVersionUID = 4936966916517396063L; |
private static final long serialVersionUID = 4936966916517396063L; |
72 |
* {@link Copyable} interface. |
* {@link Copyable} interface. |
73 |
*/ |
*/ |
74 |
@Override |
@Override |
75 |
public AttributeMetadataMap<? extends AttributeMetadata> copyTo(AttributeMetadataMap amdMap) { |
public AttributeMetadataMap<? extends AttributeMetadataInterface> copyTo(AttributeMetadataMap amdMap) { |
76 |
|
|
77 |
amdMap.clear(); |
amdMap.clear(); |
78 |
|
|
79 |
for (final NameImpl key : keySet()) { |
for (final Name key : keySet()) { |
80 |
final AMD_IMPL AMD_IMPL = get(key); |
final AMD_IMPL AMD_IMPL = get(key); |
81 |
amdMap.put(key, AMD_IMPL.copy()); |
amdMap.put(key, AMD_IMPL.copy()); |
82 |
} |
} |
85 |
|
|
86 |
/** |
/** |
87 |
* Returns the {@link AMD_IMPL} for a given {@link NameImpl}. May return |
* Returns the {@link AMD_IMPL} for a given {@link NameImpl}. May return |
88 |
* <code>null</code> or create a default {@link AttributeMetadata} depending |
* <code>null</code> or create a default {@link AttributeMetadataInterface} depending |
89 |
* on whether this method is overwritten. fly. |
* on whether this method is overwritten. fly. |
90 |
*/ |
*/ |
91 |
public AMD_IMPL get(final NameImpl name) { |
public AMD_IMPL get(final Name name) { |
92 |
return super.get(name); |
return super.get(name); |
93 |
} |
} |
94 |
|
|
95 |
/** |
/** |
96 |
* @Deprecated use get(Name name) or get(String localName) |
* @Deprecated use get(Name name) or get(String localName) |
97 |
*/ |
*/ |
98 |
|
@Deprecated |
99 |
@Override |
@Override |
|
@Deprecated |
|
100 |
public AMD_IMPL get(final Object key) { |
public AMD_IMPL get(final Object key) { |
101 |
LOGGER.error("PLEASE DONT USE get(Object) any MORE!"); |
LOGGER.error("PLEASE DONT USE get(Object) any MORE!"); |
102 |
return super.get(key); |
return super.get(key); |
144 |
* @return List of {@link AMD_IMPL} objects ordered by their weight. |
* @return List of {@link AMD_IMPL} objects ordered by their weight. |
145 |
* (heavier => further down) |
* (heavier => further down) |
146 |
*/ |
*/ |
147 |
public List<AMD_IMPL> sortedValues() { |
public TreeSet<AMD_IMPL> sortedValues() { |
148 |
final ArrayList<AMD_IMPL> list = new ArrayList<AMD_IMPL>(); |
final TreeSet<AMD_IMPL> list = new TreeSet<AMD_IMPL>(); |
149 |
list.addAll(values()); |
list.addAll(values()); |
150 |
Collections.sort(list); |
// Collections.sort(list); |
151 |
return list; |
return list; |
152 |
} |
} |
153 |
|
|
163 |
} |
} |
164 |
return list; |
return list; |
165 |
} |
} |
166 |
|
|
167 |
|
/** |
168 |
|
* Just for debuggung. Simply returns {@code super.put(.)}. |
169 |
|
* TODO: remove this method. |
170 |
|
*/ |
171 |
|
@Override |
172 |
|
public AMD_IMPL put(Name key, AMD_IMPL value) { |
173 |
|
return super.put(key, value); |
174 |
|
}; |
175 |
|
|
176 |
} |
} |