You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

UnsupportedElementException.java 2.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2004 The Apache Software Foundation
  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. */
  17. package org.apache.tools.ant;
  18. /**
  19. * Used to report attempts to set an unsupported element
  20. * When the attempt to set the element is made,
  21. * the code does not not know the name of the task/type
  22. * based on a mapping from the classname to the task/type.
  23. * However one class may be used by a lot of task/types.
  24. * This exception may be caught by code that does know
  25. * the task/type and it will reset the message to the
  26. * correct message.
  27. * This will be done once (in the case of a recursive
  28. * call to handlechildren).
  29. *
  30. * @since Ant 1.6.3 or Ant 1.7 ?
  31. */
  32. public class UnsupportedElementException extends BuildException {
  33. private String myMessage = null;
  34. private String element;
  35. /**
  36. * Constructs an unsupport element exception
  37. * @param msg The string containing the message
  38. * @param element The name of the incorrect element
  39. */
  40. public UnsupportedElementException(String msg, String element) {
  41. super(msg);
  42. this.element = element;
  43. }
  44. /**
  45. * The element that is wrong
  46. *
  47. * @return the element name
  48. */
  49. public String getElement() {
  50. return element;
  51. }
  52. /**
  53. * Override throwable#getMessage
  54. * @return the message
  55. */
  56. public String getMessage() {
  57. if (myMessage == null) {
  58. return super.getMessage();
  59. } else {
  60. return myMessage;
  61. }
  62. }
  63. /**
  64. * Set the message (If not set already)
  65. * @param message a new message
  66. */
  67. public void setMessage(String message) {
  68. if (this.myMessage == null) {
  69. this.myMessage = message;
  70. }
  71. }
  72. }