|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdata.Parameter
public class Parameter
A Parameter represents a parameter of a DataSheet
.
It is used to store information about the type of data stored in a column of the DataSheet.
Two data types are supported: Numeric and Discrete.
Numeric parameters are used for columns that only contain numbers. Discrete parameters are used for all columns that contain at least one non-numeric value. All values are stored in a TreeSet and sorted in alphabetical order. This makes it possible to also treat information on parameters that are not quantifiable, such as different shapes of an object or similar.
Nested Class Summary | |
---|---|
(package private) class |
Parameter.ReverseStringComparator
Comparator for the discrete levels TreeSet to sort the data alphabetically. |
Field Summary | |
---|---|
private java.util.TreeSet<java.lang.String> |
discreteLevels
The discrete levels. |
private java.lang.String |
name
The parameter name. |
private boolean |
numeric
Specifies whether the parameter is numeric. |
(package private) static boolean |
printLog
Flag to enable debug message printing for this class. |
(package private) static long |
serialVersionUID
The version tracking unique identifier for Serialization. |
Constructor Summary | |
---|---|
Parameter(java.lang.String name)
Instantiates a new parameter. |
Method Summary | |
---|---|
int |
getDiscreteLevelCount()
Gets the discrete level count in the TreeSet that stores all discrete levels. |
double |
getDoubleValueOf(java.lang.String string)
Gets a numeric representation of a string value for this parameter. |
java.lang.String |
getName()
Gets the name. |
java.lang.String |
getStringValueOf(double value)
Gets the string representation of a given double value for this parameter. |
boolean |
isNumeric()
Checks whether the parameter is numeric or discrete. |
private void |
log(java.lang.String message)
Prints debug information to stdout when printLog is set to true. |
void |
resetDiscreteLevels()
Reset discrete levels to an empty TreeSet. |
void |
setName(java.lang.String name)
Sets the name. |
void |
setNumeric(boolean numeric)
Specifies whether the parameter is numeric or dicrete. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final long serialVersionUID
static final boolean printLog
private java.lang.String name
private boolean numeric
private java.util.TreeSet<java.lang.String> discreteLevels
Constructor Detail |
---|
public Parameter(java.lang.String name)
name
- the parameter nameMethod Detail |
---|
public java.lang.String getName()
public void setName(java.lang.String name)
name
- the new namepublic boolean isNumeric()
public void setNumeric(boolean numeric)
numeric
- specifies if the parameter is numericpublic double getDoubleValueOf(java.lang.String string)
If the parameter is numeric, an attempt is made to parse the string as a Double. If this attempt leads to a NumberFormatException, the parameter is not considered numeric anymore, but is transformed into a discrete parameter.
If the parameter is not numeric, the string is looked up in the TreeSet discreteLevels that should contain all discrete values (that is Strings) that were found in the data sheet for this parameter. If the value is not found it is added as a new discrete level for this parameter. The treeSet is then searched again in order to get the correct index of the new discrete level.
If this second search does not yield the result, something unexpected has gone wrong and a CorruptDataException is thrown.
string
- the string
public java.lang.String getStringValueOf(double value)
If the parameter numeric, the provided value is simply converted to a String and returned.
If it is discrete, the double value is casted to an Integer value and this value is used as an index to look up the corresponding discrete value string in the TreeSet discreteLevels.
If no value is found for the given index the data is assumed to be corrupt and a CorruptDataException is thrown.
value
- the numeric value
public int getDiscreteLevelCount()
Only applies to non-numeric parameters.
public void resetDiscreteLevels()
private void log(java.lang.String message)
message
- the message
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |