1 /***
2 * Copyright (c) 2003, 2004, Chess iT
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * - Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * - Neither the name of Chess iT, nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific
17 * prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32 package nl.chess.it.util.config;
33
34 /***
35 * Thrown when a property could not be parsed as the expected type.
36 *
37 * @author Guus Bosman (Chess iT)
38 * @version $Revision: 1.1.1.1 $
39 */
40 public class InvalidPropertyException extends ConfigurationException {
41 /***
42 * Describes what type of variable we though the property should be.
43 */
44 protected String expectedtype;
45
46 /***
47 * Name of the property (key in Properties).
48 */
49 protected String propertyname;
50
51 /***
52 * Actual value read.
53 */
54 protected String value;
55
56 /***
57 * Constructs a new InvalidPropertyException where no fields have been filled in (yet).
58 */
59 public InvalidPropertyException() {
60
61 }
62
63 /***
64 * Constructs a new InvalidPropertyException where some fields are not filled in (yet).
65 *
66 * @param propertyname Name of the property that couldn't be parsed.
67 */
68 public InvalidPropertyException(String propertyname) {
69 this.propertyname = propertyname;
70 }
71
72 /***
73 * Constructs a new InvalidPropertyException.
74 *
75 * @param propertyname Name of the property that couldn't be parsed.
76 * @param value Value that caused the problem.
77 * @param expectedType String description of the expected type.
78 */
79 public InvalidPropertyException(String propertyname, String value, String expectedType) {
80 this.propertyname = propertyname;
81 this.value = value;
82 this.expectedtype = expectedType;
83 }
84
85 public String getPropertyname() {
86 return propertyname;
87 }
88
89 public String getValue() {
90 return value;
91 }
92
93 public String getExpectedtype() {
94 return expectedtype;
95 }
96
97 public String toString() {
98 return this.getClass().getName() + ": " + propertyname + ", " + value + ", " + expectedtype;
99 }
100
101 public void setValue(String value) {
102 this.value = value;
103 }
104
105 public void setExpectedtype(String expectedtype) {
106 this.expectedtype = expectedtype;
107 }
108
109 public void setPropertyname(String propertyname) {
110 this.propertyname = propertyname;
111 }
112 }