1 /* 2 * Copyright 2007-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.exceptions.i18n; 17 18 import de.smartics.exceptions.i18n.app.ConfigurationExceptionCode; 19 import de.smartics.exceptions.i18n.message.MessageParam; 20 21 /** 22 * This exception is thrown if the configuration is not valid so that the system 23 * cannot evaluate the exception property. 24 * <p> 25 * This exception and all subclasses of this exception share the resource bundle 26 * with {@link ConfigurationException}. This may change in future and is not 27 * considered to be part of the public API. 28 * </p> 29 */ 30 public class PropertyAccessConfigurationException extends 31 ConfigurationException 32 { 33 // ********************************* Fields ********************************* 34 35 // --- constants ------------------------------------------------------------ 36 37 /** 38 * The class version identifier. 39 * <p> 40 * The value of this constant is {@value}. 41 */ 42 private static final long serialVersionUID = 1L; 43 44 // --- members -------------------------------------------------------------- 45 46 /** 47 * The class that should contain the property but the information cannot be 48 * accessed. 49 * 50 * @serial 51 */ 52 @MessageParam("0:canonicalName") 53 protected final Class<?> clazz; 54 55 /** 56 * The name of the property that cannot be accessed. 57 * 58 * @serial 59 */ 60 @MessageParam("1") 61 protected final String propertyName; 62 63 // ****************************** Initializer ******************************* 64 65 // ****************************** Constructors ****************************** 66 67 /** 68 * Constructor. 69 * 70 * @param code the error or exception code of the exception. 71 * @param propertyName the name of the property that cannot be accessed. 72 * @param clazz the class that should contain the property but the information 73 * cannot be accessed. 74 * @see #PropertyAccessConfigurationException(Throwable,ConfigurationExceptionCode,String,Class) 75 */ 76 public PropertyAccessConfigurationException( 77 final ConfigurationExceptionCode code, final String propertyName, 78 final Class<?> clazz) 79 { 80 this(null, code, propertyName, clazz); 81 } 82 83 /** 84 * Constructor. 85 * 86 * @param cause the cause (which is saved for later retrieval by the 87 * {@link #getCause()} method). (A <tt>null</tt> value is permitted, 88 * and indicates that the cause is nonexistent or unknown.) 89 * @param code the error or exception code of the exception. 90 * @param propertyName the name of the property that cannot be accessed. 91 * @param clazz the class that should contain the property but the information 92 * cannot be accessed. 93 */ 94 public PropertyAccessConfigurationException(final Throwable cause, 95 final ConfigurationExceptionCode code, final String propertyName, 96 final Class<?> clazz) 97 { 98 super(cause, code, null); 99 this.propertyName = propertyName; 100 this.clazz = clazz; 101 } 102 103 // ****************************** Inner Classes ***************************** 104 105 // ********************************* Methods ******************************** 106 107 // --- init ----------------------------------------------------------------- 108 109 // --- get&set -------------------------------------------------------------- 110 111 /** 112 * Returns the name of the property that cannot be accessed. 113 * 114 * @return the name of the property that cannot be accessed. 115 */ 116 public String getPropertyName() 117 { 118 return propertyName; 119 } 120 121 /** 122 * Returns the class that should contain the property but the information 123 * cannot be accessed. 124 * 125 * @return the class that should contain the property but the information 126 * cannot be accessed. 127 */ 128 public Class<?> getClazz() 129 { 130 return clazz; 131 } 132 133 // --- business ------------------------------------------------------------- 134 135 // --- object basics -------------------------------------------------------- 136 }