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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 518 - (hide annotations)
Fri Nov 13 18:16:38 2009 UTC (15 years, 3 months ago) by alfonx
Original Path: branches/1.0-gt2-2.6/src/skrueger/geotools/AttributeMetadataMap.java
File MIME type: text/plain
File size: 2356 byte(s)
* CQLFilter.toString does not produce CQL! Useed CQL.toCQL( Filter ) instead in some places.
* Added paramter weight (for visualisation sorting) to attributeMetadata
* Added paramters X and A for Attributemetadata.. but not using it yet.. 
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 518 import org.apache.log4j.Logger;
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 alfonx 518 import skrueger.i8n.I8NUtil;
13 alfonx 464
14 alfonx 420 /**
15 alfonx 464 * An extension of TreeMap, that is copyable in the sense of the {@link Copyable} interface
16 alfonx 420 */
17 alfonx 464 public class AttributeMetadataMap extends TreeMap<Name, AttributeMetadata>
18 alfonx 420 implements Copyable<AttributeMetadataMap> {
19 alfonx 518 static private final Logger LOGGER = Logger.getLogger(AttributeMetadataMap.class);
20    
21    
22 alfonx 464 /**
23     * @Deprecated use get(Name name) or get(String localName)
24     */
25     @Deprecated
26     public AttributeMetadata get(Object key) {
27 alfonx 518 LOGGER.warn("PLEASE DONT USE get(Object) any MORE!");
28     LOGGER.warn("PLEASE DONT USE get(Object) any MORE!");
29     LOGGER.warn("PLEASE DONT USE get(Object) any MORE!");
30 alfonx 464 return super.get(key);
31 alfonx 420 }
32 alfonx 518
33 alfonx 464 public AttributeMetadata get(Name name) {
34     final AttributeMetadata attributeMetadata = super.get(name);
35 alfonx 474 if (attributeMetadata == null && name != null && !name.getLocalPart().trim().isEmpty()) {
36 alfonx 464 put(name,new AttributeMetadata(name));
37     return super.get(name);
38     }
39     return attributeMetadata;
40     }
41    
42     public AttributeMetadata get(String localName) {
43     return this.get(new NameImpl(localName));
44     }
45    
46 alfonx 420 @Override
47     public AttributeMetadataMap copyTo(AttributeMetadataMap amdMap) {
48    
49     amdMap.clear();
50    
51 alfonx 464 for (Name key : keySet()) {
52     AttributeMetadata attributeMetaData = get(key);
53 alfonx 420 amdMap.put(key, attributeMetaData.copy());
54     }
55     return amdMap;
56     }
57    
58     @Override
59     public AttributeMetadataMap copy() {
60     AttributeMetadataMap copy = new AttributeMetadataMap();
61     return copyTo(copy);
62     }
63 alfonx 464
64     public List<AttributeMetadata> sortedValues() {
65     ArrayList<AttributeMetadata> list = new ArrayList<AttributeMetadata>();
66     list.addAll(values());
67     return list;
68     }
69 alfonx 518
70     /**
71     * @return a number between 0 (bad) and 1 (good) that is calculated from the amount of translation available in the visible attributes
72     */
73     public double getQuality(List<String> languages) {
74     int allVisible = 0;
75     double colQmSum = 0.;
76     for (final AttributeMetadata oneCol : values()) {
77    
78     if (oneCol.isVisible()) {
79     allVisible++;
80     colQmSum += oneCol.getQuality(languages);
81     }
82     }
83    
84     if (allVisible > 0)
85     return colQmSum / allVisible;
86     else
87     return 1.;
88    
89     }
90 alfonx 420 }

Properties

Name Value
svn:eol-style native
svn:keywords Id URL
svn:mime-type text/plain

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26