KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > server > ntfs > StreamInfoList


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.server.ntfs;
18
19 import java.util.Vector JavaDoc;
20
21 /**
22  * Stream Information List Class
23  */

24 public class StreamInfoList
25 {
26
27     // List of stream information objects
28

29     private Vector JavaDoc<StreamInfo> m_list;
30
31     /**
32      * Default constructor
33      */

34     public StreamInfoList()
35     {
36         m_list = new Vector JavaDoc<StreamInfo>();
37     }
38
39     /**
40      * Add an item to the list
41      *
42      * @param info StreamInfo
43      */

44     public final void addStream(StreamInfo info)
45     {
46         m_list.add(info);
47     }
48
49     /**
50      * Return the stream details at the specified index
51      *
52      * @param idx int
53      * @return StreamInfo
54      */

55     public final StreamInfo getStreamAt(int idx)
56     {
57
58         // Range check the index
59

60         if (idx < 0 || idx >= m_list.size())
61             return null;
62
63         // Return the required stream information
64

65         return m_list.get(idx);
66     }
67
68     /**
69      * Find a stream by name
70      *
71      * @param name String
72      * @return StreamInfo
73      */

74     public final StreamInfo findStream(String JavaDoc name)
75     {
76
77         // Search for the required stream
78

79         for (int i = 0; i < m_list.size(); i++)
80         {
81
82             // Get the current stream information
83

84             StreamInfo sinfo = m_list.get(i);
85
86             // Check if the stream name matches
87

88             if (sinfo.getName().equals(name))
89                 return sinfo;
90         }
91
92         // Stream not found
93

94         return null;
95     }
96
97     /**
98      * Return the count of streams in the list
99      *
100      * @return int
101      */

102     public final int numberOfStreams()
103     {
104         return m_list.size();
105     }
106
107     /**
108      * Remove the specified stream from the list
109      *
110      * @param idx int
111      * @return StreamInfo
112      */

113     public final StreamInfo removeStream(int idx)
114     {
115
116         // Range check the index
117

118         if (idx < 0 || idx >= m_list.size())
119             return null;
120
121         // Remove the required stream
122

123         return m_list.remove(idx);
124     }
125
126     /**
127      * Remove the specified stream from the list
128      *
129      * @param name String
130      * @return StreamInfo
131      */

132     public final StreamInfo removeStream(String JavaDoc name)
133     {
134
135         // Search for the required stream
136

137         for (int i = 0; i < m_list.size(); i++)
138         {
139
140             // Get the current stream information
141

142             StreamInfo sinfo = m_list.get(i);
143
144             // Check if the stream name matches
145

146             if (sinfo.getName().equals(name))
147             {
148
149                 // Remove the stream from the list
150

151                 m_list.removeElementAt(i);
152                 return sinfo;
153             }
154         }
155
156         // Stream not found
157

158         return null;
159     }
160
161     /**
162      * Remove all streams from the list
163      */

164     public final void removeAllStreams()
165     {
166         m_list.removeAllElements();
167     }
168 }
169
Popular Tags