KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > netbios > win32 > WinsockNetBIOSException


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.netbios.win32;
18
19 import java.io.IOException JavaDoc;
20
21 /**
22  * Winsock NetBIOS Exception Class
23  *
24  * <p>Contains the Winsock error code from the failed Winsock call.
25  *
26  * @author GKSpencer
27  */

28 public class WinsockNetBIOSException extends IOException JavaDoc
29 {
30     private static final long serialVersionUID = 5933702607108016674L;
31
32     // Winsock error code
33

34     private int m_errCode;
35
36     /**
37      * Default constructor
38      */

39     public WinsockNetBIOSException()
40     {
41         super();
42     }
43
44     /**
45      * Class constructor
46      *
47      * @param msg String
48      */

49     public WinsockNetBIOSException(String JavaDoc msg)
50     {
51         super(msg);
52         
53         // Split out the error code
54

55         if ( msg != null)
56         {
57             int pos = msg.indexOf(":");
58             if ( pos != -1)
59                 m_errCode = Integer.valueOf(msg.substring(0, pos));
60         }
61     }
62     
63     /**
64      * Class constructor
65      *
66      * @param sts int
67      */

68     public WinsockNetBIOSException(int sts)
69     {
70         super();
71         
72         m_errCode = sts;
73     }
74     
75     /**
76      * Return the Winsock error code
77      *
78      * @return int
79      */

80     public final int getErrorCode()
81     {
82         return m_errCode;
83     }
84     
85     /**
86      * Set the error code
87      *
88      * @param sts int
89      */

90     public final void setErrorCode(int sts)
91     {
92         m_errCode = sts;
93     }
94
95     /**
96      * Return the error message string
97      *
98      * @return String
99      */

100     public String JavaDoc getMessage()
101     {
102         StringBuilder JavaDoc msg = new StringBuilder JavaDoc();
103         
104         msg.append( super.getMessage());
105         String JavaDoc winsockErr = WinsockError.asString(getErrorCode());
106         if ( winsockErr != null)
107         {
108             msg.append(" - ");
109             msg.append(winsockErr);
110         }
111         
112         return msg.toString();
113     }
114 }
115
Popular Tags