// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
//     private PageBuilder<T, E> pageBuilder;
//     private E pageParam;
// 
//     public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
//         return new PageContext<T, E>()
//                 .setPageBuilder(builder)
//                 .setPageParam(pageParam);
//     }
// 
//     public PageBuilder<T, E> getPageBuilder() {
//         return pageBuilder;
//     }
// 
//     public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
//         this.pageBuilder = pageBuilder;
//         return this;
//     }
// 
//     public E getPageParam() {
//         return pageParam;
//     }
// 
//     public PageContext setPageParam(E pageParam) {
//         this.pageParam = pageParam;
//         return this;
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
// 
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
// 
//     public PageNode parse(String limitExpression) {
//         try {
//             return createLimitParser(limitExpression).parse();
//         } catch (ParseException | Error e) {
//             throw new LimitParsingException(e);
//         }
//     }
// 
//     private LimitTokenParser createLimitParser(String expression) {
//         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
//         return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
//     private Long start;
//     private Long size;
// 
//     public Long getStart() {
//         return start;
//     }
// 
//     public PageNode setStart(Long start) {
//         this.start = start;
//         return this;
//     }
// 
//     public Long getSize() {
//         return size;
//     }
// 
//     public PageNode setSize(Long size) {
//         this.size = size;
//         return this;
//     }
// 
// }


import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext;
/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;


/**
 * @author vrustia - 4/8/16.
 */
public class DefaultPageParser implements PageParser {

    private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();

    @Override
    public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageContext.java
// public class PageContext<T, E extends PageParam> {
//     private PageBuilder<T, E> pageBuilder;
//     private E pageParam;
// 
//     public static <T, E extends PageParam> PageContext<T, E> withBuilderAndParam(PageBuilder<T, E> builder, E pageParam) {
//         return new PageContext<T, E>()
//                 .setPageBuilder(builder)
//                 .setPageParam(pageParam);
//     }
// 
//     public PageBuilder<T, E> getPageBuilder() {
//         return pageBuilder;
//     }
// 
//     public PageContext setPageBuilder(PageBuilder<T, E> pageBuilder) {
//         this.pageBuilder = pageBuilder;
//         return this;
//     }
// 
//     public E getPageParam() {
//         return pageParam;
//     }
// 
//     public PageContext setPageParam(E pageParam) {
//         this.pageParam = pageParam;
//         return this;
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/PageParam.java
// public class PageParam {
// }
// 
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/LimitParserAdapter.java
// public class LimitParserAdapter {
// 
//     public PageNode parse(String limitExpression) {
//         try {
//             return createLimitParser(limitExpression).parse();
//         } catch (ParseException | Error e) {
//             throw new LimitParsingException(e);
//         }
//     }
// 
//     private LimitTokenParser createLimitParser(String expression) {
//         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(expression.getBytes(StandardCharsets.UTF_8));
//         return new LimitTokenParser(byteArrayInputStream, StandardCharsets.UTF_8.name());
//     }
// }
// 
// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/ast/PageNode.java
// public class PageNode {
//     private Long start;
//     private Long size;
// 
//     public Long getStart() {
//         return start;
//     }
// 
//     public PageNode setStart(Long start) {
//         this.start = start;
//         return this;
//     }
// 
//     public Long getSize() {
//         return size;
//     }
// 
//     public PageNode setSize(Long size) {
//         this.size = size;
//         return this;
//     }
// 
// }


// Path: rsql-api-parent/rsql-api-page/src/main/java/com/github/vineey/rql/page/parser/DefaultPageParser.java
import com.github.vineey.rql.page.PageParam;
import com.github.vineey.rql.page.parser.ast.LimitParserAdapter;
import com.github.vineey.rql.page.parser.ast.PageNode;
import com.github.vineey.rql.page.PageContext;

/*
* MIT License
*
* Copyright (c) 2016 John Michael Vincent S. Rustia
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.vineey.rql.page.parser;


/**
 * @author vrustia - 4/8/16.
 */
public class DefaultPageParser implements PageParser {

    private LimitParserAdapter limitParserAdapter = new LimitParserAdapter();

    @Override
    public <T, E extends PageParam> T parse(String limitExpression, PageContext<T, E> pageContext) {
        PageNode parsedPageNode = limitParserAdapter.parse(limitExpression);