Package org.apache.jena.riot.adapters
Class AdapterFileManager
- java.lang.Object
-
- org.apache.jena.riot.adapters.AdapterFileManager
-
- All Implemented Interfaces:
FileManager
public class AdapterFileManager extends java.lang.Object implements 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 oneLocatorFile, oneLocatorClassLoaderand oneLocatorURLMain operations:- loadModel, readModel : URI to model
- open, openNoMap : URI to input stream
- mapURI : map URI to another by
LocationMapper
- readWholeFileAsUTF8
LocationMapperis 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. TheLocatorFilealso supports the idea of "current directory".- See Also:
StreamManager,LocationMapper,FileUtils
-
-
Field Summary
-
Fields inherited from interface org.apache.jena.util.FileManager
filePathSeparator, logAllLookups, PATH_DELIMITER
-
-
Constructor Summary
Constructors Constructor Description AdapterFileManager(StreamManager streamManager)AdapterFileManager(StreamManager streamManager, LocationMapper mapper)Create a FileManger using a RIOT StreamManager and RIOT LocationMapper
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCacheModel(java.lang.String uri, Model m)voidaddLocator(Locator oldloc)Add a locator to the end of the locators listvoidaddLocatorClassLoader(java.lang.ClassLoader cLoad)Add a class loader locatorvoidaddLocatorFile()Add a file locatorvoidaddLocatorFile(java.lang.String dir)Add a file locator which uses dir as its working directoryvoidaddLocatorFTP()voidaddLocatorHTTP()voidaddLocatorURL()voidaddLocatorZip(java.lang.String zfn)Add a zip file locatorFileManagerclone()static AdapterFileManagerget()Get the global file manager.ModelgetFromCache(java.lang.String filenameOrURI)Read out of the cache - return null if not in the cacheLocationMappergetLocationMapper()Get the location mappingStreamManagergetStreamManager()Return the associate stream managerbooleanhasCachedModel(java.lang.String filenameOrURI)booleanisCachingModels()return whether caching is on of offModelloadModel(java.lang.String filenameOrURI, java.lang.String rdfSyntax)Deprecated.ModelloadModel(java.lang.String filenameOrURI, java.lang.String baseURI, java.lang.String rdfSyntax)Deprecated.ModelloadModelInternal(java.lang.String filenameOrURI)java.util.Iterator<Locator>locators()Return an iterator over all the handlersstatic AdapterFileManagermakeGlobal()Create a "standard" FileManager.java.lang.StringmapURI(java.lang.String filenameOrURI)Apply the mapping of a filename or URIjava.io.InputStreamopen(java.lang.String filenameOrURI)Open a file using the locators of this FileManager Throws RiotNotFoundException if not found.java.io.InputStreamopenNoMap(java.lang.String filenameOrURI)Open a file using the locators of this FileManager but without location mapping.TypedStreamopenNoMapOrNull(java.lang.String filenameOrURI)Open a file using the locators of this FileManager without location mapping.ModelreadModel(Model model, java.lang.String filenameOrURI, java.lang.String rdfSyntax)Deprecated.ModelreadModel(Model model, java.lang.String filenameOrURI, java.lang.String baseURI, java.lang.String syntax)Deprecated.ModelreadModelInternal(Model model, java.lang.String filenameOrURI)java.lang.StringreadWholeFileAsUTF8(java.io.InputStream in)Deprecated.UseIO.readWholeFileAsUTF8(InputStream)java.lang.StringreadWholeFileAsUTF8(java.lang.String filename)Deprecated.UseIO.readWholeFileAsUTF8(String)voidremove(Locator loc)Remove a locatorvoidremoveCacheModel(java.lang.String uri)voidresetCache()Reset the model cachestatic voidsetGlobalFileManager(AdapterFileManager 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 cache-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jena.util.FileManager
loadModel, readModel
-
-
-
-
Constructor Detail
-
AdapterFileManager
public AdapterFileManager(StreamManager streamManager)
-
AdapterFileManager
public AdapterFileManager(StreamManager streamManager, LocationMapper mapper)
Create a FileManger using a RIOT StreamManager and RIOT LocationMapper
-
-
Method Detail
-
get
public static AdapterFileManager get()
Get the global file manager.- Returns:
- the global file manager
-
setGlobalFileManager
public static void setGlobalFileManager(AdapterFileManager 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-
-
clone
public FileManager clone()
- Specified by:
clonein interfaceFileManager
-
makeGlobal
public static AdapterFileManager makeGlobal()
Create a "standard" FileManager.
-
getStreamManager
public StreamManager getStreamManager()
Return the associate stream manager
-
setLocationMapper
public void setLocationMapper(LocationMapper mapper)
Set the location mapping- Specified by:
setLocationMapperin interfaceFileManager
-
getLocationMapper
public LocationMapper getLocationMapper()
Get the location mapping- Specified by:
getLocationMapperin interfaceFileManager
-
locators
public java.util.Iterator<Locator> locators()
Return an iterator over all the handlers- Specified by:
locatorsin interfaceFileManager
-
remove
public void remove(Locator loc)
Remove a locator- Specified by:
removein interfaceFileManager
-
addLocator
public void addLocator(Locator oldloc)
Add a locator to the end of the locators list- Specified by:
addLocatorin interfaceFileManager
-
addLocatorFile
public void addLocatorFile()
Add a file locator- Specified by:
addLocatorFilein interfaceFileManager
-
addLocatorFile
public void addLocatorFile(java.lang.String dir)
Add a file locator which uses dir as its working directory- Specified by:
addLocatorFilein interfaceFileManager
-
addLocatorClassLoader
public void addLocatorClassLoader(java.lang.ClassLoader cLoad)
Add a class loader locator- Specified by:
addLocatorClassLoaderin interfaceFileManager
-
addLocatorURL
public void addLocatorURL()
- Specified by:
addLocatorURLin interfaceFileManager
-
addLocatorHTTP
public void addLocatorHTTP()
-
addLocatorFTP
public void addLocatorFTP()
-
addLocatorZip
public void addLocatorZip(java.lang.String zfn)
Add a zip file locator- Specified by:
addLocatorZipin 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
public Model getFromCache(java.lang.String filenameOrURI)
Read out of the cache - return null if not in the cache- Specified by:
getFromCachein interfaceFileManager
-
hasCachedModel
public boolean hasCachedModel(java.lang.String filenameOrURI)
- Specified by:
hasCachedModelin interfaceFileManager
-
addCacheModel
public void addCacheModel(java.lang.String uri, Model m)- Specified by:
addCacheModelin interfaceFileManager
-
removeCacheModel
public void removeCacheModel(java.lang.String uri)
- Specified by:
removeCacheModelin interfaceFileManager
-
open
public java.io.InputStream open(java.lang.String filenameOrURI)
Open a file using the locators of this FileManager Throws RiotNotFoundException if not found.- Specified by:
openin interfaceFileManager
-
mapURI
public java.lang.String mapURI(java.lang.String filenameOrURI)
Apply the mapping of a filename or URI- Specified by:
mapURIin interfaceFileManager
-
openNoMap
public java.io.InputStream openNoMap(java.lang.String filenameOrURI)
Open a file using the locators of this FileManager but without location mapping. Throws RiotNotFoundException if not found.- Specified by:
openNoMapin interfaceFileManager
-
openNoMapOrNull
public TypedStream openNoMapOrNull(java.lang.String filenameOrURI)
Open a file using the locators of this FileManager without location mapping. Return null if not found- Specified by:
openNoMapOrNullin interfaceFileManager
-
loadModelInternal
public Model loadModelInternal(java.lang.String filenameOrURI)
- Specified by:
loadModelInternalin interfaceFileManager
-
loadModel
@Deprecated public Model loadModel(java.lang.String filenameOrURI, java.lang.String rdfSyntax)
Deprecated.Load a model from a file (local or remote). URI is the base for reading the model.- Specified by:
loadModelin interfaceFileManager- 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
@Deprecated public Model loadModel(java.lang.String filenameOrURI, java.lang.String baseURI, java.lang.String rdfSyntax)
Deprecated.Load a model from a file (local or remote).- Specified by:
loadModelin interfaceFileManager- 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.
-
readModelInternal
public Model readModelInternal(Model model, java.lang.String filenameOrURI)
- Specified by:
readModelInternalin interfaceFileManager
-
readModel
@Deprecated public Model readModel(Model model, java.lang.String filenameOrURI, java.lang.String rdfSyntax)
Deprecated.Read a file of RDF into a model.- Specified by:
readModelin interfaceFileManager- 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
@Deprecated public Model readModel(Model model, java.lang.String filenameOrURI, java.lang.String baseURI, java.lang.String syntax)
Deprecated.Read a file of RDF into a model.- Specified by:
readModelin interfaceFileManager- Parameters:
model-filenameOrURI-baseURI-syntax-- Returns:
- The model
- Throws:
JenaException- if there is syntax error in file.
-
readWholeFileAsUTF8
@Deprecated public java.lang.String readWholeFileAsUTF8(java.io.InputStream in)
Deprecated.UseIO.readWholeFileAsUTF8(InputStream)- Specified by:
readWholeFileAsUTF8in interfaceFileManager
-
readWholeFileAsUTF8
@Deprecated public java.lang.String readWholeFileAsUTF8(java.lang.String filename)
Deprecated.UseIO.readWholeFileAsUTF8(String)- Specified by:
readWholeFileAsUTF8in interfaceFileManager
-
-