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

## com.hp.hpl.jena.util
Class FileManager

    java.lang.Object
      com.hp.hpl.jena.util.FileManager

    public class FileManager

extends java.lang.Object

FileManager A FileManager provides access to named file-like resources by opening InputStreams to things in the filing system, by URL (http: and file:) and found by the classloader. It can also load RDF data from such a system resource into an existing model or create a new (Memory-based) model. There is a global FileManager which provide uniform access to system resources: applications may also create specialised FileManagers. A FileManager contains a list of location functions to try: the global FileManger has one `LocatorFile`, one `LocatorClassLoader` and one `LocatorURL` Main operations: *

- loadModel, readModel : URI to model
- open, openNoMap : URI to input stream
- mapURI : map URI to another by `LocationMapper`

Utilities:

- readWholeFileAsUTF8
- optional caching of models

A FileManager works in conjunction with a LocationMapper. A `LocationMapper` is a set of alternative locations for system resources and a set of alternative prefix locations. For example, a local copy of a common RDF dataset may be used whenever the usual URL is used by the application. The `LocatorFile` also supports the idea of "current directory".

Version:
  $Id: FileManager.java,v 1.41 2008/01/02 12:07:44 andy_seaborne Exp $
Author:
  Andy Seaborne
See Also:
  `LocationMapper`, `FileUtils`

Field Summary
`static java.lang.String` | `filePathSeparator`
`static java.lang.String` | `PATH_DELIMITER` Delimiter between path entries : because URI scheme names use : we only allow ;

Constructor Summary
`FileManager()` Create an uninitialized FileManager
`FileManager(FileManager filemanager)` Create a new file manager that is a deep copy another.
`FileManager(LocationMapper _mapper)` Create with the given location mapper

Method Summary
`void` | `addCacheModel(java.lang.String uri, Model m)`
`void` | `addLocator(Locator loc)` Add a locator to the end of the locators list
`void` | `addLocatorClassLoader(java.lang.ClassLoader cLoad)` Add a class loader locator
`void` | `addLocatorFile()` Add a file locator
`void` | `addLocatorFile(java.lang.String dir)` Add a file locator which uses dir as its working directory
`void` | `addLocatorURL()` Add a URL locator
`void` | `addLocatorZip(java.lang.String zfn)` Add a zip file locator
`static FileManager` | `get()` Get the global file manager.
`boolean` | `getCachingModels()` return whether caching is on of off
`Model` | `getFromCache(java.lang.String filenameOrURI)` Read out of the cache - return null if not in the cache
`LocationMapper` | `getLocationMapper()` Get the location mapping
`boolean` | `hasCachedModel(java.lang.String filenameOrURI)`
`Model` | `loadModel(java.lang.String filenameOrURI)` Load a model from a file (local or remote).
`Model` | `loadModel(java.lang.String filenameOrURI, java.lang.String rdfSyntax)` Load a model from a file (local or remote).
`Model` | `loadModel(java.lang.String filenameOrURI, java.lang.String baseURI, java.lang.String rdfSyntax)` Load a model from a file (local or remote).
`java.util.Iterator` | `locators()` Return an iterator over all the handlers
`static FileManager` | `makeGlobal()` Create a "standard" FileManager.
`java.lang.String` | `mapURI(java.lang.String filenameOrURI)` Apply the mapping of a filename or URI
`java.io.InputStream` | `open(java.lang.String filenameOrURI)` Open a file using the locators of this FileManager
`java.io.InputStream` | `openNoMap(java.lang.String filenameOrURI)` Open a file using the locators of this FileManager but without location mapping
`TypedStream` | `openNoMapOrNull(java.lang.String filenameOrURI)` Open a file using the locators of this FileManager but without location mapping.
`Model` | `readModel(Model model, java.lang.String filenameOrURI)` Read a file of RDF into a model.
`Model` | `readModel(Model model, java.lang.String filenameOrURI, java.lang.String rdfSyntax)` Read a file of RDF into a model.
`Model` | `readModel(Model model, java.lang.String filenameOrURI, java.lang.String baseURI, java.lang.String syntax)` Read a file of RDF into a model.
`java.lang.String` | `readWholeFileAsUTF8(java.io.InputStream in)` Slurp up a whole file
`java.lang.String` | `readWholeFileAsUTF8(java.lang.String filename)` Slurp up a whole file: map filename as necessary
`java.lang.String` | `remap(java.lang.String filenameOrURI)` Deprecated. Use mapURI
`void` | `remove(Locator loc)` Remove a locator
`void` | `removeCacheModel(java.lang.String uri)`
`void` | `resetCache()` Reset the model cache
`static void` | `setGlobalFileManager(FileManager globalFileManager)` Set the global file manager (as returned by get()) If called before any call to get(), then the usual default filemanager is not created
`void` | `setLocationMapper(LocationMapper _mapper)` Set the location mapping
`void` | `setMapper(LocationMapper _mapper)` Deprecated. Use setLocationMapper
`void` | `setModelCaching(boolean state)` Change the state of model cache : does not clear the cache
`static void` | `setStdLocators(FileManager fMgr)` Force a file handler to have the default configuration.

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

Field Detail

### PATH_DELIMITER

    public static final java.lang.String PATH_DELIMITER

  Delimiter between path entries : because URI scheme names use : we only allow ;

  See Also:
    Constant Field Values

### filePathSeparator

    public static final java.lang.String filePathSeparator

Constructor Detail

### FileManager

    public FileManager()

  Create an uninitialized FileManager

### FileManager

    public FileManager(FileManager filemanager)

  Create a new file manager that is a deep copy another. Location mapper and locators chain are copied (the locators are not cloned). The model cache is not copied and is initially set to not cache.

  Parameters:
    `filemanager` -

