org.csstudio.data.values
Class ValueUtil

java.lang.Object
  extended by org.csstudio.data.values.ValueUtil

public class ValueUtil
extends java.lang.Object

Helper for decoding the data in a IValue, mostly for display purposes.

Author:
Kay Kasemir

Constructor Summary
ValueUtil()
           
 
Method Summary
static java.lang.String formatValueAndSeverity(IValue value)
           
static double getDouble(IValue value)
          Try to get a double number from the Value.
static double getDouble(IValue value, int index)
          Try to get a double-typed array element from the Value.
static double[] getDoubleArray(IValue value)
          Try to get a double-typed array from the Value.
static java.lang.String getInfo(IValue value)
          Deprecated. Remove. Only used in old Data Browser??
static int getSize(IValue value)
           
static java.lang.String getString(IValue value)
          Converts the given value into a string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueUtil

public ValueUtil()
Method Detail

getSize

public static int getSize(IValue value)
Returns:
Array length of the value. 1 for scalars.

getDouble

public static double getDouble(IValue value)
Try to get a double number from the Value.

Some applications only deal with numeric data, so they want to interprete integer, enum and double values all the same.

Parameters:
value - The value to decode.
Returns:
A double, or Double.NaN in case the value type does not decode into a number, or Double.NEGATIVE_INFINITY if the value's severity indicates that there happens to be no useful value.

getDouble

public static double getDouble(IValue value,
                               int index)
Try to get a double-typed array element from the Value.

Parameters:
value - The value to decode.
index - The array index, 0 ... getSize()-1.
Returns:
A double, or Double.NaN in case the value type does not decode into a number, or Double.NEGATIVE_INFINITY if the value's severity indicates that there happens to be no useful value.
See Also:
#getSize(Value), #getDouble(Value)

getDoubleArray

public static double[] getDoubleArray(IValue value)
Try to get a double-typed array from the Value.

Parameters:
value - The value to decode.
Returns:
A double array, or an empty double array in case the value type does not decode into a number, or if the value's severity indicates that there happens to be no useful value.
See Also:
#getSize(Value), #getDouble(Value)

getInfo

@Deprecated
public static java.lang.String getInfo(IValue value)
Deprecated. Remove. Only used in old Data Browser??

Try to get an info string from the Value.

For numeric values, which is probably the vast majority of all values, this is the severity and status information.

For 'enum' type values, getDouble() will return the numeric value, and getInfo() returns the associated enumeration string, appended to a possible severity/status text.

For string type values, this is the string value and a possible severity/status text, while getDouble() will return NaN.

Parameters:
value - The value to decode.
Returns:
The info string, never null.

formatValueAndSeverity

public static java.lang.String formatValueAndSeverity(IValue value)
Returns:
Non-null String for the value and its severity/status. Does not include the time stamp.
See Also:
Value#format(), #getInfo(Value)

getString

public static java.lang.String getString(IValue value)
Converts the given value into a string representation. For string values, returns the value. For numeric (double and long) values, returns a non-localized string representation. Double values use a point as the decimal separator. For other types of values, the value's IValue.format() method is called and its result returned.

Parameters:
value - the value.
Returns:
a string representation of the value.