/*Copyright (C) 2026 the APIJSON group. All rights reserved.
This source code is licensed under the Apache License Version 2.0.*/
package apijson.orm;
import java.sql.SQLException;
import java.sql.Savepoint;
import java.util.List;
import java.util.Map;
import apijson.*;
/**
* @author Lemon
*/
public interface Parser
extends ParserCreator, VerifierCreator, SQLCreator {
@NotNull
Visitor getVisitor();
Parser setVisitor(@NotNull Visitor visitor);
@NotNull
RequestMethod getMethod();
Parser setMethod(@NotNull RequestMethod method);
int getVersion();
Parser setVersion(int version);
String getTag();
Parser setTag(String tag);
M getRequest();
Parser setRequest(M request);
Parser setNeedVerify(boolean needVerify);
boolean isNeedVerifyLogin();
Parser setNeedVerifyLogin(boolean needVerifyLogin);
boolean isNeedVerifyRole();
Parser setNeedVerifyRole(boolean needVerifyRole);
boolean isNeedVerifyContent();
Parser setNeedVerifyContent(boolean needVerifyContent);
String parse(String request);
String parse(M request);
M parseResponse(String request);
M parseResponse(M request);
// JSONRequest parseCorrectResponse(String table, JSONRequest response) throws Exception;
M parseCorrectRequest() throws Exception;
M parseCorrectRequest(RequestMethod method, String tag, int version, String name, M request,
int maxUpdateCount, SQLCreator creator) throws Exception;
Map getStructure(String table, String method, String tag, int version) throws Exception;
M onObjectParse(M request, String parentPath, String name, SQLConfig arrayConfig, boolean isSubquery, M cache) throws Exception;
L onArrayParse(M request, String parentPath, String name, boolean isSubquery, L cache) throws Exception;
/**
* @param key
* @param function
* @param parentPath
* @param currentName
* @param currentObject
* @return
* @throws Exception
*/
Object onFunctionParse(String key, String function, String parentPath, String currentName, M currentObject, boolean containRaw) throws Exception;
ObjectParser createObjectParser(M request, String parentPath, SQLConfig arrayConfig, boolean isSubquery, boolean isTable, boolean isArrayMainTable) throws Exception;
int getMinQueryPage();
int getMaxQueryPage();
int getDefaultQueryCount();
int getMaxQueryCount();
int getMaxUpdateCount();
int getMaxSQLCount();
int getMaxObjectCount();
int getMaxArrayCount();
int getMaxQueryDepth();
void putQueryResult(String path, Object result);
Object getValueByPath(String valuePath);
void onVerifyLogin() throws Exception;
void onVerifyContent() throws Exception;
void onVerifyRole(SQLConfig config) throws Exception;
M executeSQL(SQLConfig config, boolean isSubquery) throws Exception;
SQLExecutor getSQLExecutor();
Verifier getVerifier();
Boolean getGlobalFormat();
String getGlobalRole();
String getGlobalDatabase();
String getGlobalDatasource();
String getGlobalNamespace();
String getGlobalCatalog();
String getGlobalSchema();
Boolean getGlobalExplain();
String getGlobalCache();
int getTransactionIsolation();
void setTransactionIsolation(int transactionIsolation);
void begin(int transactionIsolation);
void rollback() throws SQLException;
void rollback(Savepoint savepoint) throws SQLException;
void commit() throws SQLException;
void close();
M newSuccessResult();
M newErrorResult(Exception e);
}