IllegalStateException.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* IllegalStateException.java -- thrown when invoking a method at
  2. an illegal or inappropriate time
  3. Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
  4. This file is part of GNU Classpath.
  5. GNU Classpath is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. GNU Classpath is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GNU Classpath; see the file COPYING. If not, write to the
  15. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA.
  17. Linking this library statically or dynamically with other modules is
  18. making a combined work based on this library. Thus, the terms and
  19. conditions of the GNU General Public License cover the whole
  20. combination.
  21. As a special exception, the copyright holders of this library give you
  22. permission to link this library with independent modules to produce an
  23. executable, regardless of the license terms of these independent
  24. modules, and to copy and distribute the resulting executable under
  25. terms of your choice, provided that you also meet, for each linked
  26. independent module, the terms and conditions of the license of that
  27. module. An independent module is a module which is not derived from
  28. or based on this library. If you modify this library, you may extend
  29. this exception to your version of the library, but you are not
  30. obligated to do so. If you do not wish to do so, delete this
  31. exception statement from your version. */
  32. package java.lang;
  33. /**
  34. * Thrown when a method is invoked at an illegal or inappropriate time. For
  35. * example:<br>
  36. * <pre>
  37. * void m(Collecion c)
  38. * {
  39. * c.iterator().remove();
  40. * }
  41. * </pre>
  42. *
  43. * @author Brian Jones
  44. * @author Warren Levy (warrenl@cygnus.com)
  45. * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
  46. * @since 1.1
  47. * @status updated to 1.5
  48. */
  49. public class IllegalStateException extends RuntimeException
  50. {
  51. /**
  52. * Compatible with JDK 1.1+.
  53. */
  54. private static final long serialVersionUID = -1848914673093119416L;
  55. /**
  56. * Create an exception without a message.
  57. */
  58. public IllegalStateException()
  59. {
  60. }
  61. /**
  62. * Create an exception with a message.
  63. *
  64. * @param s the message
  65. */
  66. public IllegalStateException(String s)
  67. {
  68. super(s);
  69. }
  70. /**
  71. * <p>
  72. * Constructs a <code>IllegalStateException</code> using
  73. * the specified error message, which should give further details
  74. * as to the reason for this exception. The specified cause
  75. * <code>Throwable</code> may be used to provide additional history,
  76. * with regards to the root of the problem. It is perfectly valid
  77. * for this to be null, if the cause of the problem is unknown.
  78. * </p>
  79. * <p>
  80. * <strong>Note</strong>: the detail message from the cause is not
  81. * automatically incorporated into the resulting detail message of
  82. * this exception.
  83. * </p>
  84. *
  85. * @param message the detail message, which should give the reason for
  86. * this exception being thrown.
  87. * @param cause the cause of this exception, or null if the cause
  88. * is unknown.
  89. * @since 1.5
  90. */
  91. public IllegalStateException(String message, Throwable cause)
  92. {
  93. super(message, cause);
  94. }
  95. /**
  96. * <p>
  97. * Constructs a <code>IllegalStateException</code> using
  98. * the specified cause <code>Throwable</code>, which may be used
  99. * to provide additional history, with regards to the root of the
  100. * problem. It is perfectly valid for this to be null, if the
  101. * cause of the problem is unknown.
  102. * </p>
  103. * <p>
  104. * The detail message is automatically constructed from the detail
  105. * message of the supplied causal exception. If the cause is null,
  106. * then the detail message will also be null. Otherwise, the detail
  107. * message of this exception will be that of the causal exception.
  108. * This makes this constructor very useful for simply wrapping another
  109. * exception.
  110. * </p>
  111. *
  112. * @param cause the cause of this exception, or null if the cause
  113. * is unknown.
  114. * @since 1.5
  115. */
  116. public IllegalStateException(Throwable cause)
  117. {
  118. super(cause);
  119. }
  120. }