Kenmegne
2025-12-10 e9d80d486b912144b59ebd5939d4837105b37b99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.megatim.queryadhoc.queries.metadata;
 
import com.megatim.queryadhoc.exceptions.BadDataValueException;
import com.megatim.queryadhoc.exceptions.ColumnNotFoundException;
import com.megatim.queryadhoc.exceptions.LocalDateTimeValueParseError;
import com.megatim.queryadhoc.model.DbColumnDescription;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 *
 * @author ASUS
 */
public class ParsedData {
 
    private final List<Map<String, Object>> sourceData;
    private final List<DbColumnDescription> columnsDescription;
    private final String tableName;
    private final List<Map<String, Object>> cachedData = new ArrayList<>();
 
    public ParsedData(List<Map<String, Object>> sourceData, List<DbColumnDescription> columnsDescription, String tableName) {
        this.sourceData = sourceData;
        this.tableName = tableName;
        this.columnsDescription = columnsDescription;
    }
 
    public List<Map<String, Object>> data() throws BadDataValueException, LocalDateTimeValueParseError, ColumnNotFoundException {
        if (cachedData.isEmpty()) {
            for (Map<String, Object> data : sourceData) {
                cachedData.add(new ParsedDataRow(data, columnsDescription, tableName).dataRow());
            }
        }
        return cachedData;
    }
}