biblivre3.cataloging.bibliographic.BiblioSearchResultsDTO.java Source code

Java tutorial

Introduction

Here is the source code for biblivre3.cataloging.bibliographic.BiblioSearchResultsDTO.java

Source

/**
 *  Este arquivo  parte do Biblivre3.
 *  
 *  Biblivre3  um software livre; voc pode redistribu-lo e/ou 
 *  modific-lo dentro dos termos da Licena Pblica Geral GNU como 
 *  publicada pela Fundao do Software Livre (FSF); na verso 3 da 
 *  Licena, ou (caso queira) qualquer verso posterior.
 *  
 *  Este programa  distribudo na esperana de que possa ser  til, 
 *  mas SEM NENHUMA GARANTIA; nem mesmo a garantia implcita de
 *  MERCANTIBILIDADE OU ADEQUAO PARA UM FIM PARTICULAR. Veja a
 *  Licena Pblica Geral GNU para maiores detalhes.
 *  
 *  Voc deve ter recebido uma cpia da Licena Pblica Geral GNU junto
 *  com este programa, Se no, veja em <http://www.gnu.org/licenses/>.
 * 
 *  @author Alberto Wagner <alberto@biblivre.org.br>
 *  @author Danniel Willian <danniel@biblivre.org.br>
 * 
 */

package biblivre3.cataloging.bibliographic;

import java.util.ArrayList;
import java.util.Properties;
import mercury.DTO;
import mercury.IFJson;
import org.json.JSONException;
import org.json.JSONObject;

public class BiblioSearchResultsDTO extends DTO implements IFJson {
    public ArrayList<ResultRow> al;
    public int totalPages;
    public int totalRecords;
    public int currentPage;
    public int recordsPerPage;

    @Override
    public JSONObject toJSONObject(Properties properties) {
        JSONObject json = new JSONObject();

        try {
            json.put("totalPages", this.totalPages);
            json.put("totalRecords", this.totalRecords);
            json.put("currentPage", this.currentPage);
            json.put("recordsPerPage", this.recordsPerPage);

            for (ResultRow rr : this.al) {
                json.append("results", rr.toJSONObject(null));
            }
        } catch (JSONException e) {
        }

        return json;
    }

    public int getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(int totalRecords) {
        this.totalRecords = totalRecords;
    }
}