Class ValueFactory

java.lang.Object
org.yamcs.studio.data.vtype.ValueFactory

public class ValueFactory extends Object
Factory class for all concrete implementation of the types.

The factory methods do not do anything in terms of defensive copy and immutability to the objects, which they are passed as they are. It's the client responsibility to prepare them appropriately, which is automatically done anyway for all objects except collections.

  • Constructor Details

    • ValueFactory

      public ValueFactory()
  • Method Details

    • newVString

      public static VString newVString(String value, Alarm alarm, Time time)
      Creates a new VString.
    • newVBoolean

      public static VBoolean newVBoolean(boolean value, Alarm alarm, Time time)
      Creates a new VBoolean.
    • newVMultiDouble

      public static VMultiDouble newVMultiDouble(List<VDouble> values, Alarm alarm, Time time, Display display)
      Creates a new VMultiDouble.
    • newVLong

      public static VLong newVLong(Long value, Alarm alarm, Time time, Display display)
      Creates a new VLong.
    • newVInt

      public static VInt newVInt(Integer value, Alarm alarm, Time time, Display display)
      Creates a new VInt.
    • newVShort

      public static VShort newVShort(Short value, Alarm alarm, Time time, Display display)
      Creates a new VShort.
    • newVByte

      public static VByte newVByte(Byte value, Alarm alarm, Time time, Display display)
      Creates a new VByte.
    • newAlarm

      public static Alarm newAlarm(AlarmSeverity alarmSeverity, String alarmName)
      New alarm with the given severity and status.
    • alarmNone

      public static Alarm alarmNone()
      No alarm.
      Returns:
      severity and status NONE
    • newAlarm

      public static Alarm newAlarm(Number value, Display display)
      Alarm based on the value and the display ranges.
    • newTime

      public static Time newTime(Instant timestamp, Integer timeUserTag, boolean timeValid)
      Creates a new time.
    • newTime

      public static Time newTime(Instant timestamp)
      New time, with no user tag and valid data.
    • timeNow

      public static Time timeNow()
      New time with the current timestamp, no user tag and valid data.
      Returns:
      the new time
    • newDisplay

      public static Display newDisplay(Double lowerDisplayLimit, Double lowerAlarmLimit, double lowerWarningLimit, String units, NumberFormat numberFormat, Double upperWarningLimit, double upperAlarmLimit, Double upperDisplayLimit, double lowerCtrlLimit, Double upperCtrlLimit)
      Creates a new display
    • newDisplay

      public static ArrayDimensionDisplay newDisplay(ListNumber boundaries, String unit)
    • newDisplay

      public static ArrayDimensionDisplay newDisplay(ListNumber boundaries, boolean reversed, String unit)
    • newDisplay

      public static ArrayDimensionDisplay newDisplay(int size, ListNumberProvider boundaryProvider, boolean invert)
    • newDisplay

      public static ArrayDimensionDisplay newDisplay(int size, ListNumberProvider boundaryProvider)
    • newDisplay

      public static ArrayDimensionDisplay newDisplay(int nCells)
      Returns an array display where the index is used to calculate the cell boundaries.
      Parameters:
      nCells - the number of cells along the direction
      Returns:
      a new array display
    • displayNone

      public static Display displayNone()
      Empty display information.
      Returns:
      no display
    • displayBoolean

      public static Display displayBoolean()
      Returns a display from 0 to 1, suitable for booleans.
      Returns:
      a display for boolean
    • newVNumber

      public static VNumber newVNumber(Number value, Alarm alarm, Time time, Display display)
      Creates a new VNumber based on the type of the data
    • newVDouble

      public static VDouble newVDouble(Double value, Alarm alarm, Time time, Display display)
      Creates a new VDouble.
    • newVDouble

      public static VDouble newVDouble(Double value, Time time, Display display)
      Creates a new VDouble using the given value, time, display and generating the alarm from the value and display information.
    • newVDouble

      public static VDouble newVDouble(Double value, Display display)
      Creates new immutable VDouble by using metadata from the old value, now as timestamp and computing alarm from the metadata range.
    • newVDouble

      public static VDouble newVDouble(Double value)
      Creates a new VDouble, no alarm, time now, no display.
    • newVDouble

      public static VDouble newVDouble(Double value, Time time)
      Creates a new VDouble, no alarm, no display.
    • newVFloat

      public static VFloat newVFloat(Float value, Alarm alarm, Time time, Display display)
      Creates a new VFloat.
    • newVEnum

      public static VEnum newVEnum(int index, List<String> labels, Alarm alarm, Time time)
      Create a new VEnum.
      Parameters:
      index - the index in the label array
      labels - the labels
      alarm - the alarm
      time - the time
      Returns:
      the new value
    • newVStatistics

      public static VStatistics newVStatistics(double average, double stdDev, double min, double max, int nSamples, Alarm alarm, Time time, Display display)
      Creates a new VStatistics.
    • newVNumberArray

      public static VNumberArray newVNumberArray(ListNumber data, Alarm alarm, Time time, Display display)
      Creates a new VNumberArray based on the type of the data.
    • newVNumberArray

      public static VNumberArray newVNumberArray(ListNumber data, ListInt sizes, List<ArrayDimensionDisplay> dimensionDisplay, Alarm alarm, Time time, Display display)
      Creates a new VNumberArray based on the type of the data.
      Parameters:
      data - the array data
      sizes - the array shape
      dimensionDisplay - the array axis display information
      alarm - the alarm
      time - the time
      display - the display
      Returns:
      a new value
    • ndArray

      public static VNumberArray ndArray(VNumberArray data, ArrayDimensionDisplay... dimensions)
      Constructs and nd array with the data, time and alarm in the first array and the given dimension information.
      Parameters:
      data - the array with the data
      dimensions - the dimension information
      Returns:
      a new array
    • newVDoubleArray

      public static VDoubleArray newVDoubleArray(ListDouble data, Alarm alarm, Time time, Display display)
      Creates a new VDoubleArray.
    • newVFloatArray

      public static VFloatArray newVFloatArray(ListFloat data, Alarm alarm, Time time, Display display)
      Creates a new VFloatArray.
    • newVImage

      public static VImage newVImage(int height, int width, byte[] data)
      Creates a new VImage given the data and the size.
    • newVImage

      public static VImage newVImage(int height, int width, byte[] data, Alarm alarm, Time time)
      Creates a new VImage given the data and the size.
    • newVImage

      public static VImage newVImage(int height, int width, ListNumber data, VImageDataType imageDataType, Alarm alarm, Time time)
      Creates a new VImage of type TYPE_3BYTE_BGR given the data and the size.
    • newVLongArray

      public static VLongArray newVLongArray(ListLong values, Alarm alarm, Time time, Display display)
      Creates a new VLongArray.
    • newVIntArray

      public static VIntArray newVIntArray(ListInt values, Alarm alarm, Time time, Display display)
      Creates a new VIntArray.
    • newVShortArray

      public static VShortArray newVShortArray(ListShort values, Alarm alarm, Time time, Display display)
      Creates a new VShortArray.
    • newVByteArray

      public static VByteArray newVByteArray(ListByte values, Alarm alarm, Time time, Display display)
      Creates a new VByteArray.
    • newVEnumArray

      public static VEnumArray newVEnumArray(ListInt indexes, List<String> labels, Alarm alarm, Time time)
      Create a new VEnumArray.
      Parameters:
      indexes - the indexes in the label array
      labels - the labels
      alarm - the alarm
      time - the time
      Returns:
      the new value
    • newVBooleanArray

      public static VBooleanArray newVBooleanArray(ListBoolean data, Alarm alarm, Time time)
      Creates a new VBooleanArray.
    • newVStringArray

      public static VStringArray newVStringArray(List<String> data, Alarm alarm, Time time)
      Creates a new VStringArray.
    • newVTable

      public static VTable newVTable(List<Class<?>> types, List<String> names, List<Object> values)
      Creates a new VTable - this method is provisional and will change in the future.
      Parameters:
      types - the types for each column
      names - the names for each column
      values - the values for each column
      Returns:
      the new value
    • wrapValue

      @Deprecated public static VType wrapValue(Object value)
      Deprecated.
      Takes a java objects and wraps it into a vType. All numbers are wrapped as VDouble. String is wrapped as VString. double[] and ListDouble are wrapped as VDoubleArray. A List of String is wrapped to a VStringArray. Alarms are alarmNone(), time are timeNow() and display are displayNone();
      Parameters:
      value - the value to wrap
      Returns:
      the wrapped value
    • wrapValue

      @Deprecated public static VType wrapValue(Object value, Alarm alarm)
      Takes a java objects and wraps it into a vType. All numbers are wrapped as VDouble. String is wrapped as VString. double[] and ListDouble are wrapped as VDoubleArray. A List of String is wrapped to a VStringArray. Alarms are alarm, time are timeNow() and display are displayNone();
      Parameters:
      value - the value to wrap
      alarm - the alarm for the value
      Returns:
      the wrapped value
    • toVType

      public static VType toVType(Object javaObject)
      Converts a standard java type to VTypes. Returns null if no conversion is possible. Calls toVType(java.lang.Object, org.yamcs.studio.data.vtype.Alarm, org.yamcs.studio.data.vtype.Time, org.yamcs.studio.data.vtype.Display) with no alarm, time now and no display.
      Parameters:
      javaObject - the value to wrap
      Returns:
      the new VType value
    • toVType

      public static VType toVType(Object javaObject, Alarm alarm, Time time, Display display)
      Converts a standard java type to VTypes. Returns null if no conversion is possible.

      Types are converted as follow:

      • Boolean -> VBoolean
      • Number -> corresponding VNumber
      • String -> VString
      • number array -> corresponding VNumberArray
      • ListNumber -> corresponding VNumberArray
      • List -> if all elements are String, VStringArray
      Parameters:
      javaObject - the value to wrap
      alarm - the alarm
      time - the time
      display - the display
      Returns:
      the new VType value
    • toVTypeChecked

      public static VType toVTypeChecked(Object javaObject)
      As toVType(java.lang.Object) but throws an exception if conversion not possible.
      Parameters:
      javaObject - the value to wrap
      Returns:
      the new VType value
    • toVTypeChecked

      public static VType toVTypeChecked(Object javaObject, Alarm alarm, Time time, Display display)
      Parameters:
      javaObject - the value to wrap
      alarm - the alarm
      time - the time
      display - the display
      Returns:
      the new VType value