View Javadoc

1   /*
2    * This file is part of Domingo
3    * an Open Source Java-API to Lotus Notes/Domino
4    * hosted at http://domingo.sourceforge.net
5    *
6    * Copyright (c) 2003-2007 Beck et al. projects GmbH Munich, Germany (http://www.bea.de)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21   */
22  package de.bea.domingo;
23  
24  /***
25   * Enumeration of notes errors.
26   *
27   * @see de.bea.domingo.DNotesException
28   * @author <a href="mailto:kriede@users.sourceforge.net">Kurt Riede</a>
29   */
30  public final class DNotesError {
31  
32      /*** error: general error. */
33      public static final DNotesError GENERAL_ERROR = new DNotesError(0);
34  
35      /*** error: database not found. */
36      public static final DNotesError DATABASE_NOT_FOUND = new DNotesError(1);
37  
38      /*** error: no access to database. */
39      public static final DNotesError DATABASE_NO_ACCESS = new DNotesError(2);
40  
41      /*** internal error code. */
42      private final int id;
43  
44      /***
45       * Private Constructor.
46       *
47       * @param theId the error code
48       */
49      public DNotesError(final int theId) {
50          this.id = theId;
51      }
52  
53      /***
54       * @see java.lang.Object#equals(java.lang.Object)
55       *
56       * @param   object the reference object with which to compare.
57       * @return <code>true</code> if this object is the same as the object
58       *         argument; <code>false</code> otherwise.
59       */
60      public boolean equals(final Object object) {
61          if (object == null) {
62              return false;
63          }
64          if (!(object instanceof DNotesError)) {
65              return false;
66          }
67          return this.id == ((DNotesError) object).id;
68      }
69  
70      /***
71       * @see java.lang.Object#hashCode()
72       *
73       * @return the id of the error
74       */
75      public int hashCode() {
76          return id;
77      }
78  
79      /***
80       * @see java.lang.Object#toString()
81       *
82       * @return the id of the error
83       */
84      public String toString() {
85          return "" + id;
86      }
87  
88      /***
89       * Returns a message for a given error.
90       *
91       * @param e an error
92       * @return a message for the error
93       */
94      public static String getMessage(final DNotesError e) {
95          if (e.equals(DATABASE_NOT_FOUND)) {
96              return "database not found";
97          } else if (e.equals(DATABASE_NOT_FOUND)) {
98              return "no access to database";
99          } else {
100             return "";
101         }
102     }
103 }