|
|
@ -22,12 +22,11 @@ import org.springframework.lang.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Simple {@link ArrayDeque}-based structure for tracking the logical position during |
|
|
|
* Simple {@link ArrayDeque}-based structure for tracking the logical position during |
|
|
|
* a parsing process. {@link Entry entries} are added to the LinkedList at |
|
|
|
* a parsing process. {@link Entry entries} are added to the ArrayDeque at each point |
|
|
|
* each point during the parse phase in a reader-specific manner. |
|
|
|
* during the parse phase in a reader-specific manner. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Calling {@link #toString()} will render a tree-style view of the current logical |
|
|
|
* <p>Calling {@link #toString()} will render a tree-style view of the current logical |
|
|
|
* position in the parse phase. This representation is intended for use in |
|
|
|
* position in the parse phase. This representation is intended for use in error messages. |
|
|
|
* error messages. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rob Harrop |
|
|
|
* @author Rob Harrop |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
@ -35,11 +34,6 @@ import org.springframework.lang.Nullable; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final class ParseState { |
|
|
|
public final class ParseState { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Tab character used when rendering the tree-style representation. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static final char TAB = '\t'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Internal {@link ArrayDeque} storage. |
|
|
|
* Internal {@link ArrayDeque} storage. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -54,8 +48,8 @@ public final class ParseState { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new {@code ParseState} whose {@link ArrayDeque} is a {@link Object#clone clone} |
|
|
|
* Create a new {@code ParseState} whose {@link ArrayDeque} is a clone |
|
|
|
* of that of the passed in {@code ParseState}. |
|
|
|
* of the state in the passed-in {@code ParseState}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ParseState(ParseState other) { |
|
|
|
private ParseState(ParseState other) { |
|
|
|
this.state = other.state.clone(); |
|
|
|
this.state = other.state.clone(); |
|
|
@ -99,13 +93,13 @@ public final class ParseState { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String toString() { |
|
|
|
public String toString() { |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
StringBuilder sb = new StringBuilder(64); |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
for (ParseState.Entry entry : this.state) { |
|
|
|
for (ParseState.Entry entry : this.state) { |
|
|
|
if (i > 0) { |
|
|
|
if (i > 0) { |
|
|
|
sb.append('\n'); |
|
|
|
sb.append('\n'); |
|
|
|
for (int j = 0; j < i; j++) { |
|
|
|
for (int j = 0; j < i; j++) { |
|
|
|
sb.append(TAB); |
|
|
|
sb.append('\t'); |
|
|
|
} |
|
|
|
} |
|
|
|
sb.append("-> "); |
|
|
|
sb.append("-> "); |
|
|
|
} |
|
|
|
} |
|
|
|