Class ArrayEncoder
java.lang.Object
dev.toonformat.jtoon.encoder.ArrayEncoder
Handles encoding of JSON arrays to TOON format.
Orchestrates array encoding by detecting array types and delegating to specialized encoders.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidencodeArray(String key, tools.jackson.databind.node.ArrayNode value, LineWriter writer, int depth, EncodeOptions options) Main entry point for array encoding.static StringformatInlineArray(tools.jackson.databind.node.ArrayNode values, String delimiter, String prefix, boolean lengthMarker) Formats an inline primitive array with header and values.static booleanisArrayOfArrays(tools.jackson.databind.JsonNode array) Checks if an array contains only arrays.static booleanisArrayOfObjects(tools.jackson.databind.JsonNode array) Checks if an array contains only objects.static booleanisArrayOfPrimitives(tools.jackson.databind.JsonNode array) Checks if an array contains only primitive values.
-
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 prefixvalue- ArrayNode to encodewriter- LineWriter for outputdepth- Indentation depthoptions- 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 formatdelimiter- the delimiter to use between valuesprefix- optional key prefix for the arraylengthMarker- whether to include the # marker before the length- Returns:
- the formatted inline array string
-