This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.1.x by this push: new 51be28b1c8 Code clean-up - no functional change 51be28b1c8 is described below commit 51be28b1c8a9732205579091a6ce0623910c1a7b Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Sep 25 20:25:51 2024 +0100 Code clean-up - no functional change --- java/org/apache/el/parser/AstLambdaExpression.java | 4 +- java/org/apache/el/parser/JJTELParserState.java | 45 ++++---- java/org/apache/el/parser/Node.java | 26 +++-- java/org/apache/el/parser/ParseException.java | 123 +++++++++------------ java/org/apache/el/parser/SimpleCharStream.java | 38 ++++--- java/org/apache/el/parser/SimpleNode.java | 7 +- java/org/apache/el/parser/Token.java | 65 +++++------ java/org/apache/el/parser/TokenMgrError.java | 107 ++++++++---------- 8 files changed, 193 insertions(+), 222 deletions(-) diff --git a/java/org/apache/el/parser/AstLambdaExpression.java b/java/org/apache/el/parser/AstLambdaExpression.java index 152dab9d29..079ce6a2d6 100644 --- a/java/org/apache/el/parser/AstLambdaExpression.java +++ b/java/org/apache/el/parser/AstLambdaExpression.java @@ -100,8 +100,8 @@ public class AstLambdaExpression extends SimpleNode { methodParameterIndex++; while (result instanceof LambdaExpression && methodParameterIndex < jjtGetNumChildren()) { - result = ((LambdaExpression) result).invoke( - ((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); + result = ((LambdaExpression) result) + .invoke(((AstMethodParameters) children[methodParameterIndex]).getParameters(ctx)); methodParameterIndex++; } diff --git a/java/org/apache/el/parser/JJTELParserState.java b/java/org/apache/el/parser/JJTELParserState.java index 4315ef769b..7dc18ded58 100644 --- a/java/org/apache/el/parser/JJTELParserState.java +++ b/java/org/apache/el/parser/JJTELParserState.java @@ -23,16 +23,18 @@ public class JJTELParserState { } - /* Determines whether the current node was actually closed and - pushed. This should only be called in the final user action of a - node scope. */ + /* + * Determines whether the current node was actually closed and pushed. This should only be called in the final user + * action of a node scope. + */ public boolean nodeCreated() { return node_created; } - /* Call this to reinitialize the node stack. It is called - automatically by the parser's ReInit() method. */ + /* + * Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. + */ public void reset() { nodes.clear(); marks.clear(); @@ -41,8 +43,9 @@ public class JJTELParserState { } - /* Returns the root node of the AST. It only makes sense to call - this after a successful parse. */ + /* + * Returns the root node of the AST. It only makes sense to call this after a successful parse. + */ public Node rootNode() { return nodes.get(0); } @@ -55,8 +58,9 @@ public class JJTELParserState { } - /* Returns the node on the top of the stack, and remove it from the - stack. */ + /* + * Returns the node on the top of the stack, and remove it from the stack. + */ public Node popNode() { if (--sp < mk) { mk = marks.remove(marks.size() - 1); @@ -71,8 +75,9 @@ public class JJTELParserState { } - /* Returns the number of children on the stack in the current node - scope. */ + /* + * Returns the number of children on the stack in the current node scope. + */ public int nodeArity() { return sp - mk; } @@ -93,10 +98,10 @@ public class JJTELParserState { } - /* A definite node is constructed from a specified number of - children. That number of nodes are popped from the stack and - made the children of the definite node. Then the definite node - is pushed on to the stack. */ + /* + * A definite node is constructed from a specified number of children. That number of nodes are popped from the + * stack and made the children of the definite node. Then the definite node is pushed on to the stack. + */ public void closeNodeScope(Node n, int num) { mk = marks.remove(marks.size() - 1); while (num-- > 0) { @@ -110,11 +115,11 @@ public class JJTELParserState { } - /* A conditional node is constructed if its condition is true. All - the nodes that have been pushed since the node was opened are - made children of the conditional node, which is then pushed - on to the stack. If the condition is false the node is not - constructed and they are left on the stack. */ + /* + * A conditional node is constructed if its condition is true. All the nodes that have been pushed since the node + * was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is + * false the node is not constructed and they are left on the stack. + */ public void closeNodeScope(Node n, boolean condition) { if (condition) { int a = nodeArity(); diff --git a/java/org/apache/el/parser/Node.java b/java/org/apache/el/parser/Node.java index a98d501200..5e5c090ba1 100644 --- a/java/org/apache/el/parser/Node.java +++ b/java/org/apache/el/parser/Node.java @@ -35,31 +35,37 @@ import org.apache.el.lang.EvaluationContext; @SuppressWarnings("all") // Ignore warnings in generated code 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. */ + /** + * This method is called after the node has been made the current node. It indicates that child nodes can now be + * added to it. + */ void jjtOpen(); - /** This method is called after all the child nodes have been - added. */ + /** + * This method is called after all the child nodes have been added. + */ void jjtClose(); - /** This pair of methods are used to inform the node of its - parent. */ + /** + * This pair of methods are used to inform the node of its parent. + */ void jjtSetParent(Node n); Node jjtGetParent(); - /** This method tells the node to add its argument to the node's - list of children. */ + /** + * This method tells the node to add its argument to the node's list of children. + */ void jjtAddChild(Node n, int i); - /** This method returns a child node. The children are numbered - from zero, left to right. */ + /** + * This method returns a child node. The children are numbered from zero, left to right. + */ Node jjtGetChild(int i); diff --git a/java/org/apache/el/parser/ParseException.java b/java/org/apache/el/parser/ParseException.java index 48fae12a32..7c7e36a8d6 100644 --- a/java/org/apache/el/parser/ParseException.java +++ b/java/org/apache/el/parser/ParseException.java @@ -3,21 +3,16 @@ package org.apache.el.parser; /** - * This exception is thrown when parse errors are encountered. - * You can explicitly create objects of this exception type by - * calling the method generateParseException in the generated - * parser. - * - * You can modify this class to customize your error reporting - * mechanisms so long as you retain the public fields. + * This exception is thrown when parse errors are encountered. You can explicitly create objects of this exception type + * by calling the method generateParseException in the generated parser. You can modify this class to customize your + * error reporting mechanisms so long as you retain the public fields. */ @SuppressWarnings("all") // Ignore warnings in generated code public class ParseException extends Exception { /** - * The version identifier for this Serializable class. - * Increment only if the <i>serialized</i> form of the - * class changes. + * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class + * changes. */ private static final long serialVersionUID = 1L; @@ -28,10 +23,9 @@ public class ParseException extends Exception { /** - * This constructor is used by the method "generateParseException" - * in the generated parser. Calling this constructor generates - * a new object of this type with the fields "currentToken", - * "expectedTokenSequences", and "tokenImage" set. + * This constructor is used by the method "generateParseException" in the generated parser. Calling this constructor + * generates a new object of this type with the fields "currentToken", "expectedTokenSequences", and "tokenImage" + * set. */ public ParseException(Token currentTokenVal, int[][] expectedTokenSequencesVal, String[] tokenImageVal) { super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal)); @@ -42,13 +36,10 @@ public class ParseException extends Exception { /** - * The following constructors are for use by you for whatever - * purpose you can think of. Constructing the exception in this - * manner makes the exception behave in the normal way - i.e., as - * documented in the class "Throwable". The fields "errorToken", - * "expectedTokenSequences", and "tokenImage" do not contain - * relevant information. The JavaCC generated code does not use - * these constructors. + * The following constructors are for use by you for whatever purpose you can think of. Constructing the exception + * in this manner makes the exception behave in the normal way - i.e., as documented in the class "Throwable". The + * fields "errorToken", "expectedTokenSequences", and "tokenImage" do not contain relevant information. The JavaCC + * generated code does not use these constructors. */ public ParseException() { @@ -63,33 +54,28 @@ 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 - * following this token will (therefore) be the first error token. + * This is the last token that has been consumed successfully. If this object has been created due to a parse error, + * the token following this token will (therefore) be the first error token. */ public Token currentToken; /** - * Each entry in this array is an array of integers. Each array - * of integers represents a sequence of tokens (by their ordinal - * values) that is expected at this point of the parse. + * Each entry in this array is an array of integers. Each array of integers represents a sequence of tokens (by + * their ordinal values) that is expected at this point of the parse. */ public int[][] expectedTokenSequences; /** - * This is a reference to the "tokenImage" array of the generated - * parser within which the parse error occurred. This array is - * defined in the generated ...Constants interface. + * This is a reference to the "tokenImage" array of the generated parser within which the parse error occurred. This + * array is defined in the generated ...Constants interface. */ public String[] tokenImage; /** - * It uses "currentToken" and "expectedTokenSequences" to generate a parse - * error message and returns it. If this object has been created - * due to a parse error, and you do not catch it (it gets thrown - * from the parser) the correct error message - * gets displayed. + * It uses "currentToken" and "expectedTokenSequences" to generate a parse error message and returns it. If this + * object has been created due to a parse error, and you do not catch it (it gets thrown from the parser) the + * correct error message gets displayed. */ private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) { @@ -144,8 +130,7 @@ 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 + * Used to convert raw characters to their escaped version when these raw version cannot be used as part of an ASCII * string literal. */ static String add_escapes(String str) { @@ -153,38 +138,38 @@ public class ParseException extends Exception { char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4)); - } else { - retval.append(ch); - } - continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4)); + } else { + retval.append(ch); + } + continue; } } return retval.toString(); diff --git a/java/org/apache/el/parser/SimpleCharStream.java b/java/org/apache/el/parser/SimpleCharStream.java index a2488df20c..03d570e7db 100644 --- a/java/org/apache/el/parser/SimpleCharStream.java +++ b/java/org/apache/el/parser/SimpleCharStream.java @@ -3,8 +3,8 @@ package org.apache.el.parser; /** - * An implementation of interface CharStream, where the stream is assumed to - * contain only ASCII characters (without unicode processing). + * An implementation of interface CharStream, where the stream is assumed to contain only ASCII characters (without + * unicode processing). */ @SuppressWarnings("all") // Ignore warnings in generated code @@ -165,18 +165,18 @@ public class SimpleCharStream { } switch (c) { - case '\r': - prevCharIsCR = true; - break; - case '\n': - prevCharIsLF = true; - break; - case '\t': - column--; - column += (tabSize - (column % tabSize)); - break; - default: - break; + case '\r': + prevCharIsCR = true; + break; + case '\n': + prevCharIsLF = true; + break; + case '\t': + column--; + column += (tabSize - (column % tabSize)); + break; + default: + break; } bufline[bufpos] = line; @@ -210,6 +210,7 @@ public class SimpleCharStream { @Deprecated /** * @deprecated + * * @see #getEndColumn */ @@ -221,6 +222,7 @@ public class SimpleCharStream { @Deprecated /** * @deprecated + * * @see #getEndLine */ @@ -321,8 +323,8 @@ public class SimpleCharStream { /** 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); + this(encoding == null ? new java.io.InputStreamReader(dstream) : + new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } @@ -360,8 +362,8 @@ public class SimpleCharStream { /** 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); + ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : + new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize); } diff --git a/java/org/apache/el/parser/SimpleNode.java b/java/org/apache/el/parser/SimpleNode.java index 0fd414e55a..f5e3e28745 100644 --- a/java/org/apache/el/parser/SimpleNode.java +++ b/java/org/apache/el/parser/SimpleNode.java @@ -101,10 +101,9 @@ public abstract class SimpleNode implements Node { } /* - * You can override these two methods in subclasses of SimpleNode to - * customize the way the node appears when the tree is dumped. If your - * output uses more than one line you should override toString(String), - * otherwise overriding toString() is probably all you need to do. + * You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the + * tree is dumped. If your output uses more than one line you should override toString(String), otherwise overriding + * toString() is probably all you need to do. */ diff --git a/java/org/apache/el/parser/Token.java b/java/org/apache/el/parser/Token.java index e05a681ee3..f9a525aa53 100644 --- a/java/org/apache/el/parser/Token.java +++ b/java/org/apache/el/parser/Token.java @@ -10,16 +10,14 @@ package org.apache.el.parser; public class Token implements java.io.Serializable { /** - * The version identifier for this Serializable class. - * Increment only if the <i>serialized</i> form of the - * class changes. + * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class + * changes. */ private static final long serialVersionUID = 1L; /** - * An integer that describes the kind of this token. This numbering - * system is determined by JavaCCParser, and a table of these numbers is - * stored in the file ...Constants.java. + * An integer that describes the kind of this token. This numbering system is determined by JavaCCParser, and a + * table of these numbers is stored in the file ...Constants.java. */ public int kind; @@ -41,37 +39,29 @@ public class Token implements java.io.Serializable { public String image; /** - * A reference to the next regular (non-special) token from the input - * stream. If this is the last token from the input stream, or if the - * token manager has not read tokens beyond this one, this field is - * set to null. This is true only if this token is also a regular - * token. Otherwise, see below for a description of the contents of - * this field. + * A reference to the next regular (non-special) token from the input stream. If this is the last token from the + * input stream, or if the token manager has not read tokens beyond this one, this field is set to null. This is + * true only if this token is also a regular token. Otherwise, see below for a description of the contents of this + * field. */ public Token next; /** - * This field is used to access special tokens that occur prior to this - * token, but after the immediately preceding regular (non-special) token. - * If there are no such special tokens, this field is set to null. - * When there are more than one such special token, this field refers - * to the last of these special tokens, which in turn refers to the next - * previous special token through its specialToken field, and so on - * until the first special token (whose specialToken field is null). - * The next fields of special tokens refer to other special tokens that - * immediately follow it (without an intervening regular token). If there - * is no such token, this field is null. + * This field is used to access special tokens that occur prior to this token, but after the immediately preceding + * regular (non-special) token. If there are no such special tokens, this field is set to null. When there are more + * than one such special token, this field refers to the last of these special tokens, which in turn refers to the + * next previous special token through its specialToken field, and so on until the first special token (whose + * specialToken field is null). The next fields of special tokens refer to other special tokens that immediately + * follow it (without an intervening regular token). If there is no such token, this field is null. */ public Token specialToken; /** - * An optional attribute value of the Token. - * Tokens which are not used as syntactic sugar will often contain - * meaningful values that will be used later on by the compiler or - * 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. + * An optional attribute value of the Token. Tokens which are not used as syntactic sugar will often contain + * meaningful values that will be used later on by the compiler or 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. */ public Object getValue() { return null; @@ -112,21 +102,16 @@ public class Token implements java.io.Serializable { /** - * Returns a new Token object, by default. However, if you want, you - * can create and return subclass objects based on the value of ofKind. - * Simply add the cases to the switch for all those special cases. - * For example, if you have a subclass of Token called IDToken that - * you want to create if ofKind is ID, simply add something like : - * - * case MyParserConstants.ID : return new IDToken(ofKind, image); - * - * to the following switch statement. Then you can cast matchedToken - * variable to the appropriate type and use sit in your lexical actions. + * Returns a new Token object, by default. However, if you want, you can create and return subclass objects based on + * the value of ofKind. Simply add the cases to the switch for all those special cases. For example, if you have a + * subclass of Token called IDToken that you want to create if ofKind is ID, simply add something like : case + * MyParserConstants.ID : return new IDToken(ofKind, image); to the following switch statement. Then you can cast + * matchedToken variable to the appropriate type and use sit in your lexical actions. */ public static Token newToken(int ofKind, String image) { switch (ofKind) { - default: - return new Token(ofKind, image); + default: + return new Token(ofKind, image); } } diff --git a/java/org/apache/el/parser/TokenMgrError.java b/java/org/apache/el/parser/TokenMgrError.java index 585050cef4..144dd54bd4 100644 --- a/java/org/apache/el/parser/TokenMgrError.java +++ b/java/org/apache/el/parser/TokenMgrError.java @@ -7,9 +7,8 @@ package org.apache.el.parser; public class TokenMgrError extends Error { /** - * The version identifier for this Serializable class. - * Increment only if the <i>serialized</i> form of the - * class changes. + * The version identifier for this Serializable class. Increment only if the <i>serialized</i> form of the class + * changes. */ private static final long serialVersionUID = 1L; @@ -38,53 +37,51 @@ public class TokenMgrError extends Error { public static final int LOOP_DETECTED = 3; /** - * Indicates the reason why the exception is thrown. It will have - * one of the above 4 values. + * Indicates the reason why the exception is thrown. It will have one of the above 4 values. */ int errorCode; /** - * Replaces unprintable characters by their escaped (or unicode escaped) - * equivalents in the given string + * Replaces unprintable characters by their escaped (or unicode escaped) equivalents in the given string */ protected static final String addEscapes(String str) { StringBuilder retval = new StringBuilder(); char ch; for (int i = 0; i < str.length(); i++) { switch (str.charAt(i)) { - case '\b': - retval.append("\\b"); - continue; - case '\t': - retval.append("\\t"); - continue; - case '\n': - retval.append("\\n"); - continue; - case '\f': - retval.append("\\f"); - continue; - case '\r': - retval.append("\\r"); - continue; - case '\"': - retval.append("\\\""); - continue; - case '\'': - retval.append("\\\'"); - continue; - case '\\': - retval.append("\\\\"); - continue; - default: - if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { - String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4)); - } else { - retval.append(ch); - } - continue; + case '\b': + retval.append("\\b"); + continue; + case '\t': + retval.append("\\t"); + continue; + case '\n': + retval.append("\\n"); + continue; + case '\f': + retval.append("\\f"); + continue; + case '\r': + retval.append("\\r"); + continue; + case '\"': + retval.append("\\\""); + continue; + case '\'': + retval.append("\\\'"); + continue; + case '\\': + retval.append("\\\\"); + continue; + default: + if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { + String s = "0000" + Integer.toString(ch, 16); + retval.append("\\u" + s.substring(s.length() - 4)); + } else { + retval.append(ch); + } + continue; } } return retval.toString(); @@ -92,34 +89,26 @@ public class TokenMgrError extends Error { /** - * 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. + * 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. */ protected static String LexicalErr(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, int curChar) { char curChar1 = (char) curChar; - return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " - + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") - + "after : \"" + addEscapes(errorAfter) + "\""); + return ("Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered: " + + (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar1)) + "\"") + " (" + curChar + "), ") + + "after : \"" + addEscapes(errorAfter) + "\""); } /** - * You can also modify the body of this method to customize your error messages. - * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not - * of end-users concern, so you can return something like : - * - * "Internal Error : Please file a bug report .... " - * - * from this method for such cases in the release version of your parser. + * You can also modify the body of this method to customize your error messages. For example, cases like + * LOOP_DETECTED and INVALID_LEXICAL_STATE are not of end-users concern, so you can return something like : + * "Internal Error : Please file a bug report .... " from this method for such cases in the release version of your + * parser. */ @Override public String getMessage() { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org