Class ArrayEncoder

java.lang.Object
dev.toonformat.jtoon.encoder.ArrayEncoder

public final class ArrayEncoder extends Object
Handles encoding of JSON arrays to TOON format. Orchestrates array encoding by detecting array types and delegating to specialized encoders.
  • Method Details

    • encodeArray

      public static void encodeArray(String key, tools.jackson.databind.node.ArrayNode value, LineWriter writer, int depth, EncodeOptions options)
      Main entry point for array encoding. Detects array type and delegates to appropriate encoding method.
      Parameters:
      key - Optional key prefix
      value - ArrayNode to encode
      writer - LineWriter for output
      depth - Indentation depth
      options - Encoding options
    • isArrayOfPrimitives

      public static boolean isArrayOfPrimitives(tools.jackson.databind.JsonNode array)
      Checks if an array contains only primitive values.
      Parameters:
      array - for testing that all items are primitives
      Returns:
      true if all items in the array are primitive values, false otherwise
    • isArrayOfArrays

      public static boolean isArrayOfArrays(tools.jackson.databind.JsonNode array)
      Checks if an array contains only arrays.
      Parameters:
      array - the array to check
      Returns:
      true if all items in the array are arrays, false otherwise
    • isArrayOfObjects

      public static boolean isArrayOfObjects(tools.jackson.databind.JsonNode array)
      Checks if an array contains only objects.
      Parameters:
      array - the array to check
      Returns:
      true if all items in the array are objects, false otherwise
    • formatInlineArray

      public static String formatInlineArray(tools.jackson.databind.node.ArrayNode values, String delimiter, String prefix, boolean lengthMarker)
      Formats an inline primitive array with header and values.
      Parameters:
      values - the array of primitive values to format
      delimiter - the delimiter to use between values
      prefix - optional key prefix for the array
      lengthMarker - whether to include the # marker before the length
      Returns:
      the formatted inline array string