// Path: src/main/java/com/pureperfect/ferret/ScanException.java
// public class ScanException extends RuntimeException
// {
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * The underlying cause.
// 	 * 
// 	 * @param cause
// 	 *            The underlying cause
// 	 */
// 	public ScanException(final Throwable cause)
// 	{
// 		super(cause);
// 	}
// }


import java.net.MalformedURLException;
import java.net.URL;
import javax.servlet.ServletContext;
import com.pureperfect.ferret.ScanException;
package com.pureperfect.ferret.vfs;




/**
 * An implementation of a lightweight Virtual File System (VFS) appropriate for
 * scanning in a WAR file / web application.
 * 
 * @author J. Chris Folsom
 * @version 1.0
 * @since 1.0
 * @see FileSystem
 */
public class WebFileSystem
{
	private static final WebFileSystem singleton = new WebFileSystem();

	private WebFileSystem()
	{
		// singleton
	}

	/**
	 * Get the appropriate virtual web resource.
	 * 
	 * @param parent
	 *            The parent directory
	 * 
	 * @param context
	 *            the servlet context for the application
	 * @param path
	 *            the path to the folder or file
	 * @return the appropriate virtual resource
	 */
	public PathElement getVirtualPath(WebDirectory parent,
			ServletContext context, String path)
	{
		// Directories
		if (isWebDirectory(context, path))
		{
			return new ImplWebDirectory(parent, context, path);
		}
		// Handle Archives as URLs
		else if (path.endsWith(".jar"))
		{
			try
			{
				final URL jar = context.getResource(path);

				return new ImplArchive(parent, jar);
			}
			catch (Throwable t)
			{
// Path: src/main/java/com/pureperfect/ferret/ScanException.java
// public class ScanException extends RuntimeException
// {
// 	private static final long serialVersionUID = 1L;
// 
// 	/**
// 	 * The underlying cause.
// 	 * 
// 	 * @param cause
// 	 *            The underlying cause
// 	 */
// 	public ScanException(final Throwable cause)
// 	{
// 		super(cause);
// 	}
// }


// Path: src/main/java/com/pureperfect/ferret/vfs/WebFileSystem.java
import java.net.MalformedURLException;
import java.net.URL;
import javax.servlet.ServletContext;
import com.pureperfect.ferret.ScanException;

package com.pureperfect.ferret.vfs;




/**
 * An implementation of a lightweight Virtual File System (VFS) appropriate for
 * scanning in a WAR file / web application.
 * 
 * @author J. Chris Folsom
 * @version 1.0
 * @since 1.0
 * @see FileSystem
 */
public class WebFileSystem
{
	private static final WebFileSystem singleton = new WebFileSystem();

	private WebFileSystem()
	{
		// singleton
	}

	/**
	 * Get the appropriate virtual web resource.
	 * 
	 * @param parent
	 *            The parent directory
	 * 
	 * @param context
	 *            the servlet context for the application
	 * @param path
	 *            the path to the folder or file
	 * @return the appropriate virtual resource
	 */
	public PathElement getVirtualPath(WebDirectory parent,
			ServletContext context, String path)
	{
		// Directories
		if (isWebDirectory(context, path))
		{
			return new ImplWebDirectory(parent, context, path);
		}
		// Handle Archives as URLs
		else if (path.endsWith(".jar"))
		{
			try
			{
				final URL jar = context.getResource(path);

				return new ImplArchive(parent, jar);
			}
			catch (Throwable t)
			{
				throw new ScanException(t);