/[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/2.0-RC1/src/skrueger/AttributeMetadata.java revision 604 by alfonx, Wed Dec 9 14:15:53 2009 UTC branches/2.0-RC2/src/skrueger/AttributeMetadata.java revision 675 by alfonx, Thu Feb 4 19:05:34 2010 UTC
# Line 29  Line 29 
29   ******************************************************************************/   ******************************************************************************/
30  package skrueger;  package skrueger;
31    
32  import java.util.ArrayList;  import java.util.HashSet;
33  import java.util.List;  import java.util.List;
34    
35  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
# Line 75  public class AttributeMetadata implement Line 75  public class AttributeMetadata implement
75          /**          /**
76           * 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
77           * 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
78           * be ignored. TODO not implemented yet           * be ignored. This overcomes the problem, that
79           **/           **/
80          protected List<Object> nodataValues = new ArrayList<Object>();          protected final HashSet<Object> nodataValues = new HashSet<Object>();
81    
82          /** Translation of the attribute's title **/          /** Translation of the attribute's title **/
83          protected Translation title = new Translation();          protected Translation title = new Translation();
# Line 137  public class AttributeMetadata implement Line 137  public class AttributeMetadata implement
137                  this.visible = visible;                  this.visible = visible;
138                  this.unit = unit;                  this.unit = unit;
139          }          }
140            
141    
142            /**
143             * Creates an {@link AttributeMetadata} object with the following
144             * information
145             *
146             * @param colIdx
147             *            The column index of this attribute in the underlying
148             *            table/dbf/etc...
149             * @param visible
150             *            Shall this attribute be displayed or hidden from the user?
151             * @param unit
152             *            {@link String} of the unit that the information is in
153             */
154            public AttributeMetadata(final Name name, final Boolean visible, final String unit) {
155                    this.setName(name);
156                    this.visible = visible;
157                    this.unit = unit;
158            }
159    
160          /**          /**
161           * Creates a new visible {@link AttributeMetadata}           * Creates a new visible {@link AttributeMetadata}
# Line 256  public class AttributeMetadata implement Line 275  public class AttributeMetadata implement
275                  return name;                  return name;
276          }          }
277    
278          public List<Object> getNodataValues() {          public HashSet<Object> getNodataValues() {
279                  return nodataValues;                  return nodataValues;
280          }          }
281    
# Line 319  public class AttributeMetadata implement Line 338  public class AttributeMetadata implement
338                  this.name = name;                  this.name = name;
339          }          }
340    
341          public void setNodataValues(final List<Object> nodataValues) {          public void addNodataValue(Object nodataValue) {
342                  this.nodataValues = nodataValues;                  this.nodataValues.add(nodataValue);
343            }
344            
345            public void removeNodataValue(Object nodataValue) {
346                    this.nodataValues.remove(nodataValue);
347          }          }
348    
349          public void setTitle(final Translation title) {          public void setTitle(final Translation title) {
# Line 364  public class AttributeMetadata implement Line 387  public class AttributeMetadata implement
387                  sb.append("title="+getTitle().toString());                  sb.append("title="+getTitle().toString());
388                  return sb.toString();                  return sb.toString();
389          }          }
390    
391            /**
392             * Takes any value object and checks it against the NODATA values. If the
393             * value equals a NODATA value, <code>null</code> is returned. Otherwise the
394             * same object is returned.
395             *
396             * Note: This method is called often.
397             */
398            public Object fiterNodata(final Object value) {
399                    if (nodataValues.contains(value)) return null;
400                    return value;
401            }
402  }  }

Legend:
Removed from v.604  
changed lines
  Added in v.675

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26