Author: markt Date: Mon Oct 27 23:05:59 2014 New Revision: 1634729 URL: http://svn.apache.org/r1634729 Log: Add a peek method that allows the look ahead to be specified
Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java?rev=1634729&r1=1634728&r2=1634729&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java (original) +++ tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java Mon Oct 27 23:05:59 2014 @@ -248,10 +248,30 @@ class JspReader { return caw.toString(); } + /** + * Read ahead one character without moving the cursor. + * + * @return The next character or -1 if no further input is available + */ int peekChar() { - if (!hasMoreInput()) + return peekChar(0); + } + + /** + * Read ahead the given number of characters without moving the cursor. + * + * @param readAhead The number of characters to read ahead. NOTE: This is + * zero based. + * + * @return The requested character or -1 if the end of the input is reached + * first + */ + int peekChar(int readAhead) { + int target = current.cursor + readAhead; + if (target < current.stream.length) { return -1; - return current.stream[current.cursor]; + } + return current.stream[target]; } Mark mark() { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org