java.lang.Object
org.apache.jena.util.FileManagerImpl
- All Implemented Interfaces:
FileManager
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
- readWholeFileAsUTF8
- optional caching of models
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:
-
Field Summary
Fields inherited from interface org.apache.jena.util.FileManager
filePathSeparator, logAllLookups, PATH_DELIMITER -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheModel(String uri, Model m) voidaddLocator(Locator loc) Add a locator to the end of the locators listvoidaddLocatorClassLoader(ClassLoader cLoad) Deprecated.voidDeprecated.voidaddLocatorFile(String dir) Deprecated.voidDeprecated.voidaddLocatorZip(String zfn) Deprecated.clone()static FileManagerget()Get the global file manager.getFromCache(String filenameOrURI) Read out of the cache - return null if not in the cacheGet the location mappingbooleanhasCachedModel(String filenameOrURI) booleanreturn whether caching is on of offloadModelInternal(String filenameOrURI) Load a model from a file (local or remote).locators()Return an iterator over all the handlersstatic FileManagerCreate a "standard" FileManager.Apply the mapping of a filename or URIOpen a file using the locators of this FileManagerOpen a file using the locators of this FileManager but without location mappingopenNoMapOrNull(String filenameOrURI) Open a file using the locators of this FileManager but without location mapping.readModelInternal(Model model, String filenameOrURI) Read a file of RDF into a model.voidRemove a locatorvoidremoveCacheModel(String uri) voidReset the model cachestatic voidsetGlobalFileManager(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 createdvoidsetLocationMapper(LocationMapper _mapper) Set the location mappingvoidsetModelCaching(boolean state) Change the state of model cache : does not clear the cacheMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.jena.util.FileManager
loadModel, readModel
-
Method Details
-
get
Get the global file manager.- Returns:
- the global file manager
-
setGlobalFileManager
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-
-
clone
- Specified by:
clonein interfaceFileManager
-
makeGlobal
Create a "standard" FileManager. -
setLocationMapper
Set the location mapping- Specified by:
setLocationMapperin interfaceFileManager
-
getLocationMapper
Get the location mapping- Specified by:
getLocationMapperin interfaceFileManager
-
locators
Return an iterator over all the handlers- Specified by:
locatorsin interfaceFileManager
-
addLocator
Add a locator to the end of the locators list- Specified by:
addLocatorin interfaceFileManager
-
addLocatorFile
Deprecated.Add a file locator- Specified by:
addLocatorFilein interfaceFileManager
-
addLocatorFile
Deprecated.Add a file locator which uses dir as its working directory- Specified by:
addLocatorFilein interfaceFileManager
-
addLocatorClassLoader
Deprecated.Add a class loader locator- Specified by:
addLocatorClassLoaderin interfaceFileManager
-
addLocatorURL
Deprecated.Add a URL locator- Specified by:
addLocatorURLin interfaceFileManager
-
addLocatorZip
Deprecated.Add a zip file locator- Specified by:
addLocatorZipin interfaceFileManager
-
remove
Remove a locator- Specified by:
removein interfaceFileManager
-
resetCache
public void resetCache()Reset the model cache- Specified by:
resetCachein interfaceFileManager
-
setModelCaching
public void setModelCaching(boolean state) Change the state of model cache : does not clear the cache- Specified by:
setModelCachingin interfaceFileManager
-
isCachingModels
public boolean isCachingModels()return whether caching is on of off- Specified by:
isCachingModelsin interfaceFileManager
-
getFromCache
Read out of the cache - return null if not in the cache- Specified by:
getFromCachein interfaceFileManager
-
hasCachedModel
- Specified by:
hasCachedModelin interfaceFileManager
-
addCacheModel
- Specified by:
addCacheModelin interfaceFileManager
-
removeCacheModel
- Specified by:
removeCacheModelin interfaceFileManager
-
loadModelInternal
Load a model from a file (local or remote). This operation may attempt content negotiation for http URLs.- Specified by:
loadModelInternalin interfaceFileManager- Parameters:
filenameOrURI- The filename or a URI (file:, http:)- Returns:
- a new model
- Throws:
JenaException- if there is syntax error in file.
-
readModelInternal
Read a file of RDF into a model. Guesses the syntax of the file based on filename extension, defaulting to RDF/XML.- Specified by:
readModelInternalin interfaceFileManager- Parameters:
model-filenameOrURI-- Returns:
- The model or null, if there was an error.
- Throws:
JenaException- if there is syntax error in file.
-
open
Open a file using the locators of this FileManager- Specified by:
openin interfaceFileManager
-
mapURI
Apply the mapping of a filename or URI- Specified by:
mapURIin interfaceFileManager
-
openNoMap
Open a file using the locators of this FileManager but without location mapping- Specified by:
openNoMapin interfaceFileManager
-
openNoMapOrNull
Open a file using the locators of this FileManager but without location mapping. Return null if not found- Specified by:
openNoMapOrNullin interfaceFileManager
-