public void testCaseWhenParser() throws Exception { Parser<SelectProjection> parser = ExpressionParser.selectProjection(); SelectProjection sp = TerminalParser.parse( parser, "case when /*+ comment */ (this.age = 20) then 'self' else 'other' end as name"); // SelectProjection sp = TerminalParser.parse(parser, "case when /*+ comment */ (this.age > 20) // then 'self' else 'other' end as name"); Debug.line(sp); }
public Rows toRows(Page _page, String expr) { Parser<SelectProjection> parser = ExpressionParser.selectProjection(); SelectProjection sp = TerminalParser.parse(parser, expr); Page page = (_page == Page.ALL) ? Page.create(10000, 1) : _page; // limit IteratorList<ReadNode> iterator = this.iterator(); Iterators.skip(iterator, page.getSkipOnScreen()); Iterator<ReadNode> limitIter = Iterators.limit(iterator, page.getOffsetOnScreen()); List<ReadNode> screenList = ListUtil.newList(); while (limitIter.hasNext()) { screenList.add(limitIter.next()); } int count = screenList.size(); Page pageOnScreen = Page.create( page.getListNum(), page.getPageNo() % page.getScreenCount(), page.getScreenCount()); return AdNodeRows.create( session, pageOnScreen.subList(screenList).iterator(), sp, count, "cnt"); }
public Rows toRows(String expr) { Parser<SelectProjection> parser = ExpressionParser.selectProjection(); SelectProjection sp = TerminalParser.parse(parser, expr); return AdNodeRows.create(session, iterator(), sp); }