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