View Javadoc

1   /*
2    * This file is part of hyphenType. hyphenType is free software: you can
3    * redistribute it and/or modify it under the terms of the GNU General Public
4    * License as published by the Free Software Foundation, either version 3 of the
5    * License, or (at your option) any later version. hyphenType is distributed in
6    * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
7    * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
8    * the GNU General Public License for more details. You should have received a
9    * copy of the GNU General Public License along with hyphenType. If not, see
10   * <http://www.gnu.org/licenses/>.
11   */
12  package org.hyphenType.exit;
13  
14  import org.hyphenType.datastructure.Options;
15  
16  /**
17   * Status code enumerations. Enumerations that implement this interface can be
18   * used as status codes, which are arguments for the method
19   * {@link Options#exit(Enum)}.<br>
20   * <br>
21   * <strong>!ATTENTION!</strong> {@link Enum#ordinal()} is used as the status
22   * code, when the method {@link System#exit(int)} is called. Meaning,
23   * <strong>the first enumeration constant should necessarily mean successful
24   * program execution</strong>, since its ordinal will be zero.
25   * 
26   * @author Aurelio Akira M. Matsui
27   */
28  public interface StatusCode {
29      
30      /**
31       * A call back method that is invoked by the method
32       * {@link Options#exit(Enum)} right before attempting to terminate the VM.
33       * This method can be used to output custom message to the console, for
34       * instance.<br/>
35       * This method is similar to a {@link Runtime#addShutdownHook(Thread)}. The
36       * main difference is that this method will be called on the enumeration
37       * constant related to the exit status.
38       * 
39       * @param helper A helper object that gives access to some utility methods.
40       */
41      public void beforeExit(ExitStatusHelper helper);
42  }