/// <summary> /// Loads a RDF Dataset from the NQuads input using a RDF Handler /// </summary> /// <param name="handler">RDF Handler to use</param> /// <param name="parameters">Parameters indicating the Stream to read from</param> public void Load(IRdfHandler handler, IStoreParams parameters) { if (handler == null) { throw new ArgumentNullException("handler", "Cannot parse an RDF Dataset using a null RDF Handler"); } if (parameters == null) { throw new ArgumentNullException("parameters", "Cannot parse an RDF Dataset using null Parameters"); } //Try and get the Input from the parameters TextReader input = null; if (parameters is StreamParams) { //Get Input Stream input = ((StreamParams)parameters).StreamReader; #if !SILVERLIGHT //Issue a Warning if the Encoding of the Stream is not ASCII if (!((StreamReader)input).CurrentEncoding.Equals(Encoding.ASCII)) { this.RaiseWarning("Expected Input Stream to be encoded as ASCII but got a Stream encoded as " + ((StreamReader)input).CurrentEncoding.EncodingName + " - Please be aware that parsing errors may occur as a result"); } #endif } else if (parameters is TextReaderParams) { input = ((TextReaderParams)parameters).TextReader; } if (input != null) { try { //Setup Token Queue and Tokeniser NTriplesTokeniser tokeniser = new NTriplesTokeniser(input); tokeniser.NQuadsMode = true; TokenQueue tokens = new TokenQueue(); tokens.Tokeniser = tokeniser; tokens.Tracing = this._tracetokeniser; tokens.InitialiseBuffer(); //Invoke the Parser this.Parse(handler, tokens); } catch { throw; } finally { try { input.Close(); } catch { //No catch actions - just cleaning up } } } else { throw new RdfStorageException("Parameters for the NQuadsParser must be of the type StreamParams/TextReaderParams"); } }