/[schmitzm]/trunk/src/skrueger/AttributeMetadataImpl.java
ViewVC logotype

Diff of /trunk/src/skrueger/AttributeMetadataImpl.java

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

branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java revision 534 by alfonx, Fri Nov 20 10:28:01 2009 UTC branches/2.0-RC2/src/skrueger/AttributeMetadata.java revision 666 by alfonx, Wed Feb 3 18:05:50 2010 UTC
# Line 30  Line 30 
30  package skrueger;  package skrueger;
31    
32  import java.util.ArrayList;  import java.util.ArrayList;
33    import java.util.HashSet;
34  import java.util.List;  import java.util.List;
35    
36  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
37  import org.geotools.feature.NameImpl;  import org.geotools.feature.NameImpl;
38    import org.geotools.feature.Feature.NULL;
39  import org.opengis.feature.type.AttributeDescriptor;  import org.opengis.feature.type.AttributeDescriptor;
40  import org.opengis.feature.type.Name;  import org.opengis.feature.type.Name;
41    
# Line 75  public class AttributeMetadata implement Line 77  public class AttributeMetadata implement
77          /**          /**
78           * Allows to define general NODATA values for an attribute. e.g. -9999 can           * Allows to define general NODATA values for an attribute. e.g. -9999 can
79           * be set and will always be interpreted as NULL internally and will usually           * be set and will always be interpreted as NULL internally and will usually
80           * be ignored. TODO not implemented yet           * be ignored. This overcomes the problem, that
81           **/           **/
82          protected List<Object> nodataValues = new ArrayList<Object>();          protected final HashSet<Object> nodataValues = new HashSet<Object>();
83    
84          /** Translation of the attribute's title **/          /** Translation of the attribute's title **/
85          protected Translation title = new Translation();          protected Translation title = new Translation();
# Line 134  public class AttributeMetadata implement Line 136  public class AttributeMetadata implement
136                  this.setName(name);                  this.setName(name);
137                  this.title = title;                  this.title = title;
138                  this.desc = desc;                  this.desc = desc;
139  //                  this.visible = visible;
140  //              // The THE_GEOM and shall never be visible!                  this.unit = unit;
141  //              if (name.getLocalPart().equalsIgnoreCase("the_geom"))          }
142  //                      this.visible = false;          
 //              else  
 //                      this.visible = visible;  
143    
144            /**
145             * Creates an {@link AttributeMetadata} object with the following
146             * information
147             *
148             * @param colIdx
149             *            The column index of this attribute in the underlying
150             *            table/dbf/etc...
151             * @param visible
152             *            Shall this attribute be displayed or hidden from the user?
153             * @param unit
154             *            {@link String} of the unit that the information is in
155             */
156            public AttributeMetadata(final Name name, final Boolean visible, final String unit) {
157                    this.setName(name);
158                    this.visible = visible;
159                  this.unit = unit;                  this.unit = unit;
160          }          }
161    
# Line 262  public class AttributeMetadata implement Line 277  public class AttributeMetadata implement
277                  return name;                  return name;
278          }          }
279    
280          public List<Object> getNodataValues() {          public HashSet<Object> getNodataValues() {
281                  return nodataValues;                  return nodataValues;
282          }          }
283    
# Line 325  public class AttributeMetadata implement Line 340  public class AttributeMetadata implement
340                  this.name = name;                  this.name = name;
341          }          }
342    
343          public void setNodataValues(final List<Object> nodataValues) {          public void addNodataValue(Object nodataValue) {
344                  this.nodataValues = nodataValues;                  this.nodataValues.add(nodataValue);
345            }
346            
347            public void removeNodataValue(Object nodataValue) {
348                    this.nodataValues.remove(nodataValue);
349          }          }
350    
351          public void setTitle(final Translation title) {          public void setTitle(final Translation title) {
# Line 370  public class AttributeMetadata implement Line 389  public class AttributeMetadata implement
389                  sb.append("title="+getTitle().toString());                  sb.append("title="+getTitle().toString());
390                  return sb.toString();                  return sb.toString();
391          }          }
392    
393            /**
394             * Takes any value object and checks it against the NODATA values. If the
395             * value equals a NODATA value, <code>null</code> is returned. Otherwise the
396             * same object is returned.
397             *
398             * Note: This method is called often.
399             */
400            public Object fiterNodata(final Object value) {
401                    if (nodataValues.contains(value)) return null;
402                    return value;
403            }
404  }  }

Legend:
Removed from v.534  
changed lines
  Added in v.666

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26