KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > jcifs > netbios > NbtException


1 /* jcifs smb client library in Java
2  * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package com.knowgate.jcifs.netbios;
20
21 import java.io.IOException JavaDoc;
22
23 public class NbtException extends IOException JavaDoc {
24
25     // error classes
26
public static final int SUCCESS = 0;
27     public static final int ERR_NAM_SRVC = 0x01;
28     public static final int ERR_SSN_SRVC = 0x02;
29
30     // name service error codes
31
public static final int FMT_ERR = 0x1;
32     public static final int SRV_ERR = 0x2;
33     public static final int IMP_ERR = 0x4;
34     public static final int RFS_ERR = 0x5;
35     public static final int ACT_ERR = 0x6;
36     public static final int CFT_ERR = 0x7;
37
38     // session service error codes
39
public static final int CONNECTION_REFUSED = -1;
40     public static final int NOT_LISTENING_CALLED = 0x80;
41     public static final int NOT_LISTENING_CALLING = 0x81;
42     public static final int CALLED_NOT_PRESENT = 0x82;
43     public static final int NO_RESOURCES = 0x83;
44     public static final int UNSPECIFIED = 0x8F;
45
46     public int errorClass;
47     public int errorCode;
48
49     public static String JavaDoc getErrorString( int errorClass, int errorCode ) {
50         String JavaDoc result = "";
51         switch( errorClass ) {
52             case SUCCESS:
53                 result += "SUCCESS";
54                 break;
55             case ERR_NAM_SRVC:
56                 result += "ERR_NAM_SRVC/";
57                 switch( errorCode ) {
58                     case FMT_ERR:
59                         result += "FMT_ERR: Format Error";
60                     default:
61                         result += "Unknown error code: " + errorCode;
62                 }
63                 break;
64             case ERR_SSN_SRVC:
65                 result += "ERR_SSN_SRVC/";
66                 switch( errorCode ) {
67                     case CONNECTION_REFUSED:
68                         result += "Connection refused";
69                         break;
70                     case NOT_LISTENING_CALLED:
71                         result += "Not listening on called name";
72                         break;
73                     case NOT_LISTENING_CALLING:
74                         result += "Not listening for calling name";
75                         break;
76                     case CALLED_NOT_PRESENT:
77                         result += "Called name not present";
78                         break;
79                     case NO_RESOURCES:
80                         result += "Called name present, but insufficient resources";
81                         break;
82                     case UNSPECIFIED:
83                         result += "Unspecified error";
84                         break;
85                     default:
86                         result += "Unknown error code: " + errorCode;
87                 }
88                 break;
89             default:
90                 result += "unknown error class: " + errorClass;
91         }
92         return result;
93     }
94
95     public NbtException( int errorClass, int errorCode ) {
96         super( getErrorString( errorClass, errorCode ));
97         this.errorClass = errorClass;
98         this.errorCode = errorCode;
99     }
100     public String JavaDoc toString() {
101         return new String JavaDoc( "errorClass=" + errorClass + ",errorCode=" + errorCode + ",errorString=" + getErrorString( errorClass, errorCode ));
102     }
103 }
104
Popular Tags