org.rhq.core.clientapi.util.units
Class PercentageFormatter

java.lang.Object
  extended by org.rhq.core.clientapi.util.units.SimpleFormatter
      extended by org.rhq.core.clientapi.util.units.PercentageFormatter
All Implemented Interfaces:
Formatter

public class PercentageFormatter
extends SimpleFormatter


Constructor Summary
PercentageFormatter()
           
 
Method Summary
protected  FormattedNumber formatNumber(double rawValue, NumberFormat fmt)
           
 FormattedNumber[] formatSame(double[] vals, UnitsConstants unitType, ScaleConstants scale, Locale locale, FormatSpecifics specifics)
          Format a several values at once into the same format.
protected  ScaleConstants getUnitScale()
           
protected  UnitsConstants getUnitType()
           
 UnitNumber parse(String val, Locale locale, ParseSpecifics specifics)
          Parse a string into a UnitNumber.
 
Methods inherited from class org.rhq.core.clientapi.util.units.SimpleFormatter
format, getBaseValue, getNumberFormat, getScaledValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PercentageFormatter

public PercentageFormatter()
Method Detail

getUnitType

protected UnitsConstants getUnitType()
Specified by:
getUnitType in class SimpleFormatter

getUnitScale

protected ScaleConstants getUnitScale()
Specified by:
getUnitScale in class SimpleFormatter

formatNumber

protected FormattedNumber formatNumber(double rawValue,
                                       NumberFormat fmt)
Specified by:
formatNumber in class SimpleFormatter

parse

public UnitNumber parse(String val,
                        Locale locale,
                        ParseSpecifics specifics)
                 throws ParseException
Description copied from interface: Formatter
Parse a string into a UnitNumber. E.x. parse("34 MB") -> UnitNumber(34, UNIT_BYTES, SCALE_MEGA)

Specified by:
parse in interface Formatter
Overrides:
parse in class SimpleFormatter
Parameters:
val - Value to parse
locale - Locale to parse with
specifics - An optional argument which gives the parser more information about parsing
Returns:
the number representing the parsed value
Throws:
ParseException - if the value could not be parsed

formatSame

public FormattedNumber[] formatSame(double[] vals,
                                    UnitsConstants unitType,
                                    ScaleConstants scale,
                                    Locale locale,
                                    FormatSpecifics specifics)
Description copied from interface: Formatter
Format a several values at once into the same format. I.e. no matter the discrepency of range, they all contain the same units (megabytes, etc.)

Specified by:
formatSame in interface Formatter
Overrides:
formatSame in class SimpleFormatter
Parameters:
vals - Values to format
unitType - One of UnitsConstants.UNIT_*
scale - One of UnitsConstants.SCALE_*
locale - Locale that the resultant format should be in
specifics - Optional format to give specific hints to the formatter about how the result should look.


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.