01: package de.java2html.properties;
02:
03: import de.java2html.util.IllegalConfigurationException;
04:
05: /**
06: * @author Markus Gebhard
07: */
08: public class IllegalPropertyValueException extends
09: IllegalConfigurationException {
10:
11: public IllegalPropertyValueException(String propertyName,
12: String value) {
13: super (createMessage(propertyName, value, null));
14: }
15:
16: public IllegalPropertyValueException(String propertyName,
17: String value, String[] validValues) {
18: super (createMessage(propertyName, value, validValues));
19: }
20:
21: private static String createMessage(String propertyName,
22: String value, String[] validValues) {
23: StringBuffer message = new StringBuffer(
24: "Illegal property value '" + value + "' for property '"
25: + propertyName + "'");
26: if (validValues != null && validValues.length > 0) {
27: message.append("Valid values are: ");
28: for (int i = 0; i < validValues.length; i++) {
29: message.append("'" + validValues[i] + "'");
30: if (i < validValues.hashCode() - 1) {
31: message.append(", ");
32: }
33: }
34: }
35: return message.toString();
36: }
37: }
|