KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > datatype > response > Result


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
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 org.apache.juddi.datatype.response;
17
18 import org.apache.juddi.datatype.RegistryObject;
19 import org.apache.juddi.i18n.RegistryResourceBundle;
20
21 /**
22  * Used in response DispositionReport.
23  *
24  * @author Steve Viens (sviens@apache.org)
25  */

26 public class Result implements RegistryObject
27 {
28   public static final int E_ASSERTION_NOT_FOUND = 30000;
29   public static final int E_AUTH_TOKEN_EXPIRED = 10110;
30   public static final int E_AUTH_TOKEN_REQUIRED = 10120;
31   public static final int E_ACCOUNT_LIMIT_EXCEEDED = 10160;
32   public static final int E_BUSY = 10400;
33   public static final int E_CATEGORIZATION_NOT_ALLOWED = 20100;
34   public static final int E_FATAL_ERROR = 10500;
35   public static final int E_INVALID_KEY_PASSED = 10210;
36   public static final int E_INVALID_PROJECTION = 20230;
37   public static final int E_INVALID_CATEGORY = 20000;
38   public static final int E_INVALID_COMPLETION_STATUS = 30100;
39   public static final int E_INVALID_URL_PASSED = 10220;
40   public static final int E_INVALID_VALUE = 20200;
41   public static final int E_KEY_RETIRED = 10310;
42   public static final int E_LANGUAGE_ERROR = 10060;
43   public static final int E_MESSAGE_TOO_LARGE = 30110;
44   public static final int E_NAME_TOO_LONG = 10020;
45   public static final int E_OPERATOR_MISMATCH = 10130;
46   public static final int E_PUBLISHER_CANCELLED = 30220;
47   public static final int E_REQUEST_DENIED = 30210;
48   public static final int E_SECRET_UNKNOWN = 30230;
49   public static final int E_SUCCESS = 0;
50   public static final int E_TOO_MANY_OPTIONS = 10030;
51   public static final int E_TRANSFER_ABORTED = 30200;
52   public static final int E_UNRECOGNIZED_VERSION = 10040;
53   public static final int E_UNKNOWN_USER = 10150;
54   public static final int E_UNSUPPORTED = 10050;
55   public static final int E_USER_MISMATCH = 10140;
56   public static final int E_VALUE_NOT_ALLOWED = 20210;
57   public static final int E_UNVALIDATABLE = 20220;
58   public static final int E_REQUEST_TIMEOUT = 20240;
59   public static final int E_INVALID_TIME = 40030;
60   public static final int E_RESULT_SET_TOO_LARGE = 40300;
61   
62   int errno;
63   ErrInfo errInfo;
64
65   /**
66    *
67    */

68   public Result()
69   {
70   }
71
72   /**
73    *
74    */

75   public Result(int errno)
76   {
77     setErrno(errno);
78   }
79
80   /**
81    *
82    */

83   public Result(int errno,ErrInfo errInfo)
84   {
85     this.errno = errno;
86     this.errInfo = errInfo;
87   }
88
89   /**
90    *
91    */

92   public Result(int errno,String JavaDoc errCode,String JavaDoc errMsg)
93   {
94     this.errno = errno;
95     this.errInfo = new ErrInfo(errCode,errMsg);
96   }
97
98   /**
99    * Sets the exception number of this disposition report to the given value.
100    * @param nmbr The new exception number for this disposition report.
101    */

102   public void setErrno(int nmbr)
103   {
104     this.errno = nmbr;
105   }
106
107   /**
108    * Sets the exception number of this disposition report to the given value.
109    * @param nmbr The new exception number for this disposition report.
110    */

111   public void setErrno(String JavaDoc nmbr)
112   {
113     Integer JavaDoc integer = new Integer JavaDoc(nmbr);
114     this.errno = integer.intValue();
115   }
116
117   /**
118    * Returns the exception number of this disposition report.
119    * @return The exception number of this disposition report.
120    */

121   public int getErrno()
122   {
123     return this.errno;
124   }
125
126   /**
127    *
128    */

129   public void setErrInfo(ErrInfo info)
130   {
131     this.errInfo = info;
132   }
133
134   /**
135    *
136    */

137   public ErrInfo getErrInfo()
138   {
139     return this.errInfo;
140   }
141
142   /**
143    * Sets the exception code of this ErrInfo to the given value.
144    * @param errcode The new code number for this ErrInfo.
145    */

146   public void setErrCode(String JavaDoc errCode)
147   {
148     if (this.errInfo == null)
149       errInfo = new ErrInfo();
150     errInfo.setErrCode(errCode);
151   }
152
153   /**
154    * Returns the exception code of this ErrInfo.
155    * @return The exception code of this ErrInfo.
156    */

157   public String JavaDoc getErrCode()
158   {
159     if (this.errInfo == null)
160       return null;
161     else
162       return errInfo.getErrCode();
163   }
164
165   /**
166    * Sets the exception message of this ErrInfo to the given value.
167    * @param msg The new exception message for this ErrInfo.
168    */

169   public void setErrText(String JavaDoc errText)
170   {
171     if (this.errInfo == null)
172       errInfo = new ErrInfo();
173     errInfo.setErrMsg(errText);
174   }
175
176   /**
177    * Returns the error text of this ErrInfo.
178    * @return The error text of this ErrInfo.
179    */

180   public String JavaDoc getErrText()
181   {
182     if (this.errInfo == null)
183       return null;
184     else
185       return errInfo.getErrMsg();
186   }
187
188   /**
189    *
190    */

191   public String JavaDoc toString()
192   {
193     if (errInfo == null)
194       return String.valueOf(errno);
195     
196     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
197     
198     String JavaDoc errCode = errInfo.getErrCode();
199     if (errCode != null)
200     {
201       buffer.append(errCode);
202       buffer.append(" ");
203     }
204     
205     buffer.append("(");
206     buffer.append(errno);
207     buffer.append(") ");
208     
209     String JavaDoc errText = errInfo.getErrMsg();
210     if (errText != null)
211     {
212       buffer.append(errText);
213       buffer.append(" ");
214     }
215     
216     return buffer.toString();
217   }
218
219   /**
220    *
221    */

222   public static final String JavaDoc lookupErrCode(int errno)
223   {
224     switch (errno)
225     {
226       case E_ACCOUNT_LIMIT_EXCEEDED : return "E_accountLimitExceeded";
227       case E_ASSERTION_NOT_FOUND : return "E_assertionNotFound";
228       case E_AUTH_TOKEN_EXPIRED : return "E_authTokenExpired";
229       case E_AUTH_TOKEN_REQUIRED : return "E_authTokenRequired";
230       case E_BUSY : return "E_busy";
231       case E_CATEGORIZATION_NOT_ALLOWED : return "E_categorizationNotAllowed";
232       case E_FATAL_ERROR : return "E_fatalError";
233       case E_INVALID_CATEGORY : return "E_invalidCategory";
234       case E_INVALID_COMPLETION_STATUS : return "E_invalidCompletionStatus";
235       case E_INVALID_KEY_PASSED : return "E_invalidKeyPassed";
236       case E_INVALID_PROJECTION : return "E_invalidProjection";
237       case E_INVALID_TIME : return "E_invalidTime";
238       case E_INVALID_URL_PASSED : return "E_invalidURLPassed";
239       case E_INVALID_VALUE : return "E_invalidValue";
240       case E_KEY_RETIRED : return "E_keyRetired";
241       case E_LANGUAGE_ERROR : return "E_languageError";
242       case E_MESSAGE_TOO_LARGE : return "E_messageTooLarge";
243       case E_NAME_TOO_LONG : return "E_nameTooLong";
244       case E_OPERATOR_MISMATCH : return "E_operatorMismatch";
245       case E_PUBLISHER_CANCELLED : return "E_publisherCancelled";
246       case E_REQUEST_DENIED : return "E_requestDenied";
247       case E_REQUEST_TIMEOUT : return "E_requestTimeout";
248       case E_RESULT_SET_TOO_LARGE : return "E_resultSetTooLarge";
249       case E_SECRET_UNKNOWN : return "E_secretUnknown";
250       case E_SUCCESS : return "E_success";
251       case E_TOO_MANY_OPTIONS : return "E_tooManyOptions";
252       case E_TRANSFER_ABORTED : return "E_transferAborted";
253       case E_UNKNOWN_USER : return "E_unknownUser";
254       case E_UNRECOGNIZED_VERSION : return "E_unrecognizedVersion";
255       case E_UNSUPPORTED : return "E_unsupported";
256       case E_UNVALIDATABLE : return "E_unvalidatable";
257       case E_USER_MISMATCH : return "E_userMismatch";
258       case E_VALUE_NOT_ALLOWED : return "E_valueNotAllowed";
259       default : return null;
260     }
261   }
262   
263   /**
264    *
265    */

266   public static final String JavaDoc lookupErrText(int errno)
267   {
268     String JavaDoc errCode = lookupErrCode(errno);
269     if (errCode == null)
270       return null;
271     
272     return RegistryResourceBundle.getString(errCode);
273   }
274 }
Popular Tags