data
Class Parameter

java.lang.Object
  extended by data.Parameter
All Implemented Interfaces:
java.io.Serializable

public class Parameter
extends java.lang.Object
implements java.io.Serializable

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.

See Also:
Serialized Form

Constructor Summary
Parameter(java.lang.String name, DataSheet dataSheet)
          Instantiates a new parameter.
 
Method Summary
 boolean checkIfNumeric()
          Checks whether the parameter is numeric or discrete by rechecking all designs.
 void checkOccurrenceInDiscreteLevel(java.lang.String stringValueToCheck)
          Checks the count of designs for which this parameter is on the discrete level defined by the given string argument.
 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 isMixed()
          Checks whether the parameter is mixed.
 boolean isNumeric()
          Returns whether the parameter is numeric or discrete from the stored setting.
 void resetDiscreteLevelsAndState()
          Reset discrete levels to an empty TreeSet.
 void setAtLeastOneNumeric(boolean atLeastOneNumeric)
           
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parameter

public Parameter(java.lang.String name,
                 DataSheet dataSheet)
Instantiates a new parameter.

Parameters:
name - the parameter name
Method Detail

getName

public java.lang.String getName()
Gets the name.

Returns:
the name

setName

public void setName(java.lang.String name)
Sets the name.

Parameters:
name - the new name

isMixed

public boolean isMixed()
Checks whether the parameter is mixed. A parameter is mixed if at least one design has a numeric value and at least one design has a non-numeric value.

Returns:
true, if the parameter is mixed

isNumeric

public boolean isNumeric()
Returns whether the parameter is numeric or discrete from the stored setting.

Returns:
true, if the parameter is numeric

checkIfNumeric

public boolean checkIfNumeric()
Checks whether the parameter is numeric or discrete by rechecking all designs.

Returns:
true, if the parameter is numeric

setNumeric

public void setNumeric(boolean numeric)
Specifies whether the parameter is numeric or dicrete. If a parameter is switched to non-numeric for the first time all existing designs are checked to identify all discrete levels.

Parameters:
numeric - specifies if the parameter is numeric

setAtLeastOneNumeric

public void setAtLeastOneNumeric(boolean atLeastOneNumeric)
Parameters:
atLeastOneNumeric - specifies whether there is at least one design with a numeric value for this design

getDoubleValueOf

public double getDoubleValueOf(java.lang.String string)
Gets a numeric representation of a string value for this parameter.

If the parameter is numeric, an attempt is made to parse the string as a Double. If this attempt leads to a ParseException, 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.

Parameters:
string - the string
Returns:
the numeric representation of the given string

getStringValueOf

public java.lang.String getStringValueOf(double value)
Gets the string representation of a given double value for this parameter.

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.

Parameters:
value - the numeric value
Returns:
the string representation of the given double value for this parameter.

getDiscreteLevelCount

public int getDiscreteLevelCount()
Gets the discrete level count in the TreeSet that stores all discrete levels.

Only applies to non-numeric parameters.

Returns:
the discrete level count

checkOccurrenceInDiscreteLevel

public void checkOccurrenceInDiscreteLevel(java.lang.String stringValueToCheck)
Checks the count of designs for which this parameter is on the discrete level defined by the given string argument. If the count is zero, the discrete level is removed.

Only applies to non-numeric parameters.

Parameters:
stringValueToCheck - the discrete level for which the occurrence count should be returned

resetDiscreteLevelsAndState

public void resetDiscreteLevelsAndState()
Reset discrete levels to an empty TreeSet.