Class ArrayUtils

java.lang.Object
com.api.jsonata4java.expressions.utils.ArrayUtils
All Implemented Interfaces:
Serializable

public class ArrayUtils extends Object implements Serializable
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    compare(com.fasterxml.jackson.databind.JsonNode left, com.fasterxml.jackson.databind.JsonNode right)
    Default comparison function for $sort
    static com.fasterxml.jackson.databind.node.ArrayNode
    ensureArray(com.fasterxml.jackson.databind.JsonNode n)
    If n is an array, it will be returned untouched.
    static boolean
    isArrayOfNumbers(com.fasterxml.jackson.databind.JsonNode arr)
    Determines if the supplied array contains all numeric values
    static boolean
    isArrayOfStrings(com.fasterxml.jackson.databind.JsonNode arr)
    Determines if the supplied array contains all String values
    static com.fasterxml.jackson.databind.node.ArrayNode
    push(com.fasterxml.jackson.databind.node.ArrayNode left, com.fasterxml.jackson.databind.JsonNode right)
    Merges the left, then the right array into the resulting array, preserving the element's order
    static com.fasterxml.jackson.databind.node.ArrayNode
    slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start)
    Returns a shallow copy of the portion of the supplied array from start through the end of the array
    static com.fasterxml.jackson.databind.node.ArrayNode
    slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start, int end)
    Returns a shallow copy of the portion of the supplied array from start to end (not including end)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArrayUtils

      public ArrayUtils()
  • Method Details

    • isArrayOfNumbers

      public static boolean isArrayOfNumbers(com.fasterxml.jackson.databind.JsonNode arr)
      Determines if the supplied array contains all numeric values
      Parameters:
      arr - the array to be evaluated.
      Returns:
      true if the supplied array contains all numeric values. If arr is not an array, returns false.
    • isArrayOfStrings

      public static boolean isArrayOfStrings(com.fasterxml.jackson.databind.JsonNode arr)
      Determines if the supplied array contains all String values
      Parameters:
      arr - the array to be evaluated.
      Returns:
      true if the supplied array contains all String values. If arr is not an array, returns false.
    • compare

      public static boolean compare(com.fasterxml.jackson.databind.JsonNode left, com.fasterxml.jackson.databind.JsonNode right) throws EvaluateRuntimeException
      Default comparison function for $sort
      Parameters:
      left - string or number to be compared
      right - string or number to be compared
      Returns:
      true is left is greater than right
      Throws:
      EvaluateRuntimeException - if left and right cannot be converted to numbers
    • ensureArray

      public static com.fasterxml.jackson.databind.node.ArrayNode ensureArray(com.fasterxml.jackson.databind.JsonNode n)
      If n is an array, it will be returned untouched. Otherwise, return a singleton array containing the value
      Parameters:
      n - JsonNode being checked
      Returns:
      corresponding array made from the input n
    • push

      public static com.fasterxml.jackson.databind.node.ArrayNode push(com.fasterxml.jackson.databind.node.ArrayNode left, com.fasterxml.jackson.databind.JsonNode right)
      Merges the left, then the right array into the resulting array, preserving the element's order
      Parameters:
      left - first array to be merged
      right - second array to be merged
      Returns:
      merged array containing the elements of left then the elements of right
    • slice

      public static com.fasterxml.jackson.databind.node.ArrayNode slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start, int end)
      Returns a shallow copy of the portion of the supplied array from start to end (not including end)
      Parameters:
      array -
      start -
      end -
      Returns:
      a shallow copy of the portion of the supplied array from start to end (not including end)
    • slice

      public static com.fasterxml.jackson.databind.node.ArrayNode slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start)
      Returns a shallow copy of the portion of the supplied array from start through the end of the array
      Parameters:
      array - input array to be sliced
      start - starting index where the slice should occur
      Returns:
      a shallow copy of the portion of the supplied array from start through the end of the array