Class UriLoader
Static Helper Class for dereferencing URIs and attempting to parse the results of a HTTP GET request to the URI into RDF.
Inherited Members
Namespace: VDS.RDF.Parsing
Assembly: dotNetRdf.dll
Syntax
[Obsolete("The UriLoader class has been deprecated and will be removed in a future release. Please use the Loader class as a replacement.")]
public static class UriLoader
Remarks
Caching
As of the 0.2.2 release the loader has support for caching retrieved data locally built into it (for Graphs only), caching is done using ETags where the remote server provides them or just by a user-defineable 'freshness' criteria (i.e. number of hours retrieved resources should be cached for). By default this caching happens in the system temporary directory which means it is non-persistent i.e. if you run your application using dotNetRDF it may cache stuff during the session but once the application is closed the operating system may freely delete the cached data. If you wish to have a persistent cache then you can use the CacheDirectory property to set your own cache directory. Even when you set your own cache directory dotNetRDF will delete obsolete data from it over time though this will only happen when a new request invalidates previously cached data.
If you wish to completely control the Cache you can implement your own IUriLoaderCache implementation and use it by setting the Cache property.
As of the 3.0 release, this class is now deprecated and will be removed in a future version. The replacement for this class is the Loader class.
Properties
| Edit this page View SourceCache
Gets/Sets the Cache that is in use.
Declaration
public static IUriLoaderCache Cache { get; set; }
Property Value
Type | Description |
---|---|
IUriLoaderCache |
Remarks
Setting the Cache to null does not disable it, to disable caching use the CacheEnabled property.
CacheDirectory
Gets/Sets the Directory used for caching Graphs loaded from URIs.
Declaration
public static string CacheDirectory { get; set; }
Property Value
Type | Description |
---|---|
string |
CacheDuration
Gets/Sets the amount of time Graphs are cached for.
Declaration
public static TimeSpan CacheDuration { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
Remarks
This duration only applies to URIs which don't return an ETag as part of the HTTP response when they are deferenced.
CacheEnabled
Get or set the flag that controls whether or not the cache is enabled.
Declaration
public static bool CacheEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
Timeout
Get or set the timeout (in milliseconds) for reading content from a URL.
Declaration
public static int Timeout { get; set; }
Property Value
Type | Description |
---|---|
int |
UserAgent
Gets/Sets an optional User Agent string that will be appended to HTTP Requests.
Declaration
public static string UserAgent { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
| Edit this page View SourceIsCached(Uri)
Determines whether the RDF behind the given URI is cached.
Declaration
public static bool IsCached(Uri u)
Parameters
Type | Name | Description |
---|---|---|
Uri | u | URI. |
Returns
Type | Description |
---|---|
bool |
Remarks
Note: This does not guarantee that the cached content will be used if you load from the URI using the UriLoader. Whether the cached copy is used will depend on whether.
Load(IGraph, Uri)
Attempts to load a RDF Graph from the given URI into the given Graph.
Declaration
public static void Load(IGraph g, Uri u)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to assert Triples in. |
Uri | u | URI to attempt to get RDF from. |
Remarks
Attempts to select the relevant Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can just open a HTTP Stream yourself and pass it to an instance of the correct Parser.
In the event that the URI is a File URI the FileLoader will be used instead. If the URI is a Data URI then the DataUriLoader will be used instead.
Note: UriLoader will assign the Graph the source URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
Load(IGraph, Uri, GraphCallback, object)
Attempts to load a RDF Graph from a URI asynchronously.
Declaration
public static void Load(IGraph g, Uri u, GraphCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to assert triple in. |
Uri | u | URI to load from. |
GraphCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
Will attempt to autodetect the format of the RDF based on the Content-Type header of the HTTP response.
In the event that the URI is a File URI the FileLoader will be used instead. If the URI is a Data URI then the DataUriLoader will be used instead.
Note: UriLoader will assign the Graph the source URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Load(IGraph, Uri, IRdfReader)
Attempts to load a RDF Graph from the given URI into the given Graph.
Declaration
public static void Load(IGraph g, Uri u, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to assert Triples in. |
Uri | u | URI to attempt to get RDF from. |
IRdfReader | parser | Parser to use. |
Remarks
Uses the supplied parser to attempt parsing regardless of the actual Content Type returned.
In the event that the URI is a File URI the FileLoader will be used instead. If the URI is a Data URI then the DataUriLoader will be used instead.
Note: UriLoader will assign the Graph the source URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
Load(IGraph, Uri, IRdfReader, GraphCallback, object)
Attempts to load a RDF Graph from a URI asynchronously.
Declaration
public static void Load(IGraph g, Uri u, IRdfReader parser, GraphCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to assert triple in. |
Uri | u | URI to load from. |
IRdfReader | parser | Parser to use. |
GraphCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
Uses the supplied parser to attempt parsing regardless of the actual Content Type returned.
In the event that the URI is a File URI the FileLoader will be used instead. If the URI is a Data URI then the DataUriLoader will be used instead.
Note: UriLoader will assign the Graph the source URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Load(IRdfHandler, Uri)
Attempts to load a RDF Graph from the given URI using a RDF Handler.
Declaration
public static void Load(IRdfHandler handler, Uri u)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get RDF from. |
Remarks
Attempts to select the relevant Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can just open a HTTP Stream yourself and pass it to an instance of the correct Parser.
In the event that the URI is a File URI the FileLoader will be used instead. If the URI is a Data URI then the DataUriLoader will be used instead.
Load(IRdfHandler, Uri, IRdfReader)
Attempts to load a RDF Graph from the given URI using a RDF Handler.
Declaration
public static void Load(IRdfHandler handler, Uri u, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get RDF from. |
IRdfReader | parser | Parser to use. |
Remarks
Uses the supplied parser to attempt parsing regardless of the actual Content Type returned.
In the event that the URI is a File URI the FileLoader will be used instead.
If the URI is a Data URI then the DataUriLoader will be used instead.
Load(IRdfHandler, Uri, IRdfReader, RdfHandlerCallback, object)
Attempts to load a RDF Graph from a URI asynchronously using an RDF Handler.
Declaration
public static void Load(IRdfHandler handler, Uri u, IRdfReader parser, RdfHandlerCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to load from. |
IRdfReader | parser | Parser to use. |
RdfHandlerCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
Uses the supplied parser to attempt parsing regardless of the actual Content Type returned.
In the event that the URI is a File URI the FileLoader will be used instead.
If the URI is a Data URI then the DataUriLoader will be used instead.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Load(IRdfHandler, Uri, IStoreReader)
Attempts to load a RDF dataset from the given URI using a RDF Handler.
Declaration
public static void Load(IRdfHandler handler, Uri u, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
Load(IRdfHandler, Uri, IStoreReader, RdfHandlerCallback, object)
Attempts to load a RDF dataset asynchronously from the given URI using a RDF Handler.
Declaration
public static void Load(IRdfHandler handler, Uri u, IStoreReader parser, RdfHandlerCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
RdfHandlerCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Load(IRdfHandler, Uri, RdfHandlerCallback, object)
Attempts to load a RDF Graph from a URI asynchronously using an RDF Handler.
Declaration
public static void Load(IRdfHandler handler, Uri u, RdfHandlerCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to load from. |
RdfHandlerCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
Attempts to autodetect the RDF format based on the Content-Type header of the HTTP response.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Load(ITripleStore, Uri)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public static void Load(ITripleStore store, Uri u)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | u | URI to attempt to get a RDF dataset from. |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
Load(ITripleStore, Uri, IStoreReader)
Attempts to load a RDF dataset from the given URI into the given Triple Store.
Declaration
public static void Load(ITripleStore store, Uri u, IStoreReader parser)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | u | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
Load(ITripleStore, Uri, IStoreReader, TripleStoreCallback, object)
Attempts to load a RDF dataset asynchronously from the given URI into the given Triple Store.
Declaration
public static void Load(ITripleStore store, Uri u, IStoreReader parser, TripleStoreCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | u | URI to attempt to get a RDF dataset from. |
IStoreReader | parser | Parser to use to parse the RDF dataset. |
TripleStoreCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
If the parser
parameter is set to null then this method attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If you know ahead of time the Content Type you can explicitly pass in the parser to use.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Load(ITripleStore, Uri, TripleStoreCallback, object)
Attempts to load a RDF dataset asynchronously from the given URI into the given Triple Store.
Declaration
public static void Load(ITripleStore store, Uri u, TripleStoreCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
ITripleStore | store | Triple Store to load into. |
Uri | u | URI to attempt to get a RDF dataset from. |
TripleStoreCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
LoadDataset(IRdfHandler, Uri)
Attempts to load a RDF dataset from the given URI using a RDF Handler.
Declaration
public static void LoadDataset(IRdfHandler handler, Uri u)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get a RDF dataset from. |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
LoadDataset(IRdfHandler, Uri, RdfHandlerCallback, object)
Attempts to load a RDF dataset asynchronously from the given URI using a RDF Handler.
Declaration
public static void LoadDataset(IRdfHandler handler, Uri u, RdfHandlerCallback callback, object state)
Parameters
Type | Name | Description |
---|---|---|
IRdfHandler | handler | RDF Handler to use. |
Uri | u | URI to attempt to get a RDF dataset from. |
RdfHandlerCallback | callback | Callback to invoke when the operation completes. |
object | state | State to pass to the callback. |
Remarks
Attempts to select the relevant Store Parser based on the Content Type header returned in the HTTP Response.
If the loading completes normally the callback will be invoked normally, if an error occurs it will be invoked and passed an instance of AsyncError as the state which contains details of the error and the original state.
Events
| Edit this page View SourceStoreWarning
Event which is raised when a store parser that is invoked by the UriLoader notices a non-fatal issue with the RDF dataset syntax
Declaration
public static event StoreReaderWarning StoreWarning
Event Type
Type | Description |
---|---|
StoreReaderWarning |
Warning
Event which is raised when a parser that is invoked by the UriLoader notices a non-fatal issue with the RDF syntax
Declaration
public static event RdfReaderWarning Warning
Event Type
Type | Description |
---|---|
RdfReaderWarning |