com.bigdata.counters.render
Class ValueFormatter

java.lang.Object
  extended by com.bigdata.counters.render.ValueFormatter
Direct Known Subclasses:
TextValueFormatter, XHTMLRenderer.HTMLValueFormatter

public abstract class ValueFormatter
extends Object

Datum specific formatting of ICounter values (not thread-safe since the Format objects are not thread-safe).

Version:
$Id: ValueFormatter.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected  Format dateFormat
          Used to format date/time values.
protected  DecimalFormat decimalFormat
          Used to format double and float counter values.
protected  NumberFormat integerFormat
          Used to format integer and long counter values.
protected static Pattern percent_pattern
          A pattern matching the occurrence of the word "percent" in a counter name.
protected  NumberFormat percentFormat
          Used to format counter values that can be inferred to be a percentage.
protected  DecimalFormat unitsFormat
          Used to format the units of time when expressed as elapsed units since the first sample of a History.
 
Constructor Summary
ValueFormatter(URLQueryModel model)
           
 
Method Summary
 String date(long timestamp)
          Format a timestamp as a date.
abstract  String value(ICounter counter, Object val)
          Formats a counter value as a String.
abstract  void writeFullPath(Writer w, String path)
          Write the full counter path.
abstract  void writePath(Writer w, String path, int rootDepth)
          Write a partial counter path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decimalFormat

protected final DecimalFormat decimalFormat
Used to format double and float counter values.


percentFormat

protected final NumberFormat percentFormat
Used to format counter values that can be inferred to be a percentage.


integerFormat

protected final NumberFormat integerFormat
Used to format integer and long counter values.


unitsFormat

protected final DecimalFormat unitsFormat
Used to format the units of time when expressed as elapsed units since the first sample of a History.


dateFormat

protected final Format dateFormat
Used to format date/time values.


percent_pattern

protected static final Pattern percent_pattern
A pattern matching the occurrence of the word "percent" in a counter name. Leading and trailing wildcards are used and the match is case-insensitive.

Constructor Detail

ValueFormatter

public ValueFormatter(URLQueryModel model)
Method Detail

value

public abstract String value(ICounter counter,
                             Object val)
Formats a counter value as a String.

Parameters:
counter - The counter.
value - The counter value (MAY be null).
Returns:
The formatted value.

writeFullPath

public abstract void writeFullPath(Writer w,
                                   String path)
                            throws IOException
Write the full counter path.

Throws:
IOException

writePath

public abstract void writePath(Writer w,
                               String path,
                               int rootDepth)
                        throws IOException
Write a partial counter path.

Parameters:
rootDepth - The path components will be shown beginning at this depth - ZERO (0) is the root.
Throws:
IOException

date

public String date(long timestamp)
Format a timestamp as a date.

Parameters:
timestamp - The timestamp value.
Returns:
The formatted value.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.