/[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 678 by alfonx, Fri Feb 5 15:21:33 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 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 134  public class AttributeMetadata implement Line 134  public class AttributeMetadata implement
134                  this.setName(name);                  this.setName(name);
135                  this.title = title;                  this.title = title;
136                  this.desc = desc;                  this.desc = desc;
137  //                  this.visible = visible;
138  //              // The THE_GEOM and shall never be visible!                  this.unit = unit;
139  //              if (name.getLocalPart().equalsIgnoreCase("the_geom"))          }
140  //                      this.visible = false;          
 //              else  
 //                      this.visible = visible;  
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;                  this.unit = unit;
158          }          }
159    
# Line 229  public class AttributeMetadata implement Line 242  public class AttributeMetadata implement
242                  amd.setFunctionX(getFunctionX());                  amd.setFunctionX(getFunctionX());
243                  amd.setFunctionA(getFunctionA());                  amd.setFunctionA(getFunctionA());
244    
245                  for (final Object nodataValue : getNodataValues()) {                  amd.setNodataValues(getNodataValues());
                         amd.getNodataValues().add(nodataValue);  
                 }  
246    
247                  return amd;                  return amd;
248          }          }
249    
250            // only to be used by copyTo()
251            private void setNodataValues(HashSet<Object> nodataValues2) {
252                    nodataValues = nodataValues2;
253            }
254    
255          public Translation getDesc() {          public Translation getDesc() {
256                  return desc;                  return desc;
257          }          }
# Line 262  public class AttributeMetadata implement Line 278  public class AttributeMetadata implement
278                  return name;                  return name;
279          }          }
280    
281          public List<Object> getNodataValues() {          public HashSet<Object> getNodataValues() {
282                  return nodataValues;                  return nodataValues;
283          }          }
284    
# Line 325  public class AttributeMetadata implement Line 341  public class AttributeMetadata implement
341                  this.name = name;                  this.name = name;
342          }          }
343    
344          public void setNodataValues(final List<Object> nodataValues) {          public void addNodataValue(Object nodataValue) {
345                  this.nodataValues = nodataValues;                  this.nodataValues.add(nodataValue);
346            }
347            
348            public void removeNodataValue(Object nodataValue) {
349                    this.nodataValues.remove(nodataValue);
350          }          }
351    
352          public void setTitle(final Translation title) {          public void setTitle(final Translation title) {
# Line 370  public class AttributeMetadata implement Line 390  public class AttributeMetadata implement
390                  sb.append("title="+getTitle().toString());                  sb.append("title="+getTitle().toString());
391                  return sb.toString();                  return sb.toString();
392          }          }
393    
394            /**
395             * Takes any value object and checks it against the NODATA values. If the
396             * value equals a NODATA value, <code>null</code> is returned. Otherwise the
397             * same object is returned.
398             *
399             * Note: This method is called often.
400             */
401            public Object fiterNodata(final Object value) {
402                    if (nodataValues.contains(value)) return null;
403                    return value;
404            }
405  }  }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26