KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > virtual > plugins > context > DelegatingHandler


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2006, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22
23 package org.jboss.virtual.plugins.context;
24
25 import java.io.IOException JavaDoc;
26 import java.io.InputStream JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
28 import java.net.URI JavaDoc;
29 import java.net.URISyntaxException JavaDoc;
30 import java.net.URL JavaDoc;
31 import java.util.List JavaDoc;
32
33 import org.jboss.virtual.spi.VFSContext;
34 import org.jboss.virtual.spi.VirtualFileHandler;
35
36 /**
37  * A delegating VirtualFileHandler that allows for overriding the delegate
38  * parent and name. One usecase is a link which roots another VFSContext
39  * under a different parent and name.
40  *
41  * @author Scott.Stark@jboss.org
42  * @version $Revision:$
43  */

44 public class DelegatingHandler extends AbstractVirtualFileHandler
45 {
46    /** Serialization */
47    private static final long serialVersionUID = 1;
48    
49    /** The delegate */
50    private VirtualFileHandler delegate;
51
52    /**
53     * Create a DelegatingHandler
54     *
55     * @param context - the context for the parent
56     * @param parent - the parent of the delegate in this VFS
57     * @param name - the name of the delegate in this VFS
58     * @param delegate - the handler delegate
59     */

60    public DelegatingHandler(VFSContext context, VirtualFileHandler parent, String JavaDoc name,
61          VirtualFileHandler delegate)
62    {
63       super(context, parent, name);
64       this.delegate = delegate;
65    }
66
67    public VirtualFileHandler findChild(String JavaDoc path) throws IOException JavaDoc
68    {
69       return delegate.findChild(path);
70    }
71
72    public List JavaDoc<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException JavaDoc
73    {
74       return delegate.getChildren(ignoreErrors);
75    }
76
77    public long getLastModified() throws IOException JavaDoc
78    {
79       return delegate.getLastModified();
80    }
81
82    public long getSize() throws IOException JavaDoc
83    {
84       return delegate.getSize();
85    }
86
87    public boolean isLeaf() throws IOException JavaDoc
88    {
89       return delegate.isLeaf();
90    }
91
92    public boolean isHidden() throws IOException JavaDoc
93    {
94       return delegate.isHidden();
95    }
96
97    public InputStream JavaDoc openStream() throws IOException JavaDoc
98    {
99       return delegate.openStream();
100    }
101
102    public URI JavaDoc toURI() throws URISyntaxException JavaDoc
103    {
104       return delegate.toURI();
105    }
106
107    public URL JavaDoc toURL() throws URISyntaxException JavaDoc, MalformedURLException JavaDoc
108    {
109       return delegate.toURL();
110    }
111 }
112
Popular Tags