KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > core > DeviceContext


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.server.core;
18
19 /**
20  * <p>
21  * The device context is passed to the methods of a device interface. Each shared device has a
22  * device interface and a device context associated with it. The device context allows a single
23  * device interface to be used for multiple shared devices.
24  */

25 public class DeviceContext
26 {
27
28     // Device name that the interface is associated with
29

30     private String JavaDoc m_devName;
31
32     // Flag to indicate if the device is available. Unavailable devices will not be listed by the
33
// various
34
// protocol servers.
35

36     private boolean m_available = true;
37
38     /**
39      * DeviceContext constructor.
40      */

41     public DeviceContext()
42     {
43         super();
44     }
45
46     /**
47      * DeviceContext constructor.
48      */

49     public DeviceContext(String JavaDoc devName)
50     {
51         m_devName = devName;
52     }
53
54     /**
55      * Return the device name.
56      *
57      * @return java.lang.String
58      */

59     public final String JavaDoc getDeviceName()
60     {
61         return m_devName;
62     }
63
64     /**
65      * Determine if the filesystem is available
66      *
67      * @return boolean
68      */

69     public final boolean isAvailable()
70     {
71         return m_available;
72     }
73
74     /**
75      * Set the filesystem as available, or not
76      *
77      * @param avail boolean
78      */

79     public final void setAvailable(boolean avail)
80     {
81         m_available = avail;
82     }
83
84     /**
85      * Set the device name.
86      *
87      * @param name java.lang.String
88      */

89     public final void setDeviceName(String JavaDoc name)
90     {
91         m_devName = name;
92     }
93
94     /**
95      * Close the device context, free any resources allocated by the context
96      */

97     public void CloseContext()
98     {
99     }
100
101     /**
102      * Return the context as a string
103      *
104      * @return String
105      */

106     public String JavaDoc toString()
107     {
108         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
109
110         str.append("[");
111         str.append(getDeviceName());
112         str.append("]");
113
114         return str.toString();
115     }
116 }
Popular Tags