TokenList implements TokenSource { @Override public Token nextToken() { if ((currentToken != null) && (currentToken.getType() == Token.EOF)) { return currentToken; } if (queue.isEmpty()) { fillHeap(); } ProToken tok = queue.poll(); if (tok != null) { currentToken = tok; currentToken.setTokenIndex(currentPosition++); } return currentToken; } TokenList(TokenSource input); @Override Token nextToken(); @Override int getLine(); @Override int getCharPositionInLine(); @Override CharStream getInputStream(); @Override String getSourceName(); @Override void setTokenFactory(TokenFactory<?> factory); @Override TokenFactory<?> getTokenFactory();  }
@Test public void testTokenList03() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("MESSAGE Progress. Security.PAMStatus:AccessDenied.".getBytes()), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); assertEquals(src.nextToken().getType(), Proparse.MESSAGE); assertEquals(src.nextToken().getType(), Proparse.WS); Token tok = src.nextToken(); assertEquals(tok.getType(), Proparse.ID); assertEquals(tok.getText(), "Progress.Security.PAMStatus"); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); }
@Test public void testTokenList04() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap(".Security.PAMStatus:AccessDenied.".getBytes()), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); assertEquals(src.nextToken().getType(), Proparse.NAMEDOT); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); }
@Test public void testTokenList05() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("MESSAGE customer.custnum Progress.Security.PAMStatus:AccessDenied.\nMESSAGE customer.custnum. Progress.Security.PAMStatus:AccessDenied.".getBytes()), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); assertEquals(src.nextToken().getType(), Proparse.MESSAGE); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.MESSAGE); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); }
@Test public void testTokenList06() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap(":AccessDenied.".getBytes()), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); }
@Test public void testTokenList07() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap(".. :PAMStatus.".getBytes()), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); }
@Test public void testTokenList08() { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap("\n{&procedure-handle}:file-name + \"_\":U + string({&procedure-handle})".getBytes()), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); assertEquals(src.nextToken().getType(), Proparse.COMMENT); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.OBJCOLON); assertEquals(src.nextToken().getType(), Proparse.FILE); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.PLUS); }
@Test public void testTokenList09() { try (InputStream input = new FileInputStream(new File(SRC_DIR, "tokenlist09.p"))) { ABLLexer lexer = new ABLLexer(session, ByteSource.wrap(ByteStreams.toByteArray(input)), "file.txt"); TokenSource filter0 = new NameDotTokenFilter(lexer); TokenSource src = new TokenList(filter0); Token tok1 = src.nextToken(); assertEquals(tok1.getType(), Proparse.ID); assertEquals(tok1.getText(), "customer.name"); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.ID); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); Token tok2 = src.nextToken(); assertEquals(tok2.getType(), Proparse.ID); assertEquals(tok2.getText(), "customer.name"); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); Token tok3 = src.nextToken(); assertEquals(tok3.getType(), Proparse.ID); assertEquals(tok3.getText(), "customer.name"); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.MESSAGE); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.QSTRING); assertEquals(src.nextToken().getType(), Proparse.NAMEDOT); assertEquals(src.nextToken().getType(), Proparse.COMMENT); assertEquals(src.nextToken().getType(), Proparse.MESSAGE); assertEquals(src.nextToken().getType(), Proparse.WS); assertEquals(src.nextToken().getType(), Proparse.QSTRING); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); Token tok4 = src.nextToken(); assertEquals(tok4.getType(), Proparse.ID); assertEquals(tok4.getText(), "customer.name"); assertEquals(src.nextToken().getType(), Proparse.PERIOD); assertEquals(src.nextToken().getType(), Proparse.WS); } catch (IOException caught) { fail("Unable to open file", caught); } }