Class AggregateUtil

java.lang.Object
org.yamcs.utils.AggregateUtil

public class AggregateUtil extends Object
operations to aggregates or arrays
  • Constructor Details

    • AggregateUtil

      public AggregateUtil()
  • Method Details

    • findSeparator

      public static int findSeparator(String s)
      finds the first occurrence of . or [ after the last /
      Parameters:
      s -
      Returns:
      the position of the first occurrence of . or [ after the last slash; returns -1 if not found
    • parseReference

      public static PathElement[] parseReference(String name)
      Parses a reference of shape
       /a/b/c/x.y[3][4].z
       
      into an array of PathElement: {"a/b/c/x", "y"[3,4], "z"}
      Parameters:
      name -
      Returns:
    • verifyPath

      public static boolean verifyPath(ParameterType parameterType, PathElement[] path)
      Verify that the path exists in the parameter type
      Parameters:
      parameterType -
      path -
      Returns:
    • getMemberType

      public static ParameterType getMemberType(ParameterType parameterType, PathElement[] path)
    • extractMember

      public static <T extends RawEngValue> T extractMember(T rev, PathElement[] path)
      Create a parameter value with a member from the passed parameter value as found following the path. Returns null if there is no such member.
      Parameters:
      rev -
      path -
      Returns:
    • updateMember

      public static void updateMember(ParameterValue pv, PartialParameterValue patch)
      Patches a parameter value with a new value for one member of an aggregate or array Currently this does not extend an array
      Parameters:
      pv -
      patch -
      Throws:
      IllegalArgumentException - if the member to be updated or the array element does not exist
    • getMemberValue

      public static Value getMemberValue(Value value, PathElement[] path)
      This function is used to retrieve values from hierarchical aggregates. It is equivalent with a chain of getMemberValue() calls:
         getMemberValue(getMemberValue(getMemberValue(value, path[0]),path[1])...,path[n])
       
      It returns null if the path does not lead to a valid aggregate member.
      Parameters:
      path - - the path to be traversed, can be empty.
      Returns:
      the member value found by traversing the path or null if no such member exists. In case the path is empty, this value itself will be returned.
    • toString

      public static String toString(PathElement[] path)
    • createParameterType

      public static AggregateParameterType createParameterType(String name, AggregateValue v)