skrueger
Class AttributeMetadata

java.lang.Object
  extended by skrueger.AttributeMetadata
All Implemented Interfaces:
Comparable<AttributeMetadata>, Copyable<AttributeMetadata>

public class AttributeMetadata
extends Object
implements Copyable<AttributeMetadata>, Comparable<AttributeMetadata>

This class holds meta information about an attribute/column. This information is used by StyledLayerInterface and many others.

Author:
Stefan Alfons Krüger

Field Summary
protected  Translation desc
          Translation of the attribute's description
protected  Double functionA
          For numerical attributes the value can be transformed by VALUE*X+A when presented on screen.
protected  Double functionX
          For numerical attributes the value can be transformed by VALUE*X+A when presented on screen.
protected  HashSet<Object> nodataValues
          Allows to define general NODATA values for an attribute. e.g. -9999 can be set and will always be interpreted as NULL internally and will usually be ignored.
protected  Translation title
          Translation of the attribute's title
protected  String unit
          The unit append to all visualizations of values of this attribute (is not null)
protected  boolean visible
          Is the attribute visible to the user or ignored where possible
protected  int weight
          When listed, the attributes are listed according to their weight (heavier => further down)
 
Constructor Summary
AttributeMetadata(AttributeDescriptor attDesc, int weight, List<String> langs)
           
AttributeMetadata(AttributeDescriptor attDesc, List<String> langs)
           
AttributeMetadata(Name name, Boolean visible, String unit)
          Creates an AttributeMetadata object with the following information
AttributeMetadata(Name name, Boolean visible, Translation title, Translation desc, String unit)
          Creates an AttributeMetadata object with the following information
AttributeMetadata(Name name, List<String> langs)
          Creates a new visible AttributeMetadata
AttributeMetadata(Name name, String defaultTitle, List<String> langs)
          Creates a new visible AttributeMetadata
 
Method Summary
 void addNodataValue(Object nodataValue)
           
 int compareTo(AttributeMetadata atm2)
          Orders the attributes according to their weight.
 AttributeMetadata copy()
          Creates a new instance of T and copies all values.
 AttributeMetadata copyTo(AttributeMetadata amd)
          Deep copy this object to the target object.
 Object fiterNodata(Object value)
          Takes any value object and checks it against the NODATA values.
static String formatNoDataValues(Set<Object> list)
           
 Translation getDesc()
           
 Double getFunctionA()
           
 Double getFunctionX()
           
 String getLocalName()
          The local name.
 Name getName()
          The fully qualified Name of the attribute, e.g.
 HashSet<Object> getNodataValues()
           
 String getNoDataValuesFormatted()
           
 double getQuality(List<String> languages)
           
 Translation getTitle()
           
 String getUnit()
           
 int getWeight()
           
 boolean isVisible()
          Will the end-user see this attribute?
 void removeNodataValue(Object nodataValue)
           
 void setDesc(Translation desc)
           
 void setFunctionA(Double functionA)
           
 void setFunctionX(Double functionX)
           
 void setLocalName(String localName)
          The fully qualified Name of the attribute, e.g. org.bla.plo:blub
 void setName(Name name)
          The fully qualified Name of the attribute, e.g.
 void setTitle(Translation title)
           
 void setUnit(String unit)
           
 void setVisible(boolean visible)
           
 void setVisible(Boolean visible)
          Shall the end-user see this attribute?
 void setWeight(int weight)
           
 String toString()
          For nicer debugging
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

desc

protected Translation desc
Translation of the attribute's description


functionA

protected Double functionA
For numerical attributes the value can be transformed by VALUE*X+A when presented on screen. TODO not implemented yet


functionX

protected Double functionX
For numerical attributes the value can be transformed by VALUE*X+A when presented on screen. TODO not implemented yet


nodataValues

protected HashSet<Object> nodataValues
Allows to define general NODATA values for an attribute. e.g. -9999 can be set and will always be interpreted as NULL internally and will usually be ignored. This overcomes the problem, that


title

protected Translation title
Translation of the attribute's title


unit

protected String unit
The unit append to all visualizations of values of this attribute (is not null)


visible

protected boolean visible
Is the attribute visible to the user or ignored where possible


weight

