Implementation:APIJSON APIJSON AbstractParser onArrayParse
| Knowledge Sources | |
|---|---|
| Domains | ORM, Pagination, Request_Processing |
| Last Updated | 2026-10-11 00:00 GMT |
Overview
Concrete array parser that processes key[] paginated query directives, extracting page/count/query parameters, enforcing limits, and orchestrating per-item object parsing within the array context, provided by the APIJSON ORM framework.
Description
The onArrayParse' method on AbstractParser handles array-keyed (key[]) request objects. It:
- Extracts pagination parameters: query (0=TABLE, 1=TOTAL, 2=ALL), count (items per page), page (page number), join
- Validates against limits: getMaxQueryPage(), getMaxQueryCount(), getMinQueryPage()
- Creates a SQLConfig with the array context (type, position, count, page)
- Iterates up to count times, calling onObjectParse for each item
- For query=1 (TOTAL) or query=2 (ALL): executes an additional count query
- Extracts child table data from the first item if the array key matches a table name (optimization for Table[]: { Table: {} })
- Restores removed pagination keys after processing
The method also handles the compat flag for aggregate function pagination compatibility.
Usage
Called internally by AbstractObjectParser.onChildParse() when encountering array keys. Not typically called directly.
Code Reference
Source Location
- Repository: APIJSON
- File: src/main/java/apijson/orm/AbstractParser.java
Signature
public L onArrayParse(
M request,
String parentPath,
String name,
boolean isSubquery,
L cache
) throws Exception
Parameters:
- request - The array config object with pagination keys and table objects
- parentPath - Path from root to parent
- name - Array key name (e.g., "Comment[]")
- isSubquery - Whether this array is inside a subquery
- cache - Result cache list
Returns: L (List<Object>) - Array of results
Import
import apijson.orm.AbstractParser;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| request | M | Yes | Array config with pagination keys |
| query | String | No | "0"=TABLE, "1"=TOTAL, "2"=ALL |
| count | Integer | No | Items per page |
| page | Integer | No | Page number (0-based) |
| join | Object | No | Join directive |
Outputs
| Name | Type | Description |
|---|---|---|
| return | L (List<Object>) | Array of result items |
| total | int | Total count (when query=1 or 2) |
| info | M | Pagination info (total, count, page, max, more, first, last) |
Usage Examples
Paginated Query
// Request: {
// "[]": {
// "count": 5,
// "page": 0,
// "Moment": {}
// }
// }
// onArrayParse extracts: query=TABLE, count=5, page=0
// Creates SQLConfig with count=5, page=0
// Calls onObjectParse 5 times (or until empty result)
// Returns: [ { Moment: {...} }, { Moment: {...} }, ... ]
Total Count Query
// Request: {
// "[]": {
// "count": 5,
// "page": 0,
// "query": 2, // ALL: both data and total
// "Moment": {}
// }
// }
// Executes:
// 1. HEAD query for total: SELECT count(*) FROM Moment
// 2. Data query: SELECT * FROM Moment LIMIT 5 OFFSET 0
// Puts total and pagination info in queryResultMap