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

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;

import org.jboss.virtual.plugins.context.AbstractVirtualFileHandler;
import org.jboss.virtual.spi.VirtualFileHandler;

/**
 * The assembled file handler.
 *
 * @author <a href="bill@jboss.com">Bill Burke</a>
 * @version $Revision: 1.1 $
 */
@Assembled
public class AssembledFileHandler extends AbstractVirtualFileHandler
{
   private VirtualFileHandler delegate;

   public AssembledFileHandler(AssembledContext context, AssembledDirectoryHandler parent, String name, VirtualFileHandler delegate) throws IOException
   {
      super(context, parent, name);
      if (delegate == null)
         throw new IllegalArgumentException("Null delegate");
      this.delegate = delegate;
      setVfsUrl(new URL("vfs", context.getName(), -1, getPathName(), new AssembledUrlStreamHandler(context)));
   }

   public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
   {
      throw new IOException("File cannot have children: " + this);
   }

   public VirtualFileHandler findChild(String path) throws IOException
   {
      throw new IOException("File cannot have children: " + this);
   }

   public URL toURL() throws MalformedURLException, URISyntaxException
   {
      return delegate.toURL();
   }

   public long getLastModified() throws IOException
   {
      return delegate.getLastModified();
   }

   public boolean hasBeenModified() throws IOException
   {
      return delegate.hasBeenModified();
   }

   public long getSize() throws IOException
   {
      return delegate.getSize();
   }

   public boolean exists() throws IOException
   {
      return delegate.exists();
   }

   public boolean isLeaf() throws IOException
   {
      return delegate.isLeaf();
   }

   public boolean isHidden() throws IOException
   {
      return delegate.isHidden();
   }

   public InputStream openStream() throws IOException
   {
      return delegate.openStream();
   }

   public URI toURI() throws URISyntaxException
   {
      return delegate.toURI();
   }
}

@@ -1091,136 +1091,8 @@
 n;%0D%0A
-import java.io.InputStream;%0D%0Aimport java.net.MalformedURLException;%0D%0Aimport java.net.URI;%0D%0Aimport java.net.URISyntaxException;%0D%0A
 impo
@@ -1176,35 +1176,26 @@
 context.
-AbstractVirtualFile
+Delegating
 Handler;
@@ -1289,16 +1289,76 @@
 r.%0D%0A *%0D%0A
+ * @author %3Ca href=%22ales.justin@jboss.com%22%3EAles Justin%3C/a%3E%0D%0A
  * @auth
@@ -1494,80 +1494,28 @@
 nds 
-AbstractVirtualFileHandler%0D%0A%7B%0D%0A   private VirtualFileHandler delegate;
+DelegatingHandler
 %0D%0A
+%7B
 %0D%0A  
@@ -1708,134 +1708,19 @@
 name
-);%0D%0A      if (delegate == null)%0D%0A         throw new IllegalArgumentException(%22Null delegate%22);%0D%0A      this.delegate = delegate
+, delegate)
 ;%0D%0A 
@@ -2164,927 +2164,8 @@
   %7D%0D
-%0A%0D%0A   public URL toURL() throws MalformedURLException, URISyntaxException%0D%0A   %7B%0D%0A      return delegate.toURL();%0D%0A   %7D%0D%0A%0D%0A   public long getLastModified() throws IOException%0D%0A   %7B%0D%0A      return delegate.getLastModified();%0D%0A   %7D%0D%0A%0D%0A   public boolean hasBeenModified() throws IOException%0D%0A   %7B%0D%0A      return delegate.hasBeenModified();%0D%0A   %7D%0D%0A%0D%0A   public long getSize() throws IOException%0D%0A   %7B%0D%0A      return delegate.getSize();%0D%0A   %7D%0D%0A%0D%0A   public boolean exists() throws IOException%0D%0A   %7B%0D%0A      return delegate.exists();%0D%0A   %7D%0D%0A%0D%0A   public boolean isLeaf() throws IOException%0D%0A   %7B%0D%0A      return delegate.isLeaf();%0D%0A   %7D%0D%0A%0D%0A   public boolean isHidden() throws IOException%0D%0A   %7B%0D%0A      return delegate.isHidden();%0D%0A   %7D%0D%0A%0D%0A   public InputStream openStream() throws IOException%0D%0A   %7B%0D%0A      return delegate.openStream();%0D%0A   %7D%0D%0A%0D%0A   public URI toURI() throws URISyntaxException%0D%0A   %7B%0D%0A      return delegate.toURI();%0D%0A   %7D%0D
 %0A%7D%0D%0A

Use delegating handler.