1 16 17 package org.springframework.beans.factory.parsing; 18 19 import java.util.Stack ; 20 21 33 public final class ParseState { 34 35 38 private static final char TAB = '\t'; 39 40 43 private final Stack state; 44 45 46 49 public ParseState() { 50 this.state = new Stack (); 51 } 52 53 57 private ParseState(ParseState other) { 58 this.state = (Stack ) other.state.clone(); 59 } 60 61 62 65 public void push(Entry entry) { 66 this.state.push(entry); 67 } 68 69 72 public void pop() { 73 this.state.pop(); 74 } 75 76 80 public Entry peek() { 81 return (Entry) (this.state.empty() ? null : this.state.peek()); 82 } 83 84 88 public ParseState snapshot() { 89 return new ParseState(this); 90 } 91 92 93 96 public String toString() { 97 StringBuffer sb = new StringBuffer (); 98 for (int x = 0; x < this.state.size(); x++) { 99 if (x > 0) { 100 sb.append('\n'); 101 for (int y = 0; y < x; y++) { 102 sb.append(TAB); 103 } 104 sb.append("-> "); 105 } 106 sb.append(this.state.get(x)); 107 } 108 return sb.toString(); 109 } 110 111 112 115 public interface Entry { 116 117 } 118 119 } 120 | Popular Tags |