Package javassist

# Class URLClassPath

java.lang.Object
javassist.URLClassPath

All Implemented Interfaces:
  `ClassPath`

public class URLClassPath extends Object implements ClassPath
A class search-path specified with URL (http).

See Also:
  - `ClassPath`
  - `ClassPool.insertClassPath(ClassPath)`
  - `ClassPool.appendClassPath(ClassPath)`

## Constructor Summary

Constructors
Constructor
Description
`URLClassPath(String host, int port, String directory, String packageName)`
Creates a search path specified with URL (http).

## Method Summary

Modifier and Type
Method
Description
`static byte[]`
`fetchClass(String host, int port, String directory, String classname)`
Reads a class file on an http server.
`URL`
`find(String classname)`
Returns the URL.
`InputStream`
`openClassfile(String classname)`
Opens a class file with http.
`String`
`toString()`

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

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### URLClassPath

public URLClassPath(String host, int port, String directory, String packageName)
Creates a search path specified with URL (http).

This search path is used only if a requested class name starts with the name specified by `packageName`. If `packageName` is "org.javassist." and a requested class is "org.javassist.test.Main", then the given URL is used for loading that class. The `URLClassPath` obtains a class file from:

    http://www.javassist.org:80/java/classes/org/javassist/test/Main.class

Here, we assume that `host` is "www.javassist.org", `port` is 80, and `directory` is "/java/classes/".

If `packageName` is `null`, the URL is used for loading any class.

Parameters:
  `host` - host name
  `port` - port number
  `directory` - directory name ending with "/". It can be "/" (root directory). It must start with "/".
  `packageName` - package name. It must end with "." (dot).

## Method Details

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### openClassfile

public InputStream openClassfile(String classname)
Opens a class file with http.

Specified by:
  `openClassfile` in interface `ClassPath`
Parameters:
  `classname` - a fully-qualified class name
Returns:
  null if the class file could not be found.
See Also:
  - `Translator`

### find

public URL find(String classname)
Returns the URL.

Specified by:
  `find` in interface `ClassPath`
Parameters:
  `classname` - a fully-qualified class name.
Returns:
  null if the class file could not be obtained.

### fetchClass

public static byte[] fetchClass(String host, int port, String directory, String classname) throws IOException
Reads a class file on an http server.

Parameters:
  `host` - host name
  `port` - port number
  `directory` - directory name ending with "/". It can be "/" (root directory). It must start with "/".
  `classname` - fully-qualified class name
Throws:
  `IOException`