http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Node.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Node.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Node.java index fe8b532..24b1711 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Node.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Node.java @@ -19,11 +19,11 @@ package org.apache.struts2.el.parser; +import org.apache.struts2.el.lang.EvaluationContext; + import javax.el.ELException; import javax.el.MethodInfo; -import org.apache.struts2.el.lang.EvaluationContext; - /* All AST nodes must implement this interface. It provides basic machinery for constructing the parent and child relationships @@ -35,37 +35,65 @@ import org.apache.struts2.el.lang.EvaluationContext; */ public interface Node { - /** This method is called after the node has been made the current - node. It indicates that child nodes can now be added to it. */ - public void jjtOpen(); - - /** This method is called after all the child nodes have been - added. */ - public void jjtClose(); - - /** This pair of methods are used to inform the node of its - parent. */ - public void jjtSetParent(Node n); - public Node jjtGetParent(); - - /** This method tells the node to add its argument to the node's - list of children. */ - public void jjtAddChild(Node n, int i); - - /** This method returns a child node. The children are numbered - from zero, left to right. */ - public Node jjtGetChild(int i); - - /** Return the number of children the node has. */ - public int jjtGetNumChildren(); - - public String getImage(); - - public Object getValue(EvaluationContext ctx) throws ELException; - public void setValue(EvaluationContext ctx, Object value) throws ELException; - public Class getType(EvaluationContext ctx) throws ELException; - public boolean isReadOnly(EvaluationContext ctx) throws ELException; - public void accept(NodeVisitor visitor) throws Exception; - public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) throws ELException; - public Object invoke(EvaluationContext ctx, Class[] paramTypes, Object[] paramValues) throws ELException; + /** + * This method is called after the node has been made the current + * node. It indicates that child nodes can now be added to it. + */ + public void jjtOpen(); + + /** + * This method is called after all the child nodes have been + * added. + */ + public void jjtClose(); + + /** + * This pair of methods are used to inform the node of its + * parent. + * + * @param n the node + */ + public void jjtSetParent(Node n); + + public Node jjtGetParent(); + + /** + * This method tells the node to add its argument to the node's + * list of children. + * + * @param n the node + * @param i i + */ + public void jjtAddChild(Node n, int i); + + /** + * This method returns a child node. The children are numbered + * from zero, left to right. + * + * @param i i + * + * @return child node + */ + public Node jjtGetChild(int i); + + /** + * @return the number of children the node has. + */ + public int jjtGetNumChildren(); + + public String getImage(); + + public Object getValue(EvaluationContext ctx) throws ELException; + + public void setValue(EvaluationContext ctx, Object value) throws ELException; + + public Class getType(EvaluationContext ctx) throws ELException; + + public boolean isReadOnly(EvaluationContext ctx) throws ELException; + + public void accept(NodeVisitor visitor) throws Exception; + + public MethodInfo getMethodInfo(EvaluationContext ctx, Class[] paramTypes) throws ELException; + + public Object invoke(EvaluationContext ctx, Class[] paramTypes, Object[] paramValues) throws ELException; }
http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ParseException.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ParseException.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ParseException.java index 231d73c..a57e7da 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ParseException.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/ParseException.java @@ -23,7 +23,11 @@ public class ParseException extends Exception { * This constructor calls its super class with the empty string * to force the "toString" method of parent class "Throwable" to * print the error message in the form: - * ParseException: <result of getMessage> + * ParseException: <result of getMessage> + * + * @param currentTokenVal current token value + * @param expectedTokenSequencesVal expected token sequence value + * @param tokenImageVal token image value */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, @@ -52,7 +56,11 @@ public class ParseException extends Exception { specialConstructor = false; } - /** Constructor with message. */ + /** + * Constructor with message. + * + * @param message exception message + */ public ParseException(String message) { super(message); specialConstructor = false; @@ -68,7 +76,7 @@ public class ParseException extends Exception { /** * This is the last token that has been consumed successfully. If * this object has been created due to a parse error, the token - * followng this token will (therefore) be the first error token. + * following this token will (therefore) be the first error token. */ public Token currentToken; @@ -95,25 +103,27 @@ public class ParseException extends Exception { * from the parser), then this method is called during the printing * of the final stack trace, and hence the correct error message * gets displayed. + * + * @return the exception message */ public String getMessage() { if (!specialConstructor) { return super.getMessage(); } - StringBuffer expected = new StringBuffer(); + StringBuilder expected = new StringBuilder(); int maxSize = 0; - for (int i = 0; i < expectedTokenSequences.length; i++) { - if (maxSize < expectedTokenSequences[i].length) { - maxSize = expectedTokenSequences[i].length; - } - for (int j = 0; j < expectedTokenSequences[i].length; j++) { - expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' '); + for (int[] expectedTokenSequence : expectedTokenSequences) { + if (maxSize < expectedTokenSequence.length) { + maxSize = expectedTokenSequence.length; + } + for (int anExpectedTokenSequence : expectedTokenSequence) { + expected.append(tokenImage[anExpectedTokenSequence]).append(' '); + } + if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0) { + expected.append("..."); + } + expected.append(eol).append(" "); } - if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) { - expected.append("..."); - } - expected.append(eol).append(" "); - } String retval = "Encountered \""; Token tok = currentToken.next; for (int i = 0; i < maxSize; i++) { @@ -148,9 +158,12 @@ public class ParseException extends Exception { * Used to convert raw characters to their escaped version * when these raw version cannot be used as part of an ASCII * string literal. + * + * @param str string to escape + * @return string with escapes */ protected String add_escapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) @@ -184,11 +197,10 @@ public class ParseException extends Exception { default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } - continue; } } return retval.toString(); http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/SimpleCharStream.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/SimpleCharStream.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/SimpleCharStream.java index 9e4a407..bb7f01e 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/SimpleCharStream.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/SimpleCharStream.java @@ -7,466 +7,567 @@ package org.apache.struts2.el.parser; * contain only ASCII characters (without unicode processing). */ -public class SimpleCharStream -{ -/** Whether parser is static. */ - public static final boolean staticFlag = false; - int bufsize; - int available; - int tokenBegin; -/** Position in buffer. */ - public int bufpos = -1; - protected int bufline[]; - protected int bufcolumn[]; - - protected int column = 0; - protected int line = 1; - - protected boolean prevCharIsCR = false; - protected boolean prevCharIsLF = false; - - protected java.io.Reader inputStream; - - protected char[] buffer; - protected int maxNextCharInd = 0; - protected int inBuf = 0; - protected int tabSize = 8; - - protected void setTabSize(int i) { tabSize = i; } - protected int getTabSize(int i) { return tabSize; } - - - protected void ExpandBuff(boolean wrapAround) - { - char[] newbuffer = new char[bufsize + 2048]; - int newbufline[] = new int[bufsize + 2048]; - int newbufcolumn[] = new int[bufsize + 2048]; - - try - { - if (wrapAround) - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - System.arraycopy(buffer, 0, newbuffer, - bufsize - tokenBegin, bufpos); - buffer = newbuffer; - - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); - bufline = newbufline; - - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); - bufcolumn = newbufcolumn; - - maxNextCharInd = (bufpos += (bufsize - tokenBegin)); +public class SimpleCharStream { + /** + * Whether parser is static. + */ + public static final boolean staticFlag = false; + int bufsize; + int available; + int tokenBegin; + /** + * Position in buffer. + */ + public int bufpos = -1; + protected int bufline[]; + protected int bufcolumn[]; + + protected int column = 0; + protected int line = 1; + + protected boolean prevCharIsCR = false; + protected boolean prevCharIsLF = false; + + protected java.io.Reader inputStream; + + protected char[] buffer; + protected int maxNextCharInd = 0; + protected int inBuf = 0; + protected int tabSize = 8; + + protected void setTabSize(int i) { + tabSize = i; + } + + protected int getTabSize(int i) { + return tabSize; + } + + + protected void ExpandBuff(boolean wrapAround) { + char[] newbuffer = new char[bufsize + 2048]; + int newbufline[] = new int[bufsize + 2048]; + int newbufcolumn[] = new int[bufsize + 2048]; + + try { + if (wrapAround) { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + System.arraycopy(buffer, 0, newbuffer, + bufsize - tokenBegin, bufpos); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos += (bufsize - tokenBegin)); + } else { + System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); + buffer = newbuffer; + + System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); + bufline = newbufline; + + System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); + bufcolumn = newbufcolumn; + + maxNextCharInd = (bufpos -= tokenBegin); + } + } catch (Throwable t) { + throw new Error(t.getMessage()); } - else - { - System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin); - buffer = newbuffer; - System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin); - bufline = newbufline; - System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin); - bufcolumn = newbufcolumn; + bufsize += 2048; + available = bufsize; + tokenBegin = 0; + } - maxNextCharInd = (bufpos -= tokenBegin); + protected void FillBuff() throws java.io.IOException { + if (maxNextCharInd == available) { + if (available == bufsize) { + if (tokenBegin > 2048) { + bufpos = maxNextCharInd = 0; + available = tokenBegin; + } else if (tokenBegin < 0) + bufpos = maxNextCharInd = 0; + else + ExpandBuff(false); + } else if (available > tokenBegin) + available = bufsize; + else if ((tokenBegin - available) < 2048) + ExpandBuff(true); + else + available = tokenBegin; } - } - catch (Throwable t) - { - throw new Error(t.getMessage()); - } - - - bufsize += 2048; - available = bufsize; - tokenBegin = 0; - } - - protected void FillBuff() throws java.io.IOException - { - if (maxNextCharInd == available) - { - if (available == bufsize) - { - if (tokenBegin > 2048) - { - bufpos = maxNextCharInd = 0; - available = tokenBegin; - } - else if (tokenBegin < 0) - bufpos = maxNextCharInd = 0; - else - ExpandBuff(false); + + int i; + try { + if ((i = inputStream.read(buffer, maxNextCharInd, + available - maxNextCharInd)) == -1) { + inputStream.close(); + throw new java.io.IOException(); + } else + maxNextCharInd += i; + return; + } catch (java.io.IOException e) { + --bufpos; + backup(0); + if (tokenBegin == -1) + tokenBegin = bufpos; + throw e; } - else if (available > tokenBegin) - available = bufsize; - else if ((tokenBegin - available) < 2048) - ExpandBuff(true); - else - available = tokenBegin; - } - - int i; - try { - if ((i = inputStream.read(buffer, maxNextCharInd, - available - maxNextCharInd)) == -1) - { - inputStream.close(); - throw new java.io.IOException(); + } + + /** + * Start. + * + * @return first char + * @throws java.io.IOException in case of IO errors + */ + public char BeginToken() throws java.io.IOException { + tokenBegin = -1; + char c = readChar(); + tokenBegin = bufpos; + + return c; + } + + protected void UpdateLineColumn(char c) { + column++; + + if (prevCharIsLF) { + prevCharIsLF = false; + line += (column = 1); + } else if (prevCharIsCR) { + prevCharIsCR = false; + if (c == '\n') { + prevCharIsLF = true; + } else + line += (column = 1); } - else - maxNextCharInd += i; - return; - } - catch(java.io.IOException e) { - --bufpos; - backup(0); - if (tokenBegin == -1) - tokenBegin = bufpos; - throw e; - } - } - -/** Start. */ - public char BeginToken() throws java.io.IOException - { - tokenBegin = -1; - char c = readChar(); - tokenBegin = bufpos; - - return c; - } - - protected void UpdateLineColumn(char c) - { - column++; - - if (prevCharIsLF) - { - prevCharIsLF = false; - line += (column = 1); - } - else if (prevCharIsCR) - { - prevCharIsCR = false; - if (c == '\n') - { - prevCharIsLF = true; + + switch (c) { + case '\r': + prevCharIsCR = true; + break; + case '\n': + prevCharIsLF = true; + break; + case '\t': + column--; + column += (tabSize - (column % tabSize)); + break; + default: + break; + } + + bufline[bufpos] = line; + bufcolumn[bufpos] = column; + } + + /** + * Read a character. + * @return character + * @throws java.io.IOException in case of IO errors + */ + public char readChar() throws java.io.IOException { + if (inBuf > 0) { + --inBuf; + + if (++bufpos == bufsize) + bufpos = 0; + + return buffer[bufpos]; + } + + if (++bufpos >= maxNextCharInd) + FillBuff(); + + char c = buffer[bufpos]; + + UpdateLineColumn(c); + return c; + } + + /** + * @return column + * @see #getEndColumn + * @deprecated + */ + + public int getColumn() { + return bufcolumn[bufpos]; + } + + /** + * @return line + * @see #getEndLine + * @deprecated + */ + + public int getLine() { + return bufline[bufpos]; + } + + /** + * @return token end column number. + */ + public int getEndColumn() { + return bufcolumn[bufpos]; + } + + /** + * @return token end line number. + */ + public int getEndLine() { + return bufline[bufpos]; + } + + /** + * @return token beginning column number. + */ + public int getBeginColumn() { + return bufcolumn[tokenBegin]; + } + + /** + * @return token beginning line number. + */ + public int getBeginLine() { + return bufline[tokenBegin]; + } + + /** + * Backup a number of characters. + * @param amount amount of characters + */ + public void backup(int amount) { + + inBuf += amount; + if ((bufpos -= amount) < 0) + bufpos += bufsize; + } + + /** + * Constructor. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size + */ + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; + } + + /** + * Constructor. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + */ + public SimpleCharStream(java.io.Reader dstream, int startline, + int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + /** + * Constructor. + * + * @param dstream stream + */ + public SimpleCharStream(java.io.Reader dstream) { + this(dstream, 1, 1, 4096); + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size + */ + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn, int buffersize) { + inputStream = dstream; + line = startline; + column = startcolumn - 1; + + if (buffer == null || buffersize != buffer.length) { + available = bufsize = buffersize; + buffer = new char[buffersize]; + bufline = new int[buffersize]; + bufcolumn = new int[buffersize]; } + prevCharIsLF = prevCharIsCR = false; + tokenBegin = inBuf = maxNextCharInd = 0; + bufpos = -1; + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + */ + public void ReInit(java.io.Reader dstream, int startline, + int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + /** + * Reinitialise. + * + * @param dstream stream + */ + public void ReInit(java.io.Reader dstream) { + ReInit(dstream, 1, 1, 4096); + } + + /** + * Constructor. + * + * @param dstream stream + * @param encoding encoding + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size + * @throws java.io.UnsupportedEncodingException in case of unsupported encoding + */ + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { + this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** + * Constructor. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size + */ + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) { + this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** + * Constructor. + * + * @param dstream stream + * @param encoding encoding + * @param startline start line + * @param startcolumn start column + * @throws java.io.UnsupportedEncodingException in case of unsupported encoding + */ + public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException { + this(dstream, encoding, startline, startcolumn, 4096); + } + + /** + * Constructor. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + */ + public SimpleCharStream(java.io.InputStream dstream, int startline, + int startcolumn) { + this(dstream, startline, startcolumn, 4096); + } + + /** + * Constructor. + * + * @param dstream stream + * @param encoding encoding + * @throws java.io.UnsupportedEncodingException in case of unsupported encoding + */ + public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { + this(dstream, encoding, 1, 1, 4096); + } + + /** + * Constructor. + * + * @param dstream stream + */ + public SimpleCharStream(java.io.InputStream dstream) { + this(dstream, 1, 1, 4096); + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param encoding encoding + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size + * @throws java.io.UnsupportedEncodingException in case of unsupported encoding + */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException { + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + * @param buffersize buffer size + */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn, int buffersize) { + ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param encoding encoding + * @throws java.io.UnsupportedEncodingException in case of unsupported encoding + */ + public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException { + ReInit(dstream, encoding, 1, 1, 4096); + } + + /** + * Reinitialise. + * + * @param dstream stream + */ + public void ReInit(java.io.InputStream dstream) { + ReInit(dstream, 1, 1, 4096); + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param encoding encoding + * @param startline start line + * @param startcolumn start column + * @throws java.io.UnsupportedEncodingException in case of unsupported encoding + */ + public void ReInit(java.io.InputStream dstream, String encoding, int startline, + int startcolumn) throws java.io.UnsupportedEncodingException { + ReInit(dstream, encoding, startline, startcolumn, 4096); + } + + /** + * Reinitialise. + * + * @param dstream stream + * @param startline start line + * @param startcolumn start column + */ + public void ReInit(java.io.InputStream dstream, int startline, + int startcolumn) { + ReInit(dstream, startline, startcolumn, 4096); + } + + /** + * @return token literal value. + */ + public String GetImage() { + if (bufpos >= tokenBegin) + return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); else - line += (column = 1); - } - - switch (c) - { - case '\r' : - prevCharIsCR = true; - break; - case '\n' : - prevCharIsLF = true; - break; - case '\t' : - column--; - column += (tabSize - (column % tabSize)); - break; - default : - break; - } - - bufline[bufpos] = line; - bufcolumn[bufpos] = column; - } - -/** Read a character. */ - public char readChar() throws java.io.IOException - { - if (inBuf > 0) - { - --inBuf; - - if (++bufpos == bufsize) - bufpos = 0; - - return buffer[bufpos]; - } - - if (++bufpos >= maxNextCharInd) - FillBuff(); - - char c = buffer[bufpos]; - - UpdateLineColumn(c); - return c; - } - - /** - * @deprecated - * @see #getEndColumn - */ - - public int getColumn() { - return bufcolumn[bufpos]; - } - - /** - * @deprecated - * @see #getEndLine - */ - - public int getLine() { - return bufline[bufpos]; - } - - /** Get token end column number. */ - public int getEndColumn() { - return bufcolumn[bufpos]; - } - - /** Get token end line number. */ - public int getEndLine() { - return bufline[bufpos]; - } - - /** Get token beginning column number. */ - public int getBeginColumn() { - return bufcolumn[tokenBegin]; - } - - /** Get token beginning line number. */ - public int getBeginLine() { - return bufline[tokenBegin]; - } - -/** Backup a number of characters. */ - public void backup(int amount) { - - inBuf += amount; - if ((bufpos -= amount) < 0) - bufpos += bufsize; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.Reader dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn, int buffersize) - { - inputStream = dstream; - line = startline; - column = startcolumn - 1; - - if (buffer == null || buffersize != buffer.length) - { - available = bufsize = buffersize; - buffer = new char[buffersize]; - bufline = new int[buffersize]; - bufcolumn = new int[buffersize]; - } - prevCharIsLF = prevCharIsCR = false; - tokenBegin = inBuf = maxNextCharInd = 0; - bufpos = -1; - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.Reader dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, int startline, - int startcolumn) - { - this(dstream, startline, startcolumn, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - this(dstream, encoding, 1, 1, 4096); - } - - /** Constructor. */ - public SimpleCharStream(java.io.InputStream dstream) - { - this(dstream, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException - { - ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn, int buffersize) - { - ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, 1, 1, 4096); - } - - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream) - { - ReInit(dstream, 1, 1, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, String encoding, int startline, - int startcolumn) throws java.io.UnsupportedEncodingException - { - ReInit(dstream, encoding, startline, startcolumn, 4096); - } - /** Reinitialise. */ - public void ReInit(java.io.InputStream dstream, int startline, - int startcolumn) - { - ReInit(dstream, startline, startcolumn, 4096); - } - /** Get token literal value. */ - public String GetImage() - { - if (bufpos >= tokenBegin) - return new String(buffer, tokenBegin, bufpos - tokenBegin + 1); - else - return new String(buffer, tokenBegin, bufsize - tokenBegin) + - new String(buffer, 0, bufpos + 1); - } - - /** Get the suffix. */ - public char[] GetSuffix(int len) - { - char[] ret = new char[len]; - - if ((bufpos + 1) >= len) - System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); - else - { - System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, - len - bufpos - 1); - System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); - } - - return ret; - } - - /** Reset buffer when finished. */ - public void Done() - { - buffer = null; - bufline = null; - bufcolumn = null; - } - - /** - * Method to adjust line and column numbers for the start of a token. - */ - public void adjustBeginLineColumn(int newLine, int newCol) - { - int start = tokenBegin; - int len; - - if (bufpos >= tokenBegin) - { - len = bufpos - tokenBegin + inBuf + 1; - } - else - { - len = bufsize - tokenBegin + bufpos + 1 + inBuf; - } - - int i = 0, j = 0, k = 0; - int nextColDiff = 0, columnDiff = 0; - - while (i < len && - bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) - { - bufline[j] = newLine; - nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; - bufcolumn[j] = newCol + columnDiff; - columnDiff = nextColDiff; - i++; - } - - if (i < len) - { - bufline[j] = newLine++; - bufcolumn[j] = newCol + columnDiff; - - while (i++ < len) - { - if (bufline[j = start % bufsize] != bufline[++start % bufsize]) - bufline[j] = newLine++; - else - bufline[j] = newLine; + return new String(buffer, tokenBegin, bufsize - tokenBegin) + + new String(buffer, 0, bufpos + 1); + } + + /** + * @param len length + * @return the suffix. + */ + public char[] GetSuffix(int len) { + char[] ret = new char[len]; + + if ((bufpos + 1) >= len) + System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); + else { + System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, + len - bufpos - 1); + System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1); } - } - line = bufline[j]; - column = bufcolumn[j]; - } + return ret; + } + + /** + * Reset buffer when finished. + */ + public void Done() { + buffer = null; + bufline = null; + bufcolumn = null; + } + + /** + * Method to adjust line and column numbers for the start of a token. + * @param newLine new line + * @param newCol new column + */ + public void adjustBeginLineColumn(int newLine, int newCol) { + int start = tokenBegin; + int len; + + if (bufpos >= tokenBegin) { + len = bufpos - tokenBegin + inBuf + 1; + } else { + len = bufsize - tokenBegin + bufpos + 1 + inBuf; + } + + int i = 0, j = 0, k = 0; + int nextColDiff = 0, columnDiff = 0; + + while (i < len && + bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) { + bufline[j] = newLine; + nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j]; + bufcolumn[j] = newCol + columnDiff; + columnDiff = nextColDiff; + i++; + } + + if (i < len) { + bufline[j] = newLine++; + bufcolumn[j] = newCol + columnDiff; + + while (i++ < len) { + if (bufline[j = start % bufsize] != bufline[++start % bufsize]) + bufline[j] = newLine++; + else + bufline[j] = newLine; + } + } + + line = bufline[j]; + column = bufcolumn[j]; + } } /* JavaCC - OriginalChecksum=07e88967db3720fcfc378bbb17e7f640 (do not edit this line) */ http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Token.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Token.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Token.java index 44204b8..9fcd6c3 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Token.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/Token.java @@ -60,6 +60,8 @@ public class Token { * interpreter. This attribute value is often different from the image. * Any subclass of Token that actually wants to return a non-null value can * override this method as appropriate. + * + * @return null */ public Object getValue() { return null; @@ -72,6 +74,8 @@ public class Token { /** * Constructs a new token for the specified Image. + * + * @param kind kind */ public Token(int kind) { @@ -80,6 +84,9 @@ public class Token { /** * Constructs a new token for the specified Image and Kind. + * + * @param kind kind + * @param image image */ public Token(int kind, String image) { @@ -88,7 +95,7 @@ public class Token { } /** - * Returns the image. + * @return the image. */ public String toString() { @@ -106,6 +113,11 @@ public class Token { * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use sit in your lexical actions. + * + * @param ofKind ofKind + * @param image image + * + * @return new token */ public static Token newToken(int ofKind, String image) { http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/TokenMgrError.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/TokenMgrError.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/TokenMgrError.java index 8982dce..f57edd6 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/TokenMgrError.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/parser/TokenMgrError.java @@ -39,9 +39,12 @@ public class TokenMgrError extends Error /** * Replaces unprintable characters by their escaped (or unicode escaped) * equivalents in the given string + * + * @param str string + * @return escaped string */ protected static final String addEscapes(String str) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) @@ -75,27 +78,26 @@ public class TokenMgrError extends Error default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } - continue; } } return retval.toString(); } /** - * Returns a detailed message for the Error when it is thrown by the - * token manager to indicate a lexical error. - * Parameters : - * EOFSeen : indicates if EOF caused the lexical error - * curLexState : lexical state in which this error occurred - * errorLine : line number when the error occurred - * errorColumn : column number when the error occurred - * errorAfter : prefix that was seen before this error occurred - * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. + * + * @param EOFSeen : indicates if EOF caused the lexical error + * @param lexState : lexical state in which this error occurred + * @param errorLine : line number when the error occurred + * @param errorColumn : column number when the error occurred + * @param errorAfter : prefix that was seen before this error occurred + * @param curChar : the offending character + * + * @return a detailed message for the Error when it is thrown by the token manager to indicate a lexical error. */ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { return("Lexical error at line " + @@ -113,6 +115,8 @@ public class TokenMgrError extends Error * "Internal Error : Please file a bug report .... " * * from this method for such cases in the release version of your parser. + * + * @return the message */ public String getMessage() { return super.getMessage(); @@ -126,13 +130,28 @@ public class TokenMgrError extends Error public TokenMgrError() { } - /** Constructor with message and reason. */ + /** + * Constructor with message and reason. + * + * @param message the error message + * @param reason the reason + */ public TokenMgrError(String message, int reason) { super(message); errorCode = reason; } - /** Full Constructor. */ + /** + * Full Constructor. + * + * @param EOFSeen indicates if EOF caused the lexical error + * @param lexState lexical state in which this error occurred + * @param errorLine line number when the error occurred + * @param errorColumn column number when the error occurred + * @param errorAfter prefix that was seen before this error occurred + * @param curChar the offending character + * @param reason the reason + */ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); } http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/util/ReflectionUtil.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/util/ReflectionUtil.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/util/ReflectionUtil.java index 611d2ec..f819c61 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/util/ReflectionUtil.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/el/util/ReflectionUtil.java @@ -47,9 +47,6 @@ public class ReflectionUtil { byte.class, char.class, double.class, float.class, int.class, long.class, short.class, Void.TYPE }; - /** - * - */ private ReflectionUtil() { super(); } @@ -83,9 +80,9 @@ public class ReflectionUtil { /** * Converts an array of Class names to Class types - * @param s - * @return - * @throws ClassNotFoundException + * @param s array of class names + * @return array of class types + * @throws ClassNotFoundException if class was not found */ public static Class[] toTypeArray(String[] s) throws ClassNotFoundException { if (s == null) @@ -99,8 +96,8 @@ public class ReflectionUtil { /** * Converts an array of Class types to Class names - * @param c - * @return + * @param c array of class types + * @return array of class names */ public static String[] toTypeNameArray(Class[] c) { if (c == null) @@ -118,7 +115,7 @@ public class ReflectionUtil { * @param property the name of the method * @param paramTypes the parameter types to use * @return the method specified - * @throws MethodNotFoundException + * @throws MethodNotFoundException if method was not found */ public static Method getMethod(Object base, Object property, Class[] paramTypes) throws MethodNotFoundException { @@ -157,11 +154,11 @@ public class ReflectionUtil { } /** - * @param base - * @param property - * @return - * @throws ELException - * @throws PropertyNotFoundException + * @param base object + * @param property property + * @return property descriptor + * @throws ELException in case of EL errors + * @throws PropertyNotFoundException if property was not found */ public static PropertyDescriptor getPropertyDescriptor(Object base, Object property) throws ELException, PropertyNotFoundException { http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java index 43f4242..f8c2a5f 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/EmbeddedServletOptions.java @@ -362,7 +362,7 @@ public final class EmbeddedServletOptions implements Options { } /** - * Should we include a source fragment in exception messages, which could be displayed + * @return Should we include a source fragment in exception messages, which could be displayed * to the developer ? */ public boolean getDisplaySourceFragment() { @@ -371,7 +371,10 @@ public final class EmbeddedServletOptions implements Options { /** * Create an EmbeddedServletOptions object using data available from - * ServletConfig and ServletContext. + * ServletConfig and ServletContext. + * + * @param config servlet config + * @param context servlet context */ public EmbeddedServletOptions(ServletConfig config, ServletContext context) { http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JasperException.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JasperException.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JasperException.java index a9a73c4..691b6fd 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JasperException.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JasperException.java @@ -19,7 +19,7 @@ package org.apache.struts2.jasper; /** * Base class for all exceptions generated by the JSP engine. Makes it - * convienient to catch just this at the top-level. + * convenient to catch just this at the top-level. * * @author Anil K. Vijendran */ @@ -32,6 +32,9 @@ public class JasperException extends javax.servlet.ServletException { /** * Creates a JasperException with the embedded exception and the reason for * throwing a JasperException + * + * @param reason the reason + * @param exception the exception */ public JasperException (String reason, Throwable exception) { super(reason, exception); @@ -39,6 +42,8 @@ public class JasperException extends javax.servlet.ServletException { /** * Creates a JasperException with the embedded exception + * + * @param exception the exception */ public JasperException (Throwable exception) { super(exception); http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspC.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspC.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspC.java index 2ac1388..d9716b1 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspC.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspC.java @@ -424,21 +424,21 @@ public class JspC implements Options { return classDebugInfo; } - /** + /* * @see Options#isCaching() */ public boolean isCaching() { return caching; } - /** + /* * @see Options#isCaching() */ public void setCaching(boolean caching) { this.caching = caching; } - /** + /* * @see Options#getCache() */ public Map getCache() { @@ -446,35 +446,35 @@ public class JspC implements Options { } /** - * Background compilation check intervals in seconds + * @return Background compilation check intervals in seconds */ public int getCheckInterval() { return 0; } /** - * Modification test interval. + * @return Modification test interval. */ public int getModificationTestInterval() { return 0; } /** - * Is Jasper being used in development mode? + * @return Is Jasper being used in development mode? */ public boolean getDevelopment() { return false; } /** - * Is the generation of SMAP info for JSR45 debuggin suppressed? + * @return Is the generation of SMAP info for JSR45 debuggin suppressed? */ public boolean isSmapSuppressed() { return smapSuppressed; } /** - * Set smapSuppressed flag. + * @param smapSuppressed Set smapSuppressed flag. */ public void setSmapSuppressed(boolean smapSuppressed) { this.smapSuppressed = smapSuppressed; @@ -482,14 +482,14 @@ public class JspC implements Options { /** - * Should SMAP info for JSR45 debugging be dumped to a file? + * @return Should SMAP info for JSR45 debugging be dumped to a file? */ public boolean isSmapDumped() { return smapDumped; } /** - * Set smapSuppressed flag. + * @param smapDumped Set smapDumped flag. */ public void setSmapDumped(boolean smapDumped) { this.smapDumped = smapDumped; @@ -519,7 +519,7 @@ public class JspC implements Options { /** * Sets the class-id value to be sent to Internet Explorer when using - * <jsp:plugin> tags. + * <jsp:plugin> tags. * * @param ieClassId Class-id value */ @@ -529,7 +529,7 @@ public class JspC implements Options { /** * Gets the class-id value that is sent to Internet Explorer when using - * <jsp:plugin> tags. + * <jsp:plugin> tags. * * @return Class-id value */ @@ -552,7 +552,7 @@ public class JspC implements Options { } /** - * Compiler to use. + * @return Compiler to use. */ public String getCompiler() { return compiler; @@ -563,13 +563,13 @@ public class JspC implements Options { } /** - * Compiler class name to use. + * @return Compiler class name to use. */ public String getCompilerClassName() { return null; } - /** + /* * @see Options#getCompilerTargetVM */ public String getCompilerTargetVM() { @@ -580,14 +580,14 @@ public class JspC implements Options { compilerTargetVM = vm; } - /** + /* * @see Options#getCompilerSourceVM() */ public String getCompilerSourceVM() { return compilerSourceVM; } - /** + /* * @see Options#getCompilerSourceVM() */ public void setCompilerSourceVM(String vm) { @@ -716,7 +716,7 @@ public class JspC implements Options { } /** - * Class name of the generated file ( without package ). + * @param p Class name of the generated file ( without package ). * Can only be used if a single file is converted. * XXX Do we need this feature ? */ @@ -729,7 +729,7 @@ public class JspC implements Options { } /** - * Set the option that throws an exception in case of a compilation error. + * @param b Set the option that throws an exception in case of a compilation error. */ public void setFailOnError(final boolean b) { failOnError = b; @@ -740,7 +740,7 @@ public class JspC implements Options { } /** - * Obtain JSP configuration informantion specified in web.xml. + * @return Obtain JSP configuration information specified in web.xml. */ public JspConfig getJspConfig() { return jspConfig; @@ -787,6 +787,8 @@ public class JspC implements Options { /** * Include the generated web.xml inside the webapp's web.xml. + * + * @throws IOException in case of IO errors */ protected void mergeIntoWebXml() throws IOException { @@ -989,9 +991,12 @@ public class JspC implements Options { /** * Locate all jsp files in the webapp. Used if no explicit * jsps are specified. + * + * @param base base + * @throws JasperException in case of Jasper errors */ public void scanFiles( File base ) throws JasperException { - Stack<String> dirs = new Stack<String>(); + Stack<String> dirs = new Stack<>(); dirs.push(base.toString()); // Make sure default extensions are always included @@ -1178,6 +1183,8 @@ public class JspC implements Options { * Find the WEB-INF dir by looking up in the directory tree. * This is used if no explicit docbase is set, but only files. * XXX Maybe we should require the docbase. + * + * @param f start file for lookup */ protected void locateUriRoot( File f ) { String tUriBase = uriBase; http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java index 3d88718..976d3e3 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/JspCompilationContext.java @@ -125,7 +125,7 @@ public class JspCompilationContext { } this.rctxt = rctxt; - this.tagFileJarUrls = new HashMap<String, URL>(); + this.tagFileJarUrls = new HashMap<>(); this.basePackageName = Constants.JSP_PACKAGE_NAME; this.classLoaderInterface = classLoaderInterface; } @@ -151,7 +151,7 @@ public class JspCompilationContext { /** ---------- Class path and loader ---------- */ /** - * The classpath that is passed off to the Java compiler. + * @return The classpath that is passed off to the Java compiler. */ public String getClassPath() { if( classPath != null ) @@ -160,14 +160,14 @@ public class JspCompilationContext { } /** - * The classpath that is passed off to the Java compiler. + * @param classPath The classpath that is passed off to the Java compiler. */ public void setClassPath(String classPath) { this.classPath = classPath; } /** - * What class loader to use for loading classes while compiling + * @return What class loader to use for loading classes while compiling * this JSP? */ public ClassLoader getClassLoader() { @@ -194,7 +194,7 @@ public class JspCompilationContext { /** ---------- Input/Output ---------- */ /** - * The output directory to generate code into. The output directory + * @return The output directory to generate code into. The output directory * is make up of the scratch directory, which is provide in Options, * plus the directory derived from the package name. */ @@ -207,9 +207,11 @@ public class JspCompilationContext { } /** - * Create a "Compiler" object based on some init param data. This + * @return Create a "Compiler" object based on some init param data. This * is not done yet. Right now we're just hardcoding the actual - * compilers that are created. + * compilers that are created. + * + * @throws JasperException in case of Jasper errors */ public Compiler createCompiler() throws JasperException { jspCompiler = new CustomCompiler(); @@ -246,6 +248,9 @@ public class JspCompilationContext { /** * Get the full value of a URI relative to this compilations context * uses current file as the base. + * + * @param uri the URL + * @return full URL */ public String resolveRelativeUri(String uri) { // sometimes we get uri's massaged from File(String), so check for @@ -260,6 +265,8 @@ public class JspCompilationContext { /** * Gets a resource as a stream, relative to the meanings of this * context's implementation. + * + * @param res resource * @return a null if the resource cannot be found or represented * as an InputStream. */ @@ -282,8 +289,10 @@ public class JspCompilationContext { return context.getResourcePaths(canonicalURI(path)); } - /** - * Gets the actual path of a URI relative to the context of + /** + * @param path the path + * + * @return the actual path of a URI relative to the context of * the compilation. */ public String getRealPath(String path) { @@ -294,11 +303,11 @@ public class JspCompilationContext { } /** - * Returns the tag-file-name-to-JAR-file map of this compilation unit, + * @return the tag-file-name-to-JAR-file map of this compilation unit, * which maps tag file names to the JAR files in which the tag files are * packaged. * - * The map is populated when parsing the tag-file elements of the TLDs + * @param tagFile The map is populated when parsing the tag-file elements of the TLDs * of any imported taglibs. */ public URL getTagFileJarUrl(String tagFile) { @@ -310,7 +319,7 @@ public class JspCompilationContext { } /** - * Returns the JAR file in which the tag file for which this + * @return the JAR file in which the tag file for which this * JspCompilationContext was created is packaged, or null if this * JspCompilationContext does not correspond to a tag file, or if the * corresponding tag file is not packaged in a JAR. @@ -322,7 +331,7 @@ public class JspCompilationContext { /* ==================== Common implementation ==================== */ /** - * Just the class name (does not include package name) of the + * @return Just the class name (does not include package name) of the * generated class. */ public String getServletClassName() { @@ -349,7 +358,7 @@ public class JspCompilationContext { } /** - * Path of the JSP URI. Note that this is not a file name. This is + * @return Path of the JSP URI. Note that this is not a file name. This is * the context rooted URI of the JSP file. */ public String getJspFile() { @@ -357,7 +366,7 @@ public class JspCompilationContext { } /** - * Are we processing something that has been declared as an + * @return Are we processing something that has been declared as an * errorpage? */ public boolean isErrorPage() { @@ -381,7 +390,7 @@ public class JspCompilationContext { } /** - * True if we are compiling a tag file in prototype mode. + * @return True if we are compiling a tag file in prototype mode. * ie we only generate codes with class for the tag handler with empty * method bodies. */ @@ -394,7 +403,7 @@ public class JspCompilationContext { } /** - * Package name for the generated class is make up of the base package + * @return Package name for the generated class is make up of the base package * name, which is user settable, and the derived package name. The * derived package name directly mirrors the file heirachy of the JSP page. */ @@ -426,14 +435,14 @@ public class JspCompilationContext { } /** - * The package name into which the servlet class is generated. + * @param servletPackageName The package name into which the servlet class is generated. */ public void setServletPackageName(String servletPackageName) { this.basePackageName = servletPackageName; } /** - * Full path name of the Java file into which the servlet is being + * @return Full path name of the Java file into which the servlet is being * generated. */ public String getServletJavaFileName() { @@ -444,7 +453,7 @@ public class JspCompilationContext { } /** - * Get hold of the Options object for this context. + * @return Get hold of the Options object for this context. */ public Options getOptions() { return options; @@ -459,7 +468,7 @@ public class JspCompilationContext { } /** - * Path of the Java file relative to the work directory. + * @return Path of the Java file relative to the work directory. */ public String getJavaPath() { @@ -485,7 +494,7 @@ public class JspCompilationContext { } /** - * Get the content type of this JSP. + * @return Get the content type of this JSP. * * Content type includes content type and encoding. */ @@ -498,7 +507,7 @@ public class JspCompilationContext { } /** - * Where is the servlet being generated? + * @return Where is the servlet being generated? */ public ServletWriter getWriter() { return writer; @@ -510,12 +519,16 @@ public class JspCompilationContext { /** * Gets the 'location' of the TLD associated with the given taglib 'uri'. - * + * + * @param uri the URL + * * @return An array of two Strings: The first element denotes the real * path to the TLD. If the path to the TLD points to a jar file, then the * second element denotes the name of the TLD entry in the jar file. * Returns null if the given uri is not associated with any tag library * 'exposed' in the web application. + * + * @throws JasperException in case of Jasper errors */ public String[] getTldLocation(String uri) throws JasperException { String[] location = @@ -524,7 +537,7 @@ public class JspCompilationContext { } /** - * Are we keeping generated code around? + * @return Are we keeping generated code around? */ public boolean keepGenerated() { return getOptions().getKeepGenerated(); http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java index e822b47..68d5d4f 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/Options.java @@ -34,98 +34,98 @@ import org.apache.struts2.jasper.compiler.TldLocationsCache; public interface Options { /** - * Returns true if Jasper issues a compilation error instead of a runtime + * @return true if Jasper issues a compilation error instead of a runtime * Instantiation error if the class attribute specified in useBean action * is invalid. */ public boolean getErrorOnUseBeanInvalidClassAttribute(); /** - * Are we keeping generated code around? + * @return Are we keeping generated code around? */ public boolean getKeepGenerated(); /** - * Returns true if tag handler pooling is enabled, false otherwise. + * @return true if tag handler pooling is enabled, false otherwise. */ public boolean isPoolingEnabled(); /** - * Are we supporting HTML mapped servlets? + * @return Are we supporting HTML mapped servlets? */ public boolean getMappedFile(); /** - * Should we include debug information in compiled class? + * @return Should we include debug information in compiled class? */ public boolean getClassDebugInfo(); /** - * Background compile thread check interval in seconds + * @return Background compile thread check interval in seconds */ public int getCheckInterval(); /** - * Is Jasper being used in development mode? + * @return Is Jasper being used in development mode? */ public boolean getDevelopment(); /** - * Should we include a source fragment in exception messages, which could be displayed + * @return Should we include a source fragment in exception messages, which could be displayed * to the developer ? */ public boolean getDisplaySourceFragment(); /** - * Is the generation of SMAP info for JSR45 debugging suppressed? + * @return Is the generation of SMAP info for JSR45 debugging suppressed? */ public boolean isSmapSuppressed(); /** - * Indicates whether SMAP info for JSR45 debugging should be dumped to a + * @return Indicates whether SMAP info for JSR45 debugging should be dumped to a * file. * Ignored is suppressSmap() is true */ public boolean isSmapDumped(); /** - * Should white spaces between directives or actions be trimmed? + * @return Should white spaces between directives or actions be trimmed? */ public boolean getTrimSpaces(); /** - * Class ID for use in the plugin tag when the browser is IE. + * @return Class ID for use in the plugin tag when the browser is IE. */ public String getIeClassId(); /** - * What is my scratch dir? + * @return What is my scratch dir? */ public File getScratchDir(); /** - * What classpath should I use while compiling the servlets + * @return What classpath should I use while compiling the servlets * generated from JSP files? */ public String getClassPath(); /** - * Compiler to use. + * @return Compiler to use. */ public String getCompiler(); /** - * The compiler target VM, e.g. 1.1, 1.2, 1.3, 1.4, or 1.5. + * @return The compiler target VM, e.g. 1.1, 1.2, 1.3, 1.4, or 1.5. */ public String getCompilerTargetVM(); /** - * Compiler source VM, e.g. 1.3, 1.4, or 1.5. + * @return Compiler source VM, e.g. 1.3, 1.4, or 1.5. */ public String getCompilerSourceVM(); /** - * Java compiler class to use. + * @return Java compiler class to use. */ public String getCompilerClassName(); @@ -143,43 +143,43 @@ public interface Options { public TldLocationsCache getTldLocationsCache(); /** - * Java platform encoding to generate the JSP + * @return Java platform encoding to generate the JSP * page servlet. */ public String getJavaEncoding(); /** - * boolean flag to tell Ant whether to fork JSP page compilations. + * @return boolean flag to tell Ant whether to fork JSP page compilations. */ public boolean getFork(); /** - * Obtain JSP configuration informantion specified in web.xml. + * @return Obtain JSP configuration information specified in web.xml. */ public JspConfig getJspConfig(); /** - * Is generation of X-Powered-By response header enabled/disabled? + * @return Is generation of X-Powered-By response header enabled/disabled? */ public boolean isXpoweredBy(); /** - * Obtain a Tag Plugin Manager + * @return Obtain a Tag Plugin Manager */ public TagPluginManager getTagPluginManager(); /** - * Are Text strings to be generated as char arrays? + * @return Are Text strings to be generated as char arrays? */ public boolean genStringAsCharArray(); /** - * Modification test interval. + * @return Modification test interval. */ public int getModificationTestInterval(); /** - * Is caching enabled (used for precompilation). + * @return Is caching enabled (used for precompilation). */ public boolean isCaching(); http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java index 67f97a0..6179e9b 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/BeanRepository.java @@ -35,11 +35,14 @@ public class BeanRepository { /** * Constructor. + * + * @param loader class loader + * @param err the error dispatcher */ public BeanRepository(ClassLoader loader, ErrorDispatcher err) { this.loader = loader; this.errDispatcher = err; - beanTypes = new HashMap<String, String>(); + beanTypes = new HashMap<>(); } public void addBean(Node.UseBean n, String s, String type, String scope) http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java index fcd39b9..6e91dc2 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/Compiler.java @@ -76,6 +76,8 @@ public abstract class Compiler { * return null. Used in development mode for generating detailed error * messages. http://issues.apache.org/bugzilla/show_bug.cgi?id=37062. * </p> + * + * @return page nodes */ public Node.Nodes getPageNodes() { return this.pageNodes; @@ -86,6 +88,7 @@ public abstract class Compiler { * * @return a smap for the current JSP page, if one is generated, null * otherwise + * @throws Exception in case of any errors */ protected String[] generateJava() throws Exception { @@ -284,12 +287,20 @@ public abstract class Compiler { /** * Compile the servlet from .java file to .class file + * + * @param smap string array + * @throws FileNotFoundException is file was not found + * @throws JasperException in case of jasper errors + * @throws Exception in case of other errors */ protected abstract void generateClass(String[] smap) throws FileNotFoundException, JasperException, Exception; /** * Compile the jsp file from the current engine context + * @throws FileNotFoundException is file was not found + * @throws JasperException in case of jasper errors + * @throws Exception in case of other errors */ public void compile() throws FileNotFoundException, JasperException, Exception { @@ -303,6 +314,9 @@ public abstract class Compiler { * @param compileClass * If true, generate both .java and .class file If false, * generate only .java file + * @throws FileNotFoundException is file was not found + * @throws JasperException in case of jasper errors + * @throws Exception in case of other errors */ public void compile(boolean compileClass) throws FileNotFoundException, JasperException, Exception { @@ -318,6 +332,9 @@ public abstract class Compiler { * generate only .java file * @param jspcMode * true if invoked from JspC, false otherwise + * @throws FileNotFoundException is file was not found + * @throws JasperException in case of jasper errors + * @throws Exception in case of other errors */ public void compile(boolean compileClass, boolean jspcMode) throws FileNotFoundException, JasperException, Exception { @@ -369,6 +386,8 @@ public abstract class Compiler { /** * This is a protected method intended to be overridden by subclasses of * Compiler. This is used by the compile method to do all the compilation. + * + * @return true if out dated */ public boolean isOutDated() { return isOutDated(true); @@ -377,12 +396,14 @@ public abstract class Compiler { /** * Determine if a compilation is necessary by checking the time stamp of the * JSP page with that of the corresponding .class or .java file. If the page - * has dependencies, the check is also extended to its dependeants, and so - * on. This method can by overidden by a subclasses of Compiler. + * has dependencies, the check is also extended to its dependants, and so + * on. This method can by overridden by a subclasses of Compiler. * * @param checkClass * If true, check against .class file, if false, check against * .java file. + * + * @return true if out dated */ public boolean isOutDated(boolean checkClass) { @@ -455,9 +476,8 @@ public abstract class Compiler { return false; } - Iterator it = depends.iterator(); - while (it.hasNext()) { - String include = (String) it.next(); + for (Object depend : depends) { + String include = (String) depend; try { URL includeUrl = ctxt.getResource(include); if (includeUrl == null) { @@ -468,7 +488,7 @@ public abstract class Compiler { long includeLastModified = 0; if (iuc instanceof JarURLConnection) { includeLastModified = - ((JarURLConnection) iuc).getJarEntry().getTime(); + ((JarURLConnection) iuc).getJarEntry().getTime(); } else { includeLastModified = iuc.getLastModified(); } @@ -487,14 +507,14 @@ public abstract class Compiler { } /** - * Gets the error dispatcher. + * @return the error dispatcher. */ public ErrorDispatcher getErrorDispatcher() { return errDispatcher; } /** - * Gets the info about the page under compilation + * @return the info about the page under compilation */ public PageInfo getPageInfo() { return pageInfo; http://git-wip-us.apache.org/repos/asf/struts/blob/775c82a7/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java ---------------------------------------------------------------------- diff --git a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java index 32fec66..f3fac02 100644 --- a/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java +++ b/plugins/embeddedjsp/src/main/java/org/apache/struts2/jasper/compiler/ELFunctionMapper.java @@ -40,6 +40,8 @@ public class ELFunctionMapper { * * @param compiler Current compiler, mainly for accessing error dispatcher. * @param page The current compilation unit. + * + * @throws JasperException in case of Jasper errors */ public static void map(Compiler compiler, Node.Nodes page) throws JasperException {