package com.hongshee.ejforum.data.sql;

/**
 * <p>Title: HsqldbAdapter.java</p>
 * <p>Description: HsqldbAdapter</p>
 * <p>Copyright: Hongshee Software (c) 2007</p>
 * @author jackie du
 * @version 1.0
 */
import com.hongshee.ejforum.data.SqlAdapter;

public class HsqldbAdapter extends SqlAdapter 
{
    public HsqldbAdapter()
    {
    }
    
    public void init() throws Exception
    {}
    
    public String getPageQuerySql(StringBuilder sqlBuf, 
                                  int pageNo, int pageRows, int totalCount)
    {
        int[] pageParams = getPageQueryParams(pageNo, pageRows, totalCount);
        return sqlBuf.append(" limit ").append(pageParams[0])
                     .append(" offset ").append(pageParams[1]).toString();
    }
    
    protected int[] getPageQueryParams(int pageNo, int pageRows, int totalCount)
    {
        int[] result = new int[2];
        int offset = (pageNo-1) * pageRows;
        result[0] = pageRows;
        result[1] = offset;
        return result;
    }
    
}
