01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * Initial developer(s): Guillaume SAUTHIER
22: * --------------------------------------------------------------------------
23: * $Id: DirURLFactory.java 4622 2004-04-19 13:49:54Z sauthieg $
24: * --------------------------------------------------------------------------
25: */package org.objectweb.jonas_lib.loader.factory;
26:
27: import java.net.URL;
28: import java.io.IOException;
29:
30: /**
31: * A <code>DirURLFactory</code> is used to create URLs
32: * from an URL (pointing to a directory) and paths.
33: * Example : <br/>
34: * base : <code>file:/path/</code><br/>
35: * path : <code>META-INF/directory/</code><br/>
36: * results : <code>file:/path/META-INF/directory/</code><br/>
37: *
38: * @author Guillaume Sauthier
39: */
40: public class DirURLFactory extends URLFactory {
41:
42: /** the base URL */
43: private URL base;
44:
45: /**
46: * Create a new DirURLFactory using the specified base URL.
47: *
48: * @param url the base url. (must be a directory)
49: */
50: public DirURLFactory(URL url) {
51: base = url;
52: }
53:
54: /**
55: * Returns a new URL basically adding path to the base URL.
56: *
57: * @param path the path to add to the URL. (must not start with "/")
58: *
59: * @return a new URL of the form <base><path>.
60: *
61: * @throws IOException when created URL is invalid.
62: */
63: public URL getURL(String path) throws IOException {
64: return new URL(base + path);
65: }
66:
67: }
|