Class MBArrayStop

Object
MBArrayStop

public class MBArrayStop extends Object
Wrapper for a "stop" in an array function (See MBFunction.isArrayFunction()), providing methods to access the stop key and stop value array, as well as a method to reduce it from an array stop to a single-value stop (for a given index).

For example, the following "stops" list contains two MBArrayStops. (for each stop, the stop value is an array).

  'stops': [
          // [stopkey, stopValueArray]
             [0,       [0,10]],
             [100,     [2,15]]
    ]
 

Used by MBFunction.splitArrayFunction() to split an array function into multiple functions, one for each dimension in the output array.

  • Field Details

    • json

      public JSONArray json
    • stopValueArray

      public JSONArray stopValueArray
  • Constructor Details

    • MBArrayStop

      public MBArrayStop(JSONArray array)
  • Method Details

    • getStopKey

      public Object getStopKey()
      Get the stop key for this stop.

      For example, for the following MBArrayStop: [1, [0,10]] the output of stop.getStopKey() is 1.

      Returns:
      stop key
    • getStopValueCount

      public int getStopValueCount()
      Returns the size of the array of stop values.

      For example, for the following MBArrayStop: [0, [0,10]] the output of stop.getStopValueCount() is 2.

      Returns:
      the size of the array of stop values.
    • getStopValue

      public Object getStopValue(int idx)
      Returns the value from the stop value array at the provided index.

      For example, for the following MBArrayStop: [0, [0,10]], the output of stop.getStopValue(1) is 10.

      Parameters:
      idx - The index to look up in the stop value array.
      Returns:
      The value from the stop value array at the provided index.
    • reducedToIndex

      public JSONArray reducedToIndex(int idx)
      Returns the JSON for a new stop derived from this stop, but reduced to a single-value stop with the value from the provided index.

      For example, for the MBArrayStop [0, [0,10]], The output of stop.reducedToIndex(1) is the following new stop: [0, 10]

      Parameters:
      idx - The index to use as the single value for the new stop.
      Returns:
      A new stop, with a single stop value rather than a stop value array.