/[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 464 by alfonx, Tue Oct 13 13:22:31 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.SortedMap;
6  import java.util.TreeMap;  import java.util.TreeMap;
7    
8  import skrueger.AttributeMetaData;  import org.geotools.feature.NameImpl;
9    import org.opengis.feature.type.Name;
10    
11    import skrueger.AttributeMetadata;
12    
13  /**  /**
14   * 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  
  *  
15   */   */
16  public class AttributeMetadataMap extends TreeMap<Integer, AttributeMetaData>  public class AttributeMetadataMap extends TreeMap<Name, AttributeMetadata>
17                  implements Copyable<AttributeMetadataMap> {                  implements Copyable<AttributeMetadataMap> {
18    
19          public AttributeMetadataMap() {          /**
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            }
26    
27            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          @Override          @Override
41          public AttributeMetadataMap copyTo(AttributeMetadataMap amdMap) {          public AttributeMetadataMap copyTo(AttributeMetadataMap amdMap) {
42                                    
43                  amdMap.clear();                  amdMap.clear();
44                                    
45                  for (Integer key : keySet()) {                  for (Name key : keySet()) {
46                          AttributeMetaData attributeMetaData = get(key);                          AttributeMetadata attributeMetaData = get(key);
47                          amdMap.put(key, attributeMetaData.copy());                          amdMap.put(key, attributeMetaData.copy());
48                  }                  }
49                  return amdMap;                  return amdMap;
# Line 33  public class AttributeMetadataMap extend Line 54  public class AttributeMetadataMap extend
54                  AttributeMetadataMap copy = new AttributeMetadataMap();                  AttributeMetadataMap copy = new AttributeMetadataMap();
55                  return copyTo(copy);                  return copyTo(copy);
56          }          }
57    
58            public List<AttributeMetadata> sortedValues() {
59                    ArrayList<AttributeMetadata> list = new ArrayList<AttributeMetadata>();
60                    list.addAll(values());
61                    return list;
62            }
63  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26