| java.lang.Object com.hp.hpl.jena.util.FileManager
FileManager | public class FileManager (Code) | | 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".
See Also: LocationMapper See Also: FileUtils author: Andy Seaborne version: $Id: FileManager.java,v 1.41 2008/01/02 12:07:44 andy_seaborne Exp $ |
Method Summary | |
public void | addCacheModel(String uri, Model m) | public void | addLocator(Locator loc) | public void | addLocatorClassLoader(ClassLoader cLoad) | public void | addLocatorFile() | public void | addLocatorFile(String dir) | public void | addLocatorURL() | public void | addLocatorZip(String zfn) | public static FileManager | get() Get the global file manager. | public boolean | getCachingModels() | public Model | getFromCache(String filenameOrURI) | public LocationMapper | getLocationMapper() | public boolean | hasCachedModel(String filenameOrURI) | public Model | loadModel(String filenameOrURI) Load a model from a file (local or remote). | public Model | loadModel(String filenameOrURI, 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:) Parameters: rdfSyntax - RDF Serialization syntax. | public Model | loadModel(String filenameOrURI, String baseURI, String rdfSyntax) Load a model from a file (local or remote).
Parameters: filenameOrURI - The filename or a URI (file:, http:) Parameters: baseURI - Base URI for loading the RDF model. Parameters: rdfSyntax - RDF Serialization syntax. | public Iterator | locators() | public static FileManager | makeGlobal() Create a "standard" FileManager. | public String | mapURI(String filenameOrURI) | public InputStream | open(String filenameOrURI) | public InputStream | openNoMap(String filenameOrURI) | public TypedStream | openNoMapOrNull(String filenameOrURI) Open a file using the locators of this FileManager
but without location mapping. | public Model | readModel(Model model, String filenameOrURI) Read a file of RDF into a model. | public Model | readModel(Model model, String filenameOrURI, String rdfSyntax) Read a file of RDF into a model.
Parameters: model - Parameters: filenameOrURI - Parameters: rdfSyntax - RDF Serialization syntax. | public Model | readModel(Model model, String filenameOrURI, String baseURI, String syntax) Read a file of RDF into a model. | public String | readWholeFileAsUTF8(InputStream in) | public String | readWholeFileAsUTF8(String filename) | public String | remap(String filenameOrURI) | public void | remove(Locator loc) | public void | removeCacheModel(String uri) | public void | resetCache() | public static void | setGlobalFileManager(FileManager globalFileManager) | public void | setLocationMapper(LocationMapper _mapper) | public void | setMapper(LocationMapper _mapper) | public void | setModelCaching(boolean state) | public static void | setStdLocators(FileManager fMgr) Force a file handler to have the default configuration. |
PATH_DELIMITER | final public static String PATH_DELIMITER(Code) | | Delimiter between path entries : because URI scheme names use : we only allow ;
|
cacheModelLoads | boolean cacheModelLoads(Code) | | |
filePathSeparator | final public static String filePathSeparator(Code) | | |
logAllLookups | static boolean logAllLookups(Code) | | |
modelCache | ModelCache modelCache(Code) | | |
FileManager | public FileManager()(Code) | | Create an uninitialized FileManager
|
FileManager | public FileManager(FileManager filemanager)(Code) | | 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 - |
addLocator | public void addLocator(Locator loc)(Code) | | Add a locator to the end of the locators list
|
addLocatorClassLoader | public void addLocatorClassLoader(ClassLoader cLoad)(Code) | | Add a class loader locator
|
addLocatorFile | public void addLocatorFile()(Code) | | Add a file locator
|
addLocatorFile | public void addLocatorFile(String dir)(Code) | | Add a file locator which uses dir as its working directory
|
addLocatorURL | public void addLocatorURL()(Code) | | Add a URL locator
|
addLocatorZip | public void addLocatorZip(String zfn)(Code) | | Add a zip file locator
|
get | public static FileManager get()(Code) | | Get the global file manager.
the global file manager |
getCachingModels | public boolean getCachingModels()(Code) | | return whether caching is on of off
|
getFromCache | public Model getFromCache(String filenameOrURI)(Code) | | Read out of the cache - return null if not in the cache
|
hasCachedModel | public boolean hasCachedModel(String filenameOrURI)(Code) | | |
loadModel | public Model loadModel(String filenameOrURI)(Code) | | 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:) a new model exception: JenaException - if there is syntax error in file. |
loadModel | public Model loadModel(String filenameOrURI, String rdfSyntax)(Code) | | 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:) Parameters: rdfSyntax - RDF Serialization syntax. a new model exception: JenaException - if there is syntax error in file. |
loadModel | public Model loadModel(String filenameOrURI, String baseURI, String rdfSyntax)(Code) | | Load a model from a file (local or remote).
Parameters: filenameOrURI - The filename or a URI (file:, http:) Parameters: baseURI - Base URI for loading the RDF model. Parameters: rdfSyntax - RDF Serialization syntax. a new model exception: JenaException - if there is syntax error in file. |
locators | public Iterator locators()(Code) | | Return an iterator over all the handlers
|
makeGlobal | public static FileManager makeGlobal()(Code) | | Create a "standard" FileManager.
|
mapURI | public String mapURI(String filenameOrURI)(Code) | | Apply the mapping of a filename or URI
|
openNoMap | public InputStream openNoMap(String filenameOrURI)(Code) | | Open a file using the locators of this FileManager
but without location mapping
|
openNoMapOrNull | public TypedStream openNoMapOrNull(String filenameOrURI)(Code) | | Open a file using the locators of this FileManager
but without location mapping.
Return null if not found
|
readModel | public Model readModel(Model model, String filenameOrURI)(Code) | | Read a file of RDF into a model.
Parameters: model - Parameters: filenameOrURI - The model or null, if there was an error. exception: JenaException - if there is syntax error in file. |
readModel | public Model readModel(Model model, String filenameOrURI, String rdfSyntax)(Code) | | Read a file of RDF into a model.
Parameters: model - Parameters: filenameOrURI - Parameters: rdfSyntax - RDF Serialization syntax. The model or null, if there was an error. exception: JenaException - if there is syntax error in file. |
readModel | public Model readModel(Model model, String filenameOrURI, String baseURI, String syntax)(Code) | | Read a file of RDF into a model.
Parameters: model - Parameters: filenameOrURI - Parameters: baseURI - Parameters: syntax - The model exception: JenaException - if there is syntax error in file. |
readWholeFileAsUTF8 | public String readWholeFileAsUTF8(String filename)(Code) | | Slurp up a whole file: map filename as necessary
|
removeCacheModel | public void removeCacheModel(String uri)(Code) | | |
resetCache | public void resetCache()(Code) | | Reset the model cache
|
setGlobalFileManager | public static void setGlobalFileManager(FileManager globalFileManager)(Code) | | 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 - |
setLocationMapper | public void setLocationMapper(LocationMapper _mapper)(Code) | | Set the location mapping
|
setModelCaching | public void setModelCaching(boolean state)(Code) | | Change the state of model cache : does not clear the cache
|
setStdLocators | public static void setStdLocators(FileManager fMgr)(Code) | | Force a file handler to have the default configuration.
|
|
|