KickJava   Java API By Example, From Geeks To Geeks.

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


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.DCEWriteable;
21
22 /**
23  * Workstation Information Class
24  */

25 public class WorkstationInfo implements DCEWriteable
26 {
27
28     // Supported information levels
29

30     public static final int InfoLevel100 = 100;
31
32     // Information level
33

34     private int m_infoLevel;
35
36     // Server information
37

38     private int m_platformId;
39     private String JavaDoc m_name;
40     private String JavaDoc m_domain;
41     private int m_verMajor;
42     private int m_verMinor;
43
44     private String JavaDoc m_userName;
45     private String JavaDoc m_logonDomain;
46     private String JavaDoc m_otherDomain;
47
48     /**
49      * Default constructor
50      */

51     public WorkstationInfo()
52     {
53     }
54
55     /**
56      * Class constructor
57      *
58      * @param lev int
59      */

60     public WorkstationInfo(int lev)
61     {
62         m_infoLevel = lev;
63     }
64
65     /**
66      * Get the information level
67      *
68      * @return int
69      */

70     public final int getInformationLevel()
71     {
72         return m_infoLevel;
73     }
74
75     /**
76      * Get the workstation name
77      *
78      * @return String
79      */

80     public final String JavaDoc getWorkstationName()
81     {
82         return m_name;
83     }
84
85     /**
86      * Get the domain/workgroup
87      *
88      * @return String
89      */

90     public final String JavaDoc getDomain()
91     {
92         return m_domain;
93     }
94
95     /**
96      * Get the workstation platform id
97      *
98      * @return int
99      */

100     public final int getPlatformId()
101     {
102         return m_platformId;
103     }
104
105     /**
106      * Get the workstation major version
107      *
108      * @return int
109      */

110     public final int getMajorVersion()
111     {
112         return m_verMajor;
113     }
114
115     /**
116      * Get the workstation minor version
117      *
118      * @return int
119      */

120     public final int getMinorVersion()
121     {
122         return m_verMinor;
123     }
124
125     /**
126      * Reutrn the user name
127      *
128      * @return String
129      */

130     public final String JavaDoc getUserName()
131     {
132         return m_userName;
133     }
134
135     /**
136      * Return the workstations logon domain.
137      *
138      * @return java.lang.String
139      */

140     public String JavaDoc getLogonDomain()
141     {
142         return m_logonDomain;
143     }
144
145     /**
146      * Return the list of domains that the workstation is enlisted in.
147      *
148      * @return java.lang.String
149      */

150     public String JavaDoc getOtherDomains()
151     {
152         return m_otherDomain;
153     }
154
155     /**
156      * Set the logon domain name.
157      *
158      * @param logdom java.lang.String
159      */

160     public void setLogonDomain(String JavaDoc logdom)
161     {
162         m_logonDomain = logdom;
163     }
164
165     /**
166      * Set the other domains that this workstation is enlisted in.
167      *
168      * @param othdom java.lang.String
169      */

170     public void setOtherDomains(String JavaDoc othdom)
171     {
172         m_otherDomain = othdom;
173     }
174
175     /**
176      * Set the workstation name
177      *
178      * @param name String
179      */

180     public final void setWorkstationName(String JavaDoc name)
181     {
182         m_name = name;
183     }
184
185     /**
186      * Set the domain/workgroup
187      *
188      * @param domain String
189      */

190     public final void setDomain(String JavaDoc domain)
191     {
192         m_domain = domain;
193     }
194
195     /**
196      * Set the information level
197      *
198      * @param lev int
199      */

200     public final void setInformationLevel(int lev)
201     {
202         m_infoLevel = lev;
203     }
204
205     /**
206      * Set the platform id
207      *
208      * @param id int
209      */

210     public final void setPlatformId(int id)
211     {
212         m_platformId = id;
213     }
214
215     /**
216      * Set the version
217      *
218      * @param verMajor int
219      * @param verMinor int
220      */

221     public final void setVersion(int verMajor, int verMinor)
222     {
223         m_verMajor = verMajor;
224         m_verMinor = verMinor;
225     }
226
227     /**
228      * Set the logged in user name
229      *
230      * @param user String
231      */

232     public final void setUserName(String JavaDoc user)
233     {
234         m_userName = user;
235     }
236
237     /**
238      * Clear the string values
239      */

240     protected final void clearStrings()
241     {
242
243         // Clear the string values
244

245         m_userName = null;
246         m_domain = null;
247         m_logonDomain = null;
248         m_otherDomain = null;
249     }
250
251     /**
252      * Write a workstation information structure
253      *
254      * @param buf DCEBuffer
255      * @param strBuf DCEBuffer
256      */

257     public void writeObject(DCEBuffer buf, DCEBuffer strBuf)
258     {
259
260         // Output the workstation information structure
261

262         buf.putInt(getInformationLevel());
263         buf.putPointer(true);
264
265         // Output the required information level
266

267         switch (getInformationLevel())
268         {
269
270         // Level 100
271

272         case InfoLevel100:
273             buf.putInt(getPlatformId());
274             buf.putPointer(true);
275             buf.putPointer(true);
276             buf.putInt(getMajorVersion());
277             buf.putInt(getMinorVersion());
278
279             strBuf.putString(getWorkstationName(), DCEBuffer.ALIGN_INT, true);
280             strBuf.putString(getDomain() != null ? getDomain() : "", DCEBuffer.ALIGN_INT, true);
281             break;
282
283         // Level 101
284

285         case 101:
286             break;
287
288         // Level 102
289

290         case 102:
291             break;
292         }
293     }
294
295     /**
296      * Return the workstation information as a string
297      *
298      * @return String
299      */

300     public String JavaDoc toString()
301     {
302         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
303         str.append("[");
304
305         str.append(getWorkstationName());
306         str.append(":Domain=");
307         str.append(getDomain());
308         str.append(":User=");
309         str.append(getUserName());
310         str.append(":Id=");
311         str.append(getPlatformId());
312
313         str.append(":v");
314         str.append(getMajorVersion());
315         str.append(".");
316         str.append(getMinorVersion());
317
318         // Optional strings
319

320         if (getLogonDomain() != null)
321         {
322             str.append(":Logon=");
323             str.append(getLogonDomain());
324         }
325
326         if (getOtherDomains() != null)
327         {
328             str.append(":Other=");
329             str.append(getOtherDomains());
330         }
331
332         // Return the workstation information as a string
333

334         str.append("]");
335         return str.toString();
336     }
337 }
338
Popular Tags