/[schmitzm]/trunk/src/skrueger/geotools/AttributeMetadataMap.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/AttributeMetadataMap.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 420 by alfonx, Thu Oct 1 20:22:48 2009 UTC revision 474 by alfonx, Thu Oct 15 14:04:16 2009 UTC
# Line 1  Line 1 
1  package skrueger.geotools;  package skrueger.geotools;
2    
3    import java.util.ArrayList;
4    import java.util.List;
5  import java.util.TreeMap;  import java.util.TreeMap;
6    
7  import skrueger.AttributeMetaData;  import org.geotools.feature.NameImpl;
8    import org.opengis.feature.type.Name;
9    
10    import skrueger.AttributeMetadata;
11    
12  /**  /**
13   * An extension of TreeMap, that is clonable in the sense of   * An extension of TreeMap, that is copyable in the sense of the {@link Copyable} interface
  *  
  * @author stefan  
  *  
14   */   */
15  public class AttributeMetadataMap extends TreeMap<Integer, AttributeMetaData>  public class AttributeMetadataMap extends TreeMap<Name, AttributeMetadata>
16                  implements Copyable<AttributeMetadataMap> {                  implements Copyable<AttributeMetadataMap> {
17    
18          public AttributeMetadataMap() {          /**
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            }
25    
26            public AttributeMetadata get(Name name) {
27                    final AttributeMetadata attributeMetadata = super.get(name);
28                    if (attributeMetadata == null && name != null && !name.getLocalPart().trim().isEmpty()) {
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          @Override          @Override
40          public AttributeMetadataMap copyTo(AttributeMetadataMap amdMap) {          public AttributeMetadataMap copyTo(AttributeMetadataMap amdMap) {
41                                    
42                  amdMap.clear();                  amdMap.clear();
43                                    
44                  for (Integer key : keySet()) {                  for (Name key : keySet()) {
45                          AttributeMetaData attributeMetaData = get(key);                          AttributeMetadata attributeMetaData = get(key);
46                          amdMap.put(key, attributeMetaData.copy());                          amdMap.put(key, attributeMetaData.copy());
47                  }                  }
48                  return amdMap;                  return amdMap;
# Line 33  public class AttributeMetadataMap extend Line 53  public class AttributeMetadataMap extend
53                  AttributeMetadataMap copy = new AttributeMetadataMap();                  AttributeMetadataMap copy = new AttributeMetadataMap();
54                  return copyTo(copy);                  return copyTo(copy);
55          }          }
56    
57            public List<AttributeMetadata> sortedValues() {
58                    ArrayList<AttributeMetadata> list = new ArrayList<AttributeMetadata>();
59                    list.addAll(values());
60                    return list;
61            }
62  }  }

Legend:
Removed from v.420  
changed lines
  Added in v.474

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26