### FileManager

    public FileManager(LocationMapper _mapper)

  Create with the given location mapper

Method Detail

### get

    public static FileManager get()

  Get the global file manager.

  Returns:
    the global file manager

### setGlobalFileManager

    public static void setGlobalFileManager(FileManager globalFileManager)

  Set the global file manager (as returned by get()) If called before any call to get(), then the usual default filemanager is not created

  Parameters:
    `globalFileManager` -

### makeGlobal

    public static FileManager makeGlobal()

  Create a "standard" FileManager.

### setStdLocators

    public static void setStdLocators(FileManager fMgr)

  Force a file handler to have the default configuration.

### setMapper

    public void setMapper(LocationMapper _mapper)

  Deprecated. Use setLocationMapper

### setLocationMapper

    public void setLocationMapper(LocationMapper _mapper)

  Set the location mapping

### getLocationMapper

    public LocationMapper getLocationMapper()

  Get the location mapping

### locators

    public java.util.Iterator locators()

  Return an iterator over all the handlers

### addLocator

    public void addLocator(Locator loc)

  Add a locator to the end of the locators list

### addLocatorFile

    public void addLocatorFile()

  Add a file locator

### addLocatorFile

    public void addLocatorFile(java.lang.String dir)

  Add a file locator which uses dir as its working directory

### addLocatorClassLoader

    public void addLocatorClassLoader(java.lang.ClassLoader cLoad)

  Add a class loader locator

### addLocatorURL

    public void addLocatorURL()

  Add a URL locator

### addLocatorZip

    public void addLocatorZip(java.lang.String zfn)

  Add a zip file locator

### remove

    public void remove(Locator loc)

  Remove a locator

### resetCache

    public void resetCache()

  Reset the model cache

### setModelCaching

    public void setModelCaching(boolean state)

  Change the state of model cache : does not clear the cache

### getCachingModels

    public boolean getCachingModels()

  return whether caching is on of off

### getFromCache

    public Model getFromCache(java.lang.String filenameOrURI)

  Read out of the cache - return null if not in the cache

### hasCachedModel

    public boolean hasCachedModel(java.lang.String filenameOrURI)

### addCacheModel

    public void addCacheModel(java.lang.String uri,
                              Model m)

### removeCacheModel

    public void removeCacheModel(java.lang.String uri)

### loadModel

    public Model loadModel(java.lang.String filenameOrURI)

  Load a model from a file (local or remote). Guesses the syntax of the file based on filename extension, defaulting to RDF/XML.

  Parameters:
    `filenameOrURI` - The filename or a URI (file:, http:)
  Returns:
    a new model
  Throws:
    `JenaException` - if there is syntax error in file.

### loadModel

    public Model loadModel(java.lang.String filenameOrURI,
                           java.lang.String rdfSyntax)

  Load a model from a file (local or remote). URI is the base for reading the model.

  Parameters:
    `filenameOrURI` - The filename or a URI (file:, http:)
    `rdfSyntax` - RDF Serialization syntax.
  Returns:
    a new model
  Throws:
    `JenaException` - if there is syntax error in file.

### loadModel

    public Model loadModel(java.lang.String filenameOrURI,
                           java.lang.String baseURI,
                           java.lang.String rdfSyntax)

  Load a model from a file (local or remote).

  Parameters:
    `filenameOrURI` - The filename or a URI (file:, http:)
    `baseURI` - Base URI for loading the RDF model.
    `rdfSyntax` - RDF Serialization syntax.
  Returns:
    a new model
  Throws:
    `JenaException` - if there is syntax error in file.

### readModel

    public Model readModel(Model model,
                           java.lang.String filenameOrURI)

  Read a file of RDF into a model.

  Parameters:
    `model` -
    `filenameOrURI` -
  Returns:
    The model or null, if there was an error.
  Throws:
    `JenaException` - if there is syntax error in file.

### readModel

    public Model readModel(Model model,
                           java.lang.String filenameOrURI,
                           java.lang.String rdfSyntax)

  Read a file of RDF into a model.

  Parameters:
    `model` -
    `filenameOrURI` -
    `rdfSyntax` - RDF Serialization syntax.
  Returns:
    The model or null, if there was an error.
  Throws:
    `JenaException` - if there is syntax error in file.

### readModel

    public Model readModel(Model model,
                           java.lang.String filenameOrURI,
                           java.lang.String baseURI,
                           java.lang.String syntax)

  Read a file of RDF into a model.

  Parameters:
    `model` -
    `filenameOrURI` -
    `baseURI` -
    `syntax` -
  Returns:
    The model
  Throws:
    `JenaException` - if there is syntax error in file.

### open

    public java.io.InputStream open(java.lang.String filenameOrURI)

  Open a file using the locators of this FileManager

### remap

    public java.lang.String remap(java.lang.String filenameOrURI)

  Deprecated. Use mapURI

### mapURI

    public java.lang.String mapURI(java.lang.String filenameOrURI)

  Apply the mapping of a filename or URI

### readWholeFileAsUTF8

    public java.lang.String readWholeFileAsUTF8(java.io.InputStream in)

  Slurp up a whole file

### readWholeFileAsUTF8

    public java.lang.String readWholeFileAsUTF8(java.lang.String filename)

  Slurp up a whole file: map filename as necessary

### openNoMap

    public java.io.InputStream openNoMap(java.lang.String filenameOrURI)

  Open a file using the locators of this FileManager but without location mapping

### openNoMapOrNull

    public TypedStream openNoMapOrNull(java.lang.String filenameOrURI)

  Open a file using the locators of this FileManager but without location mapping. Return null if not found

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

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP