View Javadoc
1   /*
2    * Copyright 2008, 2009 Ange Optimization ApS
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 eu.simuline.octave.exception;
17  
18  import eu.simuline.octave.exec.OctaveExec; // for javadoc only 
19  
20  /**
21   * Base exception class for the JavaOctave project. 
22   * RuntimeException which handles the destroyed marker. 
23   * Special methods: {@link #setDestroyed(boolean)} and {@link #isDestroyed()}. 
24   * Note that derived classes shall implement all constructors ****. 
25   */
26  public abstract class OctaveException extends RuntimeException {
27  
28      /**
29       * Set to true on exceptions thrown from an Octave object 
30       * when the reason for the exception is that the object has 
31       * been asked to destroy its octave process. 
32       */
33      private boolean destroyed = false;
34  
35      /**
36       * Constructor. 
37       *
38       * @see Throwable
39       */
40      public OctaveException() {
41          // Do nothing
42      }
43  
44      /**
45       * Constructor. 
46       *
47       * @param message
48       * @see Throwable
49       */
50      public OctaveException(final String message) {
51          super(message);
52      }
53  
54      /**
55       * Constructor. 
56       *
57       * @param cause
58       * @see Throwable
59       */
60      public OctaveException(final Throwable cause) {
61          super(cause);
62      }
63  
64      /**
65       * Constructor 
66       * required by {@link  OctaveExec#reInstException(OctaveException)}. 
67       *
68       * @param message
69       * @param cause
70       * @see Throwable
71       */
72      public OctaveException(final String message, final Throwable cause) {
73          super(message, cause);
74      }
75  
76      /**
77       * @return destroyed
78       */
79      public final boolean isDestroyed() {
80          return this.destroyed;
81      }
82  
83      /**
84       * @param destroyed
85       */
86      public final void setDestroyed(final boolean destroyed) {
87          this.destroyed = destroyed;
88      }
89  
90  }