1 16 17 package org.springframework.beans.factory.parsing; 18 19 import org.springframework.util.Assert; 20 21 32 public class Problem { 33 34 private final String message; 35 36 private final Location location; 37 38 private final ParseState parseState; 39 40 private final Throwable rootCause; 41 42 43 48 public Problem(String message, Location location) { 49 this(message, location, null, null); 50 } 51 52 58 public Problem(String message, Location location, ParseState parseState) { 59 this(message, location, parseState, null); 60 } 61 62 69 public Problem(String message, Location location, ParseState parseState, Throwable rootCause) { 70 Assert.notNull(message, "Message must not be null"); 71 Assert.notNull(location, "Location must not be null"); 72 this.message = message; 73 this.location = location; 74 this.parseState = parseState; 75 this.rootCause = rootCause; 76 } 77 78 79 82 public String getMessage() { 83 return message; 84 } 85 86 89 public Location getLocation() { 90 return location; 91 } 92 93 98 public String getResourceDescription() { 99 return getLocation().getResource().getDescription(); 100 } 101 102 105 public ParseState getParseState() { 106 return this.parseState; 107 } 108 109 112 public Throwable getRootCause() { 113 return rootCause; 114 } 115 116 117 public String toString() { 118 StringBuffer sb = new StringBuffer (); 119 sb.append("Configuration problem: "); 120 sb.append(getMessage()); 121 sb.append("\nOffending resource: ").append(getResourceDescription()); 122 if (getParseState() != null) { 123 sb.append('\n').append(getParseState()); 124 } 125 return sb.toString(); 126 } 127 128 } 129 | Popular Tags |