/[schmitzm]/branches/2.0-RC1/src/skrueger/geotools/AttributeMetadataMap.java
ViewVC logotype

Diff of /branches/2.0-RC1/src/skrueger/geotools/AttributeMetadataMap.java

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

revision 517 by alfonx, Thu Oct 15 14:04:16 2009 UTC revision 518 by alfonx, Fri Nov 13 18:16:38 2009 UTC
# Line 4  import java.util.ArrayList; Line 4  import java.util.ArrayList;
4  import java.util.List;  import java.util.List;
5  import java.util.TreeMap;  import java.util.TreeMap;
6    
7    import org.apache.log4j.Logger;
8  import org.geotools.feature.NameImpl;  import org.geotools.feature.NameImpl;
9  import org.opengis.feature.type.Name;  import org.opengis.feature.type.Name;
10    
11  import skrueger.AttributeMetadata;  import skrueger.AttributeMetadata;
12    import skrueger.i8n.I8NUtil;
13    
14  /**  /**
15   * An extension of TreeMap, that is copyable in the sense of the {@link Copyable} interface   * An extension of TreeMap, that is copyable in the sense of the {@link Copyable} interface
16   */   */
17  public class AttributeMetadataMap extends TreeMap<Name, AttributeMetadata>  public class AttributeMetadataMap extends TreeMap<Name, AttributeMetadata>
18                  implements Copyable<AttributeMetadataMap> {                  implements Copyable<AttributeMetadataMap> {
19            static private final Logger LOGGER = Logger.getLogger(AttributeMetadataMap.class);
20            
21            
22          /**          /**
23           * @Deprecated use get(Name name) or get(String localName)           * @Deprecated use get(Name name) or get(String localName)
24           */           */
25          @Deprecated          @Deprecated
26          public AttributeMetadata get(Object key) {          public AttributeMetadata get(Object key) {
27                    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                  return super.get(key);                  return super.get(key);
31          }          }
32            
33          public AttributeMetadata get(Name name) {          public AttributeMetadata get(Name name) {
34                  final AttributeMetadata attributeMetadata = super.get(name);                  final AttributeMetadata attributeMetadata = super.get(name);
35                  if (attributeMetadata == null && name != null && !name.getLocalPart().trim().isEmpty()) {                  if (attributeMetadata == null && name != null && !name.getLocalPart().trim().isEmpty()) {
# Line 59  public class AttributeMetadataMap extend Line 66  public class AttributeMetadataMap extend
66                  list.addAll(values());                  list.addAll(values());
67                  return list;                  return list;
68          }          }
69    
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  }  }

Legend:
Removed from v.517  
changed lines
  Added in v.518

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26