Browse Source

Fix and improve Javadoc in spring-expression

Closes gh-28800
pull/28850/head
Marc Wrobel 2 years ago committed by Sam Brannen
parent
commit
91258271e4
  1. 2
      spring-expression/src/main/java/org/springframework/expression/ConstructorResolver.java
  2. 2
      spring-expression/src/main/java/org/springframework/expression/ParserContext.java
  3. 4
      spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java
  4. 2
      spring-expression/src/main/java/org/springframework/expression/spel/SpelNode.java
  5. 6
      spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java
  6. 7
      spring-expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java
  7. 4
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java
  8. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
  9. 2
      spring-expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java
  10. 2
      spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java
  11. 2
      spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java
  12. 2
      spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurityExpressionTests.java
  13. 6
      spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
  14. 4
      spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java
  15. 2
      spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java

2
spring-expression/src/main/java/org/springframework/expression/ConstructorResolver.java

@ -22,7 +22,7 @@ import org.springframework.core.convert.TypeDescriptor; @@ -22,7 +22,7 @@ import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;
/**
* A constructor resolver attempts locate a constructor and returns a ConstructorExecutor
* A constructor resolver attempts to locate a constructor and returns a ConstructorExecutor
* that can be used to invoke that constructor. The ConstructorExecutor will be cached but
* if it 'goes stale' the resolvers will be called again.
*

2
spring-expression/src/main/java/org/springframework/expression/ParserContext.java

@ -27,7 +27,7 @@ package org.springframework.expression; @@ -27,7 +27,7 @@ package org.springframework.expression;
public interface ParserContext {
/**
* Whether or not the expression being parsed is a template. A template expression
* Whether the expression being parsed is a template. A template expression
* consists of literal text that can be mixed with evaluatable blocks. Some examples:
* <pre class="code">
* Some literal text

4
spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java

@ -171,7 +171,7 @@ public class CodeFlow implements Opcodes { @@ -171,7 +171,7 @@ public class CodeFlow implements Opcodes {
/**
* Called after the main expression evaluation method has been generated, this
* method will callback any registered FieldAdders or ClinitAdders to add any
* method will call back any registered FieldAdders or ClinitAdders to add any
* extra information to the class representing the compiled expression.
*/
public void finish() {
@ -1008,7 +1008,7 @@ public class CodeFlow implements Opcodes { @@ -1008,7 +1008,7 @@ public class CodeFlow implements Opcodes {
/**
* For use in mathematical operators, handles converting from a (possibly boxed)
* number on the stack to a primitive numeric type.
* <p>For example, from a Integer to a double, just need to call 'Number.doubleValue()'
* <p>For example, from an Integer to a double, just need to call 'Number.doubleValue()'
* but from an int to a double, need to use the bytecode 'i2d'.
* @param mv the method visitor when instructions should be appended
* @param stackDescriptor a descriptor of the operand on the stack

2
spring-expression/src/main/java/org/springframework/expression/spel/SpelNode.java

@ -66,7 +66,7 @@ public interface SpelNode { @@ -66,7 +66,7 @@ public interface SpelNode {
void setValue(ExpressionState expressionState, @Nullable Object newValue) throws EvaluationException;
/**
* Return the string form the this AST node.
* Return the string form of this AST node.
* @return the string form
*/
String toStringAST();

6
spring-expression/src/main/java/org/springframework/expression/spel/ast/ConstructorReference.java

@ -140,7 +140,7 @@ public class ConstructorReference extends SpelNodeImpl { @@ -140,7 +140,7 @@ public class ConstructorReference extends SpelNodeImpl {
// To determine which situation it is, the AccessException will contain a cause.
// If the cause is an InvocationTargetException, a user exception was thrown inside the constructor.
// Otherwise the constructor could not be invoked.
// Otherwise, the constructor could not be invoked.
if (ex.getCause() instanceof InvocationTargetException) {
// User exception was the root cause - exit now
Throwable rootCause = ex.getCause().getCause();
@ -271,7 +271,7 @@ public class ConstructorReference extends SpelNodeImpl { @@ -271,7 +271,7 @@ public class ConstructorReference extends SpelNodeImpl {
newArray = Array.newInstance(componentType, arraySize);
}
else {
// Multi-dimensional - hold onto your hat!
// Multidimensional - hold onto your hat!
int[] dims = new int[this.dimensions.length];
long numElements = 1;
for (int d = 0; d < this.dimensions.length; d++) {
@ -288,7 +288,7 @@ public class ConstructorReference extends SpelNodeImpl { @@ -288,7 +288,7 @@ public class ConstructorReference extends SpelNodeImpl {
else {
// There is an initializer
if (this.dimensions == null || this.dimensions.length > 1) {
// There is an initializer but this is a multi-dimensional array (e.g. new int[][]{{1,2},{3,4}})
// There is an initializer but this is a multidimensional array (e.g. new int[][]{{1,2},{3,4}})
// - this is not currently supported
throw new SpelEvaluationException(getStartPosition(),
SpelMessage.MULTIDIM_ARRAY_INITIALIZER_NOT_SUPPORTED);

7
spring-expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java

@ -26,8 +26,9 @@ import org.springframework.util.Assert; @@ -26,8 +26,9 @@ import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Represents the elvis operator ?:. For an expression "a?:b" if a is not null, the value
* of the expression is "a", if a is null then the value of the expression is "b".
* Represents the elvis operator <code>?:</code>. For an expression <code>a?:b</code> if <code>a</code> is not null,
* the value of the expression is <code>a</code>, if <code>a</code> is null then the value of the expression is
* <code>b</code>.
*
* @author Andy Clement
* @author Juergen Hoeller
@ -117,7 +118,7 @@ public class Elvis extends SpelNodeImpl { @@ -117,7 +118,7 @@ public class Elvis extends SpelNodeImpl {
this.exitTypeDescriptor = conditionDescriptor;
}
else {
// Use the easiest to compute common super type
// Use the easiest to compute common supertype
this.exitTypeDescriptor = "Ljava/lang/Object";
}
}

4
spring-expression/src/main/java/org/springframework/expression/spel/ast/OperatorInstanceof.java

@ -29,8 +29,8 @@ import org.springframework.lang.Nullable; @@ -29,8 +29,8 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
* The operator 'instanceof' checks if an object is of the class specified in the right
* hand operand, in the same way that {@code instanceof} does in Java.
* The operator 'instanceof' checks if an object is of the class specified in the
* right-hand operand, in the same way that {@code instanceof} does in Java.
*
* @author Andy Clement
* @since 3.0

2
spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java

@ -164,7 +164,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl { @@ -164,7 +164,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
/**
* Attempt to read the named property from the current context object.
* @return the value of the property
* @throws EvaluationException if any problem accessing the property or it cannot be found
* @throws EvaluationException if any problem accessing the property, or if it cannot be found
*/
private TypedValue readProperty(TypedValue contextObject, EvaluationContext evalContext, String name)
throws EvaluationException {

2
spring-expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java

@ -74,7 +74,7 @@ public class Ternary extends SpelNodeImpl { @@ -74,7 +74,7 @@ public class Ternary extends SpelNodeImpl {
this.exitTypeDescriptor = leftDescriptor;
}
else {
// Use the easiest to compute common super type
// Use the easiest to compute common supertype
this.exitTypeDescriptor = "Ljava/lang/Object";
}
}

2
spring-expression/src/main/java/org/springframework/expression/spel/standard/InternalSpelExpressionParser.java

@ -78,7 +78,7 @@ import org.springframework.util.Assert; @@ -78,7 +78,7 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Hand-written SpEL parser. Instances are reusable but are not thread-safe.
* Handwritten SpEL parser. Instances are reusable but are not thread-safe.
*
* @author Andy Clement
* @author Juergen Hoeller

2
spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java

@ -35,7 +35,7 @@ public class OperatorOverloaderTests extends AbstractExpressionTests { @@ -35,7 +35,7 @@ public class OperatorOverloaderTests extends AbstractExpressionTests {
@Test
public void testSimpleOperations() throws Exception {
// no built in support for this:
// no built-in support for this:
evaluateAndCheckError("'abc'-true",SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
StandardEvaluationContext eContext = TestScenarioCreator.getTestEvaluationContext();

2
spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurityExpressionTests.java

@ -123,7 +123,7 @@ public class ScenariosForSpringSecurityExpressionTests extends AbstractExpressio @@ -123,7 +123,7 @@ public class ScenariosForSpringSecurityExpressionTests extends AbstractExpressio
SpelExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.setRootObject(new Supervisor("Ben")); // so non-qualified references 'hasRole()' 'hasIpAddress()' are invoked against it);
ctx.setRootObject(new Supervisor("Ben")); // so non-qualified references 'hasRole()' 'hasIpAddress()' are invoked against it;
ctx.addMethodResolver(new MyMethodResolver()); // NEEDS TO OVERRIDE THE REFLECTION ONE - SHOW REORDERING MECHANISM
// Might be better with a as a variable although it would work as a property too...

6
spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java

@ -84,7 +84,7 @@ public class SetValueTests extends AbstractExpressionTests { @@ -84,7 +84,7 @@ public class SetValueTests extends AbstractExpressionTests {
StandardEvaluationContext lContext = TestScenarioCreator.getTestEvaluationContext();
// PROPERTYORFIELDREFERENCE
// Non existent field (or property):
// Non-existent field (or property):
Expression e1 = parser.parseExpression("arrayContainer.wibble");
assertThat(e1.isWritable(lContext)).as("Should not be writable!").isFalse();
@ -103,12 +103,12 @@ public class SetValueTests extends AbstractExpressionTests { @@ -103,12 +103,12 @@ public class SetValueTests extends AbstractExpressionTests {
assertThat(e4.isWritable(lContext)).as("Should not be writable!").isFalse();
// INDEXER
// non existent indexer (wibble made up)
// non-existent indexer (wibble made up)
Expression e5 = parser.parseExpression("arrayContainer.wibble[99]");
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
e5.isWritable(lContext));
// non existent indexer (index via a string)
// non-existent indexer (index via a string)
Expression e6 = parser.parseExpression("arrayContainer.ints['abc']");
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
e6.isWritable(lContext));

4
spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java

@ -272,7 +272,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @@ -272,7 +272,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
assertCanCompile(expression);
assertThat(expression.getValue()).asInstanceOf(BOOLEAN).isTrue();
// Only when the right hand operand is a direct type reference
// Only when the right-hand operand is a direct type reference
// will it be compilable.
StandardEvaluationContext ctx = new StandardEvaluationContext();
ctx.setVariable("foo", String.class);
@ -4155,7 +4155,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests { @@ -4155,7 +4155,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
void propertyReference() {
TestClass6 tc = new TestClass6();
// non static field
// non-static field
expression = parser.parseExpression("orange");
assertCantCompile(expression);
assertThat(expression.getValue(tc)).isEqualTo("value1");

2
spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java

@ -602,7 +602,7 @@ class SpelReproTests extends AbstractExpressionTests { @@ -602,7 +602,7 @@ class SpelReproTests extends AbstractExpressionTests {
/**
* Test whether {@link ReflectiveMethodResolver} follows Java Method Invocation
* Conversion order. And more precisely that widening reference conversion is 'higher'
* than a unboxing conversion.
* than an unboxing conversion.
*/
@Test
void conversionPriority_SPR8224() throws Exception {

Loading…
Cancel
Save