Java tutorial
/******* Copyright 2015 NeuroBASE,Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. **********/ package com.echopf; import java.util.ArrayList; import org.json.JSONException; import org.json.JSONObject; /** * {@.en Composes a list with paginate data.} * {@.ja ????????} */ public class ECHOList<S extends ECHODataObject<S>> extends ArrayList<S> { private static final long serialVersionUID = 1L; private int page; private int prevPage; private int nextPage; private int pageCount; private int count; private int limit; private String order; private boolean asc; /** * Constructs a new ECHOList. * * @param data a copying paginate data in JSONObject. * @throws ECHOException */ protected ECHOList(JSONObject data) throws ECHOException { super(); copyPaginateData(data); } /** * {@.ja ??????} * {@.en Gets the current page no.} */ public int getPage() { return this.page; } /** * {@.ja ??????} * {@.en Gets the previous page no.} */ public int getPrevPage() { return this.prevPage; } /** * {@.ja ?????} * {@.en Gets the next page no.} */ public int getNextPage() { return this.nextPage; } /** * {@.ja ?????} * {@.en Gets the total number of pages.} */ public int getPageCount() { return this.pageCount; } /** * {@.ja ??????????} * {@.en Gets the total number of found objects.} */ public int getCount() { return this.count; } /** * {@.ja 1???????} * {@.en Gets the number of objects per a page.} */ public int getLimit() { return this.limit; } /** * {@.ja ????????} * {@.en Gets the field name of sorting criteria.} */ public String getOrder() { return this.order; } /** * {@.ja ????????????} * {@.en Gets whether to sort in ascending order.} */ public boolean isAsc() { return this.asc; } /** * Copies paginate data. * @throws ECHOException */ protected void copyPaginateData(JSONObject data) throws ECHOException { if (data == null) throw new IllegalArgumentException("argument `data` must not be null."); this.page = data.optInt("page"); this.prevPage = data.optInt("prevPage"); this.nextPage = data.optInt("nextPage"); this.pageCount = data.optInt("pageCount"); this.count = data.optInt("count"); this.limit = data.optInt("limit"); this.order = data.optString("order"); this.asc = data.optBoolean("asc"); } }