1. /*
  2. * Copyright 2002-2004 the original author or authors.
  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 org.springframework.beans;
  17. /**
  18. * Exception thrown when referring to an invalid bean property.
  19. * Carries the offending bean class and property name.
  20. * @author Juergen Hoeller
  21. * @since 31.05.2004
  22. */
  23. public class InvalidPropertyException extends FatalBeanException {
  24. private final Class beanClass;
  25. private final String propertyName;
  26. /**
  27. * Create a new InvalidPropertyException.
  28. * @param beanClass the offending bean class
  29. * @param propertyName the offending property
  30. * @param msg the detail message
  31. */
  32. public InvalidPropertyException(Class beanClass, String propertyName, String msg) {
  33. this(beanClass, propertyName, msg, null);
  34. }
  35. /**
  36. * Create a new InvalidPropertyException.
  37. * @param beanClass the offending bean class
  38. * @param propertyName the offending property
  39. * @param msg the detail message
  40. * @param ex the root cause
  41. */
  42. public InvalidPropertyException(Class beanClass, String propertyName, String msg, Throwable ex) {
  43. super("Invalid property '" + propertyName + "' of bean class [" + beanClass.getName() + "]: " + msg, ex);
  44. this.beanClass = beanClass;
  45. this.propertyName = propertyName;
  46. }
  47. /**
  48. * Return the offending bean class.
  49. */
  50. public Class getBeanClass() {
  51. return beanClass;
  52. }
  53. /**
  54. * Return the name of the offending property.
  55. */
  56. public String getPropertyName() {
  57. return propertyName;
  58. }
  59. }