KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > dcerpc > info > ServerInfo


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.smb.dcerpc.info;
18
19 import org.alfresco.filesys.smb.dcerpc.DCEBuffer;
20 import org.alfresco.filesys.smb.dcerpc.DCEBufferException;
21 import org.alfresco.filesys.smb.dcerpc.DCEReadable;
22 import org.alfresco.filesys.smb.dcerpc.DCEWriteable;
23
24 /**
25  * Server Information Class
26  */

27 public class ServerInfo implements DCEWriteable, DCEReadable
28 {
29
30     // Information levels supported
31

32     public static final int InfoLevel0 = 0;
33     public static final int InfoLevel1 = 1;
34     public static final int InfoLevel101 = 101;
35     public static final int InfoLevel102 = 102;
36
37     // Server platform ids
38

39     public final static int PLATFORM_OS2 = 400;
40     public final static int PLATFORM_NT = 500;
41
42     // Information level
43

44     private int m_infoLevel;
45
46     // Server information
47

48     private int m_platformId;
49     private String JavaDoc m_name;
50     private int m_verMajor;
51     private int m_verMinor;
52     private int m_srvType;
53     private String JavaDoc m_comment;
54
55     /**
56      * Default constructor
57      */

58     public ServerInfo()
59     {
60     }
61
62     /**
63      * Class constructor
64      *
65      * @param lev int
66      */

67     public ServerInfo(int lev)
68     {
69         m_infoLevel = lev;
70     }
71
72     /**
73      * Get the information level
74      *
75      * @return int
76      */

77     public final int getInformationLevel()
78     {
79         return m_infoLevel;
80     }
81
82     /**
83      * Get the server name
84      *
85      * @return String
86      */

87     public final String JavaDoc getServerName()
88     {
89         return m_name;
90     }
91
92     /**
93      * Get the server comment
94      *
95      * @return String
96      */

97     public final String JavaDoc getComment()
98     {
99         return m_comment;
100     }
101
102     /**
103      * Get the server platform id
104      *
105      * @return int
106      */

107     public final int getPlatformId()
108     {
109         return m_platformId;
110     }
111
112     /**
113      * Get the servev major version
114      *
115      * @return int
116      */

117     public final int getMajorVersion()
118     {
119         return m_verMajor;
120     }
121
122     /**
123      * Get the server minor version
124      *
125      * @return int
126      */

127     public final int getMinorVersion()
128     {
129         return m_verMinor;
130     }
131
132     /**
133      * Get the server type flags
134      *
135      * @return int
136      */

137     public final int getServerType()
138     {
139         return m_srvType;
140     }
141
142     /**
143      * Set the server name
144      *
145      * @param name String
146      */

147     public final void setServerName(String JavaDoc name)
148     {
149         m_name = name;
150     }
151
152     /**
153      * Set the server comment
154      *
155      * @param comment String
156      */

157     public final void setComment(String JavaDoc comment)
158     {
159         m_comment = comment;
160     }
161
162     /**
163      * Set the information level
164      *
165      * @param lev int
166      */

167     public final void setInformationLevel(int lev)
168     {
169         m_infoLevel = lev;
170     }
171
172     /**
173      * Set the server platform id
174      *
175      * @param id int
176      */

177     public final void setPlatformId(int id)
178     {
179         m_platformId = id;
180     }
181
182     /**
183      * Set the server type flags
184      *
185      * @param typ int
186      */

187     public final void setServerType(int typ)
188     {
189         m_srvType = typ;
190     }
191
192     /**
193      * Set the server version
194      *
195      * @param verMajor int
196      * @param verMinor int
197      */

198     public final void setVersion(int verMajor, int verMinor)
199     {
200         m_verMajor = verMajor;
201         m_verMinor = verMinor;
202     }
203
204     /**
205      * Clear the string values
206      */

207     protected final void clearStrings()
208     {
209
210         // Clear the string values
211

212         m_name = null;
213         m_comment = null;
214     }
215
216     /**
217      * Read the server information from the DCE/RPC buffer
218      *
219      * @param buf DCEBuffer
220      * @exception DCEBufferException
221      */

222     public void readObject(DCEBuffer buf) throws DCEBufferException
223     {
224
225         // Clear the string values
226

227         clearStrings();
228
229         // Read the server information details
230

231         m_infoLevel = buf.getInt();
232         buf.skipPointer();
233
234         // Unpack the server information
235

236         switch (getInformationLevel())
237         {
238
239         // Information level 0
240

241         case InfoLevel0:
242             if (buf.getPointer() != 0)
243                 m_name = buf.getString(DCEBuffer.ALIGN_INT);
244             break;
245
246         // Information level 101/1
247

248         case InfoLevel1:
249         case InfoLevel101:
250             m_platformId = buf.getInt();
251             buf.skipPointer();
252             m_verMajor = buf.getInt();
253             m_verMinor = buf.getInt();
254             m_srvType = buf.getInt();
255             buf.skipPointer();
256
257             m_name = buf.getString(DCEBuffer.ALIGN_INT);
258             m_comment = buf.getString();
259             break;
260
261         // Level 102
262

263         case InfoLevel102:
264             break;
265         }
266     }
267
268     /**
269      * Read the strings for this object from the DCE/RPC buffer
270      *
271      * @param buf DCEBuffer
272      * @exception DCEBufferException
273      */

274     public void readStrings(DCEBuffer buf) throws DCEBufferException
275     {
276
277         // Not required
278
}
279
280     /**
281      * Write a server information structure
282      *
283      * @param buf DCEBuffer
284      * @param strBuf DCEBuffer
285      */

286     public void writeObject(DCEBuffer buf, DCEBuffer strBuf)
287     {
288
289         // Output the server information structure
290

291         buf.putInt(getInformationLevel());
292         buf.putPointer(true);
293
294         // Output the required information level
295

296         switch (getInformationLevel())
297         {
298
299         // Information level 0
300

301         case InfoLevel0:
302             buf.putPointer(getServerName() != null);
303             if (getServerName() != null)
304                 strBuf.putString(getServerName(), DCEBuffer.ALIGN_INT, true);
305             break;
306
307         // Information level 101/1
308

309         case InfoLevel1:
310         case InfoLevel101:
311             buf.putInt(getPlatformId());
312             buf.putPointer(true);
313             buf.putInt(getMajorVersion());
314             buf.putInt(getMinorVersion());
315             buf.putInt(getServerType());
316             buf.putPointer(true);
317
318             strBuf.putString(getServerName(), DCEBuffer.ALIGN_INT, true);
319             strBuf.putString(getComment() != null ? getComment() : "", DCEBuffer.ALIGN_INT, true);
320             break;
321
322         // Level 102
323

324         case InfoLevel102:
325             break;
326         }
327     }
328
329     /**
330      * Return the server information as a string
331      *
332      * @return String
333      */

334     public String JavaDoc toString()
335     {
336         return "";
337     }
338 }
339
Popular Tags