KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > vfs > AbstractVFSProvider


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.vfs;
21
22 import java.util.Arrays JavaDoc;
23 import java.util.List JavaDoc;
24
25
26 /**
27  * Abstract implementation of a {@link VFSProvider}.
28  *
29  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
30  */

31 public abstract class AbstractVFSProvider implements VFSProvider {
32
33     private String JavaDoc bundle;
34     private String JavaDoc scheme;
35     private List JavaDoc<String JavaDoc> handle;
36     private boolean fireEvents;
37     private boolean hiddenFilesSupported;
38     private int hostRequirement, portRequirement, userInfoRequirement, pathRequirement;
39     private Class JavaDoc storeClass;
40     
41     /**
42      * Constructor for providers that only handle stores with scheme
43      * specified, do not fire events and support hidden files and do not support host, port
44      * or userinfo
45      *
46      * @param scheme
47      * @param storeClass
48      * @param bundle bundle
49      */

50     public AbstractVFSProvider(String JavaDoc scheme, Class JavaDoc storeClass, String JavaDoc bundle) {
51         this(scheme, false, true, ELEMENT_NOT_APPLICABLE, ELEMENT_NOT_APPLICABLE, ELEMENT_NOT_APPLICABLE, ELEMENT_REQUIRED, storeClass, bundle);
52     }
53
54     /**
55      * Constructor.
56      *
57      * @param scheme scheme
58      * @param fireEvents fire events
59      * @param hiddenFilesSupported hidden files supported
60      * @param hostRequirement host requirement
61      * @param portRequirement port requirement
62      * @param userInfoRequirement user info requirement
63      * @param pathRequirement path requirement
64      * @param storeClass store class
65      * @param bundle bundle
66      */

67     public AbstractVFSProvider(String JavaDoc scheme, boolean fireEvents, boolean hiddenFilesSupported, int hostRequirement, int portRequirement, int userInfoRequirement, int pathRequirement, Class JavaDoc storeClass, String JavaDoc bundle) {
68         this(scheme, Arrays.asList(new String JavaDoc[] { scheme }), fireEvents, hiddenFilesSupported, hostRequirement, portRequirement, userInfoRequirement, pathRequirement, storeClass, bundle);
69     }
70
71     /**
72      * Constructor.
73      *
74      * @param scheme scheme
75      * @param handle handle
76      * @param fireEvents fire events
77      * @param hiddenFilesSupported hidden files supported
78      * @param hostRequirement host requirement
79      * @param portRequirement port requirement
80      * @param userInfoRequirement user info requirement
81      * @param pathRequirement path requirement
82      * @param storeClass store class
83      * @param bundle bundle
84      */

85     public AbstractVFSProvider(String JavaDoc scheme, List JavaDoc<String JavaDoc> handle, boolean fireEvents, boolean hiddenFilesSupported, int hostRequirement, int portRequirement, int userInfoRequirement, int pathRequirement, Class JavaDoc storeClass, String JavaDoc bundle) {
86         super();
87         this.scheme = scheme;
88         this.handle = handle;
89         this.fireEvents = fireEvents;
90         this.hiddenFilesSupported = hiddenFilesSupported;
91         this.hostRequirement = hostRequirement;
92         this.portRequirement = portRequirement;
93         this.userInfoRequirement = userInfoRequirement;
94         this.pathRequirement = pathRequirement;
95         this.storeClass = storeClass;
96         this.bundle = bundle;
97     }
98     
99     /* (non-Javadoc)
100      * @see com.sslexplorer.vfs.VFSProvider#getBundle()
101      */

102     public String JavaDoc getBundle() {
103         return bundle;
104     }
105
106     /* (non-Javadoc)
107      * @see com.sslexplorer.vfs.VFSProvider#getScheme()
108      */

109     public String JavaDoc getScheme() {
110         return scheme;
111     }
112
113     /* (non-Javadoc)
114      * @see com.sslexplorer.vfs.VFSProvider#getStoreClass()
115      */

116     public Class JavaDoc getStoreClass() {
117         return storeClass;
118     }
119
120     /* (non-Javadoc)
121      * @see com.sslexplorer.vfs.VFSProvider#isFireEvents()
122      */

123     public boolean isFireEvents() {
124         return fireEvents;
125     }
126
127     /* (non-Javadoc)
128      * @see com.sslexplorer.vfs.VFSProvider#isHiddenFilesSupported()
129      */

130     public boolean isHiddenFilesSupported() {
131         return hiddenFilesSupported;
132     }
133
134     /* (non-Javadoc)
135      * @see com.sslexplorer.vfs.VFSProvider#isRequiredHost()
136      */

137     public int getHostRequirement() {
138         return hostRequirement;
139     }
140
141     /* (non-Javadoc)
142      * @see com.sslexplorer.vfs.VFSProvider#isRequiredPort()
143      */

144     public int getPortRequirement() {
145         return portRequirement;
146     }
147
148     /* (non-Javadoc)
149      * @see com.sslexplorer.vfs.VFSProvider#isRequiredUserInfo()
150      */

151     public int getUserInfoRequirement() {
152         return userInfoRequirement;
153     }
154
155     /* (non-Javadoc)
156      * @see com.sslexplorer.vfs.VFSProvider#willHandle(java.lang.String)
157      */

158     public boolean willHandle(String JavaDoc scheme) {
159         return handle.contains(scheme);
160     }
161
162     /* (non-Javadoc)
163      * @see com.sslexplorer.vfs.VFSProvider#getPathRequirement()
164      */

165     public int getPathRequirement() {
166         return pathRequirement;
167     }
168
169     /* (non-Javadoc)
170      * @see java.lang.Comparable#compareTo(java.lang.Object)
171      */

172     public int compareTo(VFSProvider o) {
173         return getScheme().compareTo(o.getScheme());
174     }
175
176 }
177
Popular Tags