Class TabularArrayEncoder
java.lang.Object
dev.toonformat.jtoon.encoder.TabularArrayEncoder
Detects and encodes uniform arrays of objects in efficient tabular format.
Tabular format declares field names once in a header and streams rows as CSV-like data.
-
Method Summary
Modifier and TypeMethodDescriptiondetectTabularHeader(tools.jackson.databind.node.ArrayNode rows) Detects if an array can be encoded in tabular format.static voidencodeArrayOfObjectsAsTabular(String prefix, tools.jackson.databind.node.ArrayNode rows, List<String> header, LineWriter writer, int depth, EncodeOptions options) Encodes an array of objects as a tabular structure.static voidwriteTabularRows(tools.jackson.databind.node.ArrayNode rows, List<String> header, LineWriter writer, int depth, EncodeOptions options) Writes rows of tabular data by extracting values in header order.
-
Method Details
-
detectTabularHeader
Detects if an array can be encoded in tabular format. Returns the header fields if tabular encoding is possible, empty list otherwise.- Parameters:
rows- The array to analyze- Returns:
- List of field names for tabular header, or empty list if not tabular
-
encodeArrayOfObjectsAsTabular
public static void encodeArrayOfObjectsAsTabular(String prefix, tools.jackson.databind.node.ArrayNode rows, List<String> header, LineWriter writer, int depth, EncodeOptions options) Encodes an array of objects as a tabular structure.- Parameters:
prefix- Optional key prefixrows- Array of uniform objectsheader- List of field nameswriter- LineWriter for outputdepth- Indentation depthoptions- Encoding options
-
writeTabularRows
public static void writeTabularRows(tools.jackson.databind.node.ArrayNode rows, List<String> header, LineWriter writer, int depth, EncodeOptions options) Writes rows of tabular data by extracting values in header order. Public to allow ListItemEncoder to write rows after placing header on "- " line.- Parameters:
rows- Array of objectsheader- List of field nameswriter- LineWriter for outputdepth- Indentation depthoptions- Encoding options
-