org.epics.pvmanager.data
Class ValueFormat

java.lang.Object
  extended by java.text.Format
      extended by org.epics.pvmanager.data.ValueFormat
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
SimpleValueFormat

public abstract class ValueFormat
extends Format

Formats a data type to a String representation. This class provide default implementations that can format scalars and arrays to an arbitrary precision and a maximum number of array elements.

Author:
carcassi
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
Format.Field
 
Constructor Summary
ValueFormat()
           
 
Method Summary
 String format(Array<?> array)
          Formats an array.
protected abstract  StringBuffer format(Array<?> array, StringBuffer toAppendTo, FieldPosition pos)
          Formats an array.
 StringBuffer format(Object data, StringBuffer toAppendTo, FieldPosition pos)
          Formats the given data object.
 String format(Scalar<?> scalar)
          Formats an scalar.
protected abstract  StringBuffer format(Scalar<?> scalar, StringBuffer toAppendTo, FieldPosition pos)
          Formats a scalar.
 NumberFormat getNumberFormat()
          Returns the NumberFormat used to format the numeric values.
 Object parseObject(String source, ParsePosition pos)
           
 void setNumberFormat(NumberFormat numberFormat)
          Changes the NumberFormat used to format the numeric values.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueFormat

public ValueFormat()
Method Detail

format

public StringBuffer format(Object data,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Formats the given data object. For scalars and arrays redirects to the appropriate methods. For anything else uses Object.toString().

Specified by:
format in class Format
Parameters:
data - data object to format
Returns:
a String representation

format

public String format(Scalar<?> scalar)
Formats an scalar.

Parameters:
array - data object to format
Returns:
a String representation

format

public String format(Array<?> array)
Formats an array.

Parameters:
array - data object to format
Returns:
a String representation

format

protected abstract StringBuffer format(Scalar<?> scalar,
                                       StringBuffer toAppendTo,
                                       FieldPosition pos)
Formats a scalar.

Parameters:
scalar - data object to format
toAppendTo - output buffer
Returns:
the output buffer

format

protected abstract StringBuffer format(Array<?> array,
                                       StringBuffer toAppendTo,
                                       FieldPosition pos)
Formats an array.

Parameters:
array - data object to format
toAppendTo - output buffer
Returns:
the output buffer

getNumberFormat

public NumberFormat getNumberFormat()
Returns the NumberFormat used to format the numeric values. If null, it will use the NumberFormat from the value Display.

Returns:
a NumberFormat

setNumberFormat

public void setNumberFormat(NumberFormat numberFormat)
Changes the NumberFormat used to format the numeric values. If null, it will use the NumberFormat from the value Display.

Parameters:
numberFormat - a NumberFormat

parseObject

public Object parseObject(String source,
                          ParsePosition pos)
Specified by:
parseObject in class Format


Copyright © 2011. All Rights Reserved.