org.ibisph.dao.chart
Class AbstractDAO.DataValueParser

java.lang.Object
  extended by org.ibisph.dao.chart.AbstractDAO.DataValueParser
Enclosing class:
AbstractDAO

protected class AbstractDAO.DataValueParser
extends java.lang.Object

Internal helper object that parses the numeric string value to a double so that it can be validated. Also tracks and sets the max value if the new value is larger and contains getters to retrieve the raw value, the unformatted passed in value, and a java formatter formatted string value.


Constructor Summary
AbstractDAO.DataValueParser()
          Explicit default constructor.
AbstractDAO.DataValueParser(java.lang.String javaNumberFormatPattern)
          Data structure and helper methods that deal with a verifying and formatting a data value.
 
Method Summary
 double getDoubleValue()
           
 java.lang.String getFormattedValue()
          Gets the formatted value based on the value set with the format specified in the format pattern property.
 double getMaxValue()
           
 java.lang.String getParsedValue()
           
 void set(java.lang.String value)
          Sets (and verifies) the numeric value to be cleaned and formatted.
 void setNumberFormatPattern(java.lang.String javaNumberFormatPattern)
          Sets the format pattern to be used for the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDAO.DataValueParser

public AbstractDAO.DataValueParser()
Explicit default constructor.


AbstractDAO.DataValueParser

public AbstractDAO.DataValueParser(java.lang.String javaNumberFormatPattern)
Data structure and helper methods that deal with a verifying and formatting a data value.

Parameters:
javaNumberFormatPattern - Standard Java numeric format pattern.
Method Detail

setNumberFormatPattern

public void setNumberFormatPattern(java.lang.String javaNumberFormatPattern)
Sets the format pattern to be used for the value.

Parameters:
javaNumberFormatPattern - Standard Java numeric format pattern.

set

public void set(java.lang.String value)
Sets (and verifies) the numeric value to be cleaned and formatted. Value is parsed and if unsuccessful, is cleaned of possible formatting characters and then re-parsed. It is also checked for a max value and if exceeds then is set to the max value.

Parameters:
value - Value to be cleaned and formatted.

getFormattedValue

public java.lang.String getFormattedValue()
Gets the formatted value based on the value set with the format specified in the format pattern property.

Returns:
formatted value based on the value specified in the set method. If no formatter (e.g. no format pattern specified) then returns whatever was passed into set because that might already be formatted from IBISQ etc. Another possibility is that the value couldn't be converted to a valid double (which case the parsed value is null) so return the original value specified in the set method (unparsed value). Else use the formatter to create and return the formatted string value.
See Also:
Sun's Decimal Format

getParsedValue

public java.lang.String getParsedValue()
Returns:
parsed value in string format

getDoubleValue

public double getDoubleValue()
Returns:
parsed value as a double

getMaxValue

public double getMaxValue()
Returns:
max value property