View Javadoc

1   /*
2    * Copyright 2006-2010 Sam Adams <sea36 at users.sourceforge.net>
3    *
4    * This file is part of JNI-InChI.
5    *
6    * JNI-InChI is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as published
8    * by the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * JNI-InChI is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with JNI-InChI.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package net.sf.jniinchi;
20  
21  
22  /**
23   * <p>Type-safe enumeration of InChI return codes.
24   *
25   * <p>InChI library return values:<br>
26   * <tt>
27   * SKIP     (-2)    Not used in InChI library<br>
28   * EOF      (-1)    No structural data has been provided<br>
29   * OKAY     (0)     Success, no errors or warnings<br>
30   * WARNING  (1)     Success, warning(s) issued<br>
31   * ERROR    (2)     Error: no InChI has been created<br>
32   * FATAL    (3)     Severe error: no InChI has been created (typically,
33   *                  memory allocation failure)<br>
34   * UNKNOWN  (4)     Unknown program error<br>
35   * BUSY     (5)     Previous call to InChI has not returned yet<br>
36   * </tt>
37   * <p>See <tt>inchi_api.h</tt>.
38   * @author Sam Adams
39   */
40  public enum INCHI_RET {
41  
42      /**
43       * Not used in InChI library.
44       */
45      SKIP(-2),
46  
47      /**
48       * No structural data has been provided.
49       */
50      EOF(-1),
51  
52      /**
53       * Success; no errors or warnings.
54       */
55      OKAY(0),
56  
57      /**
58       * Success; warning(s) issued.
59       */
60      WARNING(1),
61  
62      /**
63       * Error: no InChI has been created.
64       */
65      ERROR(2),
66  
67      /**
68       * Severe error: no InChI has been created (typically, memory allocation failure).
69       */
70      FATAL(3),
71  
72      /**
73       * Unknown program error.
74       */
75      UNKNOWN(4),
76  
77      /**
78       * Previuos call to InChI has not returned yet.
79       */
80      BUSY(5);
81  
82  
83  
84      /**
85       * Internal InChI index (from inchi_api.h).
86       */
87      private final int indx;
88  
89      /**
90       * Constructor.
91       */
92      private INCHI_RET(final int indx) {
93          this.indx = indx;
94      };
95  
96      public int getIndx() {
97          return indx;
98      }
99  
100     public static INCHI_RET getValue(int ret) {
101         switch(ret) {
102             case -2:
103                 return SKIP;
104             case -1:
105                 return EOF;
106             case 0:
107                 return OKAY;
108             case 1:
109                 return WARNING;
110             case 2:
111                 return ERROR;
112             case 3:
113                 return FATAL;
114             case 4:
115                 return UNKNOWN;
116             case 5:
117                 return BUSY;
118             default:
119                 return null;
120         }
121     }
122     
123 }