All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.odysz.transact.sql.PageInf Maven / Gradle / Ivy

package io.odysz.transact.sql;

import static io.odysz.common.LangExt.eq;
import static io.odysz.common.LangExt.isNull;
import static io.odysz.common.LangExt.len;

import java.util.ArrayList;
import java.util.HashMap;

import io.odysz.anson.Anson;

/**
 * 

DB records' page information.

* *

This type should presented in all request with A = records in the near future.

* *
Use case:
* 1. Semantic.jserv/io.oz.spreadsheet.SpreadsheetReq.pageInf,
* Anclient.ts:
* curriculum/views/north/AllDecissionsComp.conds
* curriculum/views/north/MyComp.conds
* ...
* * 2. Docsync.jserv/io.oz.jserv.dbsync.DBSyncReq.pageInf,
* Anclient.java:
* Docsync.jserv/io.oz.jserv.dbsync.DBWorker#syncTabl()
* * 3. Sandbox, Album-jserv/Streetier.stree * * 4. ... * @author [email protected] * */ public class PageInf extends Anson { public long page; public long size; public long total; public ArrayList arrCondts; public HashMap mapCondts; public PageInf() { this.arrCondts = new ArrayList(); this.mapCondts = new HashMap(); } public PageInf(long page, long size, String... condt) { this.page = page; this.size = size; this.arrCondts = new ArrayList(); if (!isNull(condt)) arrCondts.add(condt); mapCondts = new HashMap(); } /** * condts = [[...arg0s], string[] other-args] * @param arg0s * @return this */ public PageInf insertCondt(String... arg0s) { this.arrCondts.add(0, arg0s); return this; } public PageInf mergeArgs() { if (len(mapCondts) > 0) for (String k : mapCondts.keySet()) arrCondts.add(new String[] {k, (String)mapCondts.get(k)}); mapCondts.clear(); return this; } /** * Reshape 2D array of n-v pairs to string array for string.format(). * * @return args array */ public String[] arrCondts2args() { ArrayList args = new ArrayList(arrCondts.size()); for (String[] arg : arrCondts) { args.add(isNull(arg) ? "" : arg[arg.length - 1]); } return args.toArray(new String[0]); } public String getArg(String argName) { if (mapCondts != null && mapCondts.containsKey(argName)) return (String)mapCondts.get(argName); else if (arrCondts != null) { for (String[] nv : arrCondts) if (eq(nv[0], argName)) return nv[1]; } return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy