Package com.sun.ts.lib.util.sec.misc

# Class URLClassPath

java.lang.Object
com.sun.ts.lib.util.sec.misc.URLClassPath

public class URLClassPath extends Object
This class is used to maintain a search path of URLs for loading classes and resources from both JAR files and directories.

Author:
  David Connelly

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `URLClassPath(URL[] urls)`
  `URLClassPath(URL[] urls, URLStreamHandlerFactory factory)`
  Creates a new URLClassPath for the given URLs.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addURL(URL url)`
  Appends the specified URL to the search path of directory and JAR file URLs from which to load classes and resources.
  `URL`
  `checkURL(URL url)`
  `URL`
  `findResource(String name, boolean check)`
  Finds the resource with the specified name on the URL search path or null if not found or security check fails.
  `Enumeration`
  `findResources(String name, boolean check)`
  Finds all resources on the URL search path with the given name.
  `Resource`
  `getResource(String name)`
  `Resource`
  `getResource(String name, boolean check)`
  Finds the first Resource on the URL search path which has the specified name.
  `Enumeration`
  `getResources(String name)`
  `Enumeration`
  `getResources(String name, boolean check)`
  Finds all resources on the URL search path with the given name.
  `URL[]`
  `getURLs()`
  Returns the original search path of URLs.
  `static URL[]`
  `pathToURLs(String path)`
  Convert class path specification into an array of file URLs.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### URLClassPath

    public URLClassPath(URL[] urls, URLStreamHandlerFactory factory)
    Creates a new URLClassPath for the given URLs. The URLs will be searched in the order specified for classes and resources. A URL ending with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file.
    Parameters:
      `urls` - the directory and JAR file URLs to search for classes and resources
      `factory` - the URLStreamHandlerFactory to use when creating new URLs

  - ### URLClassPath

    public URLClassPath(URL[] urls)

- ## Method Details

  - ### addURL

    public void addURL(URL url)
    Appends the specified URL to the search path of directory and JAR file URLs from which to load classes and resources.

  - ### getURLs

    public URL[] getURLs()
    Returns the original search path of URLs.

  - ### findResource

    public URL findResource(String name, boolean check)
    Finds the resource with the specified name on the URL search path or null if not found or security check fails.
    Parameters:
      `name` - the name of the resource
      `check` - whether to perform a security check
    Returns:
      a `URL` for the resource, or `null` if the resource could not be found.

  - ### getResource

    public Resource getResource(String name, boolean check)
    Finds the first Resource on the URL search path which has the specified name. Returns null if no Resource could be found.
    Parameters:
      `name` - the name of the Resource
      `check` - whether to perform a security check
    Returns:
      the Resource, or null if not found

  - ### findResources

    public Enumeration findResources(String name, boolean check)
    Finds all resources on the URL search path with the given name. Returns an enumeration of the URL objects.
    Parameters:
      `name` - the resource name
    Returns:
      an Enumeration of all the urls having the specified name

  - ### getResource

    public Resource getResource(String name)

  - ### getResources

    public Enumeration getResources(String name, boolean check)
    Finds all resources on the URL search path with the given name. Returns an enumeration of the Resource objects.
    Parameters:
      `name` - the resource name
    Returns:
      an Enumeration of all the resources having the specified name

  - ### getResources

    public Enumeration getResources(String name)

  - ### pathToURLs

    public static URL[] pathToURLs(String path)
    Convert class path specification into an array of file URLs. The path of the file is encoded before conversion into URL form so that reserved characters can safely appear in the path.

  - ### checkURL

    public URL checkURL(URL url)