Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## gnu.xml.util
Class Resolver

    java.lang.Object
      |
      +--gnu.xml.util.Resolver

All Implemented Interfaces:
  java.lang.Cloneable, EntityResolver

public class Resolver
extends java.lang.Object
implements EntityResolver, java.lang.Cloneable

Utility implementation of a SAX resolver, which can be used to improve network utilization of SAX based XML components. It does this by supporting local caches of external entities. SAX parsers should use such local caches when possible.

FIXME: This needs to leverage a catalog facility.

Version:
  $Date: 2001/10/29 21:49:10 $

Constructor Summary
`Resolver(java.util.Dictionary dict)` Constructs a resolver which understands how to map PUBLIC identifiers to other URIs, typically for local copies of standard DTD components.

Method Summary
`static void` | `addDirectoryMapping(java.util.Dictionary table, java.lang.String[][] mappings, java.io.File directory)` Updates a dictionary used to map PUBLIC identifiers to file names, so that it uses the mappings in a specified directory.
`static java.lang.String` | `fileNameToURL(java.lang.String filename)` Provides the URL for a named file, without relying on the JDK 1.2 `File.toURL`() utility method.
`static java.lang.String` | `fileToURL(java.io.File f)` Provides the URL for a file, without relying on the JDK 1.2 `File.toURL`() utility method.
`static java.lang.String` | `getEncoding(java.lang.String contentType)` This parses most MIME content type strings that have charset=... encoding declarations to and returns the specified encoding.
`static java.lang.String` | `getURL(java.lang.String fileOrURL)` Returns a URL string.
`InputSource` | `resolveEntity(java.lang.String publicId, java.lang.String systemId)` Uses a local dictionary of public identifiers to resolve URIs, normally with the goal of minimizing network traffic or latencies.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Resolver

    public Resolver(java.util.Dictionary dict)

  Constructs a resolver which understands how to map PUBLIC identifiers to other URIs, typically for local copies of standard DTD components.
  Parameters:
    `dictionary` - maps PUBLIC identifiers to URIs. This is not copied; subsequent modifications will be reported through the resolution operations.

Method Detail

### addDirectoryMapping

    public static void addDirectoryMapping(java.util.Dictionary table,
                                           java.lang.String[][] mappings,
                                           java.io.File directory)
                                    throws java.io.IOException

  Updates a dictionary used to map PUBLIC identifiers to file names, so that it uses the mappings in a specified directory.
  Parameters:
    `mappings` - Array of string pairs, where the first member of each pair is a PUBLIC identifier and the second is the name of a file, relative to the specified directory.
    `directory` - File holding the specified files.

### fileNameToURL

    public static java.lang.String fileNameToURL(java.lang.String filename)
                                          throws java.io.IOException

  Provides the URL for a named file, without relying on the JDK 1.2 `File.toURL`() utility method.
  Parameters:
    `filename` - the file name to convert. Relative file names are resolved the way the JVM resolves them (current to the process-global current working directory).
  Throws:
    `java.io.IOException` - if the file does not exist

### fileToURL

    public static java.lang.String fileToURL(java.io.File f)
                                      throws java.io.IOException

  Provides the URL for a file, without relying on the JDK 1.2 `File.toURL`() utility method.
  Parameters:
    `f` - the file to convert. Relative file names are resolved the way the JVM resolves them (current to the process-global current working directory).
  Throws:
    `java.io.IOException` - if the file does not exist

### getURL

    public static java.lang.String getURL(java.lang.String fileOrURL)

  Returns a URL string. Note that if a malformed URL is provided, or the parameter names a nonexistent file, the resulting URL may be malformed.
  Parameters:
    `fileOrURL` - If this is the name of a file which exists, then its URL is returned. Otherwise the argument is returned.

### getEncoding

    public static java.lang.String getEncoding(java.lang.String contentType)

  This parses most MIME content type strings that have charset=... encoding declarations to and returns the specified encoding. This conforms to RFC 3023, and is useful when constructing InputSource objects from URLConnection objects or other objects using MIME content typing.
  Parameters:
    `contentType` - the MIME content type that will be parsed; must not be null.
  Returns:
    the appropriate encoding, or null if the content type is not text and there's no `charset=...` attribute

### resolveEntity

    public InputSource resolveEntity(java.lang.String publicId,
                                     java.lang.String systemId)
                              throws java.io.IOException,
                                     SAXException

  Uses a local dictionary of public identifiers to resolve URIs, normally with the goal of minimizing network traffic or latencies.
  Specified by:
    `resolveEntity` in interface `EntityResolver`
  Following copied from interface: `org.xml.sax.EntityResolver`
  Parameters:
    `publicId` - The public identifier of the external entity being referenced, or null if none was supplied.
    `systemId` - The system identifier of the external entity being referenced.
  Returns:
    An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.
  Throws:
    `SAXException` - Any SAX exception, possibly wrapping another exception.
    `java.io.IOException` - A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.
  See Also:
    `InputSource`

Overview | Package | Class | Use | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Source code is under GPL (with library exception) in the JAXP project at http://www.gnu.org/software/classpathx/jaxp
This documentation was derived from that source code on 2001-11-20.