protected int weight
When listed, the attributes are listed according to their weight (heavier => further down)

See Also:
compareTo(AttributeMetadata)
Constructor Detail

AttributeMetadata

public AttributeMetadata(AttributeDescriptor attDesc,
                         int weight,
                         List<String> langs)

AttributeMetadata

public AttributeMetadata(AttributeDescriptor attDesc,
                         List<String> langs)

AttributeMetadata

public AttributeMetadata(Name name,
                         Boolean visible,
                         Translation title,
                         Translation desc,
                         String unit)
Creates an AttributeMetadata object with the following information

Parameters:
colIdx - The column index of this attribute in the underlying table/dbf/etc...
visible - Shall this attribute be displayed or hidden from the user?
title - Translation for Name
desc - Translation for an attribute description
unit - String of the unit that the information is in

AttributeMetadata

public AttributeMetadata(Name name,
                         Boolean visible,
                         String unit)
Creates an AttributeMetadata object with the following information

Parameters:
colIdx - The column index of this attribute in the underlying table/dbf/etc...
visible - Shall this attribute be displayed or hidden from the user?
unit - String of the unit that the information is in

AttributeMetadata

public AttributeMetadata(Name name,
                         List<String> langs)
Creates a new visible AttributeMetadata


AttributeMetadata

public AttributeMetadata(Name name,
                         String defaultTitle,
                         List<String> langs)
Creates a new visible AttributeMetadata

Method Detail

compareTo

public int compareTo(AttributeMetadata atm2)
Orders the attributes according to their weight. Heavier => further down.

Specified by:
compareTo in interface Comparable<AttributeMetadata>

copy

public AttributeMetadata copy()
Description copied from interface: Copyable
Creates a new instance of T and copies all values.

Specified by:
copy in interface Copyable<AttributeMetadata>
See Also:
inferface

copyTo

public AttributeMetadata copyTo(AttributeMetadata amd)
Description copied from interface: Copyable
Deep copy this object to the target object. The target object has to be of the same

Specified by:
copyTo in interface Copyable<AttributeMetadata>
See Also:
inferface

getDesc

public Translation getDesc()

getFunctionA

public Double getFunctionA()

getFunctionX

public Double getFunctionX()

getLocalName

public String getLocalName()
The local name. E.g. the name of the DBF column as a String


getName

public Name getName()
The fully qualified Name of the attribute, e.g. org.bla.plo:blub


getNodataValues

public HashSet<Object> getNodataValues()

getQuality

public double getQuality(List<String> languages)
Returns:
a number between 0 (bad) and 1 (good) that is calculated from the amount of translation available. If this attribute is not visible, it will return 1.

getTitle

public Translation getTitle()

getUnit

public String getUnit()

getWeight

public int getWeight()

isVisible

public boolean isVisible()
Will the end-user see this attribute?


setDesc

public void setDesc(Translation desc)

setFunctionA

public void setFunctionA(Double functionA)

setFunctionX

public void setFunctionX(Double functionX)

setLocalName

public void setLocalName(String localName)
The fully qualified Name of the attribute, e.g. org.bla.plo:blub


setName

public void setName(Name name)
The fully qualified Name of the attribute, e.g. org.bla.plo:blub


addNodataValue

public void addNodataValue(Object nodataValue)

removeNodataValue

public void removeNodataValue(Object nodataValue)

setTitle

public void setTitle(Translation title)

setUnit

public void setUnit(String unit)

setVisible

public void setVisible(boolean visible)

setVisible

public void setVisible(Boolean visible)
Shall the end-user see this attribute?

Parameters:
visible -

setWeight

public void setWeight(int weight)

toString

public String toString()
For nicer debugging

Overrides:
toString in class Object

fiterNodata

public Object fiterNodata(Object value)
Takes any value object and checks it against the NODATA values. If the value equals a NODATA value, null is returned. Otherwise the same object is returned. Note: This method is called often.


getNoDataValuesFormatted

public String getNoDataValuesFormatted()
Returns:
a nicely formatted String containing all NODATA values. Strings are quoted fo that the empty String can be seen.

formatNoDataValues

public static String formatNoDataValues(Set<Object> list)
Returns:
a nicely formatted String containing all NODATA values. Strings are quoted fo that the empty String can be seen.