Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.expression;
|
||||
|
||||
/**
|
||||
* Super class for exceptions that can occur whilst processing expressions
|
||||
* Super class for exceptions that can occur whilst processing expressions.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @since 3.0
|
||||
@@ -27,11 +27,11 @@ public class ExpressionException extends RuntimeException {
|
||||
|
||||
protected String expressionString;
|
||||
|
||||
protected int position; // -1 if not known - but should be known in all reasonable cases
|
||||
protected int position; // -1 if not known - but should be known in all reasonable cases
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new expression exception.
|
||||
* Construct a new expression exception.
|
||||
* @param expressionString the expression string
|
||||
* @param message a descriptive message
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ public class ExpressionException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new expression exception.
|
||||
* Construct a new expression exception.
|
||||
* @param expressionString the expression string
|
||||
* @param position the position in the expression string where the problem occurred
|
||||
* @param message a descriptive message
|
||||
@@ -54,7 +54,7 @@ public class ExpressionException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new expression exception.
|
||||
* Construct a new expression exception.
|
||||
* @param position the position in the expression string where the problem occurred
|
||||
* @param message a descriptive message
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ public class ExpressionException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new expression exception.
|
||||
* Construct a new expression exception.
|
||||
* @param position the position in the expression string where the problem occurred
|
||||
* @param message a descriptive message
|
||||
* @param cause the underlying cause of this exception
|
||||
@@ -75,21 +75,40 @@ public class ExpressionException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new expression exception.
|
||||
* Construct a new expression exception.
|
||||
* @param message a descriptive message
|
||||
*/
|
||||
public ExpressionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new expression exception.
|
||||
* @param message a descriptive message
|
||||
* @param cause the underlying cause of this exception
|
||||
*/
|
||||
public ExpressionException(String message, Throwable cause) {
|
||||
super(message,cause);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the exception message. Since Spring 4.0 this method returns the same
|
||||
* result as {@link #toDetailedString()}.
|
||||
* Return the expression string.
|
||||
*/
|
||||
public final String getExpressionString() {
|
||||
return this.expressionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the position in the expression string where the problem occurred.
|
||||
*/
|
||||
public final int getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exception message. Since Spring 4.0 this method returns the
|
||||
* same result as {@link #toDetailedString()}.
|
||||
* @see java.lang.Throwable#getMessage()
|
||||
*/
|
||||
@Override
|
||||
@@ -98,35 +117,34 @@ public class ExpressionException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exception simple message without including the expression that caused
|
||||
* the failure.
|
||||
* Return a detailed description of this exception, including the expression
|
||||
* String and position (if available) as well as the actual exception message.
|
||||
*/
|
||||
public String toDetailedString() {
|
||||
if (this.expressionString != null) {
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append("Expression '");
|
||||
output.append(this.expressionString);
|
||||
output.append("'");
|
||||
if (this.position != -1) {
|
||||
output.append(" @ ");
|
||||
output.append(this.position);
|
||||
}
|
||||
output.append(": ");
|
||||
output.append(getSimpleMessage());
|
||||
return output.toString();
|
||||
}
|
||||
else {
|
||||
return getSimpleMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the exception simple message without including the expression
|
||||
* that caused the failure.
|
||||
*/
|
||||
public String getSimpleMessage() {
|
||||
return super.getMessage();
|
||||
}
|
||||
|
||||
public String toDetailedString() {
|
||||
StringBuilder output = new StringBuilder();
|
||||
if (this.expressionString!=null) {
|
||||
output.append("Expression '");
|
||||
output.append(this.expressionString);
|
||||
output.append("'");
|
||||
if (this.position!=-1) {
|
||||
output.append(" @ ");
|
||||
output.append(this.position);
|
||||
}
|
||||
output.append(": ");
|
||||
}
|
||||
output.append(getSimpleMessage());
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public final String getExpressionString() {
|
||||
return this.expressionString;
|
||||
}
|
||||
|
||||
public final int getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user