RDFTriX is responsible for managing serialization to and from TriX data format.
Пример #1
0
        /// <summary>
        /// Writes the given store to the given stream in the given RDF format.
        /// </summary>
        public static void WriteRDF(RDFStoreEnums.RDFFormats rdfFormat, RDFStore store, Stream outputStream)
        {
            if (store != null)
            {
                if (outputStream != null)
                {
                    switch (rdfFormat)
                    {
                    case RDFStoreEnums.RDFFormats.NQuads:
                        RDFNQuads.Serialize(store, outputStream);
                        break;

                    case RDFStoreEnums.RDFFormats.TriX:
                        RDFTriX.Serialize(store, outputStream);
                        break;
                    }
                }
                else
                {
                    throw new RDFStoreException("Cannot write RDF file because given \"outputStream\" parameter is null.");
                }
            }
            else
            {
                throw new RDFStoreException("Cannot write RDF file because given \"store\" parameter is null.");
            }
        }
Пример #2
0
        /// <summary>
        /// Reads a memory store from a stream of the given RDF format.
        /// </summary>
        public static RDFMemoryStore FromStream(RDFStoreEnums.RDFFormats rdfFormat, Stream inputStream)
        {
            if (inputStream != null)
            {
                switch (rdfFormat)
                {
                case RDFStoreEnums.RDFFormats.NQuads:
                    return(RDFNQuads.Deserialize(inputStream));

                case RDFStoreEnums.RDFFormats.TriX:
                    return(RDFTriX.Deserialize(inputStream));
                }
            }
            throw new RDFStoreException("Cannot read RDF memory store from stream because given \"inputStream\" parameter is null.");
        }
Пример #3
0
        /// <summary>
        /// Reads a memory store from a file of the given RDF format.
        /// </summary>
        public static RDFMemoryStore FromFile(RDFStoreEnums.RDFFormats rdfFormat, string filepath)
        {
            if (!string.IsNullOrEmpty(filepath))
            {
                if (File.Exists(filepath))
                {
                    switch (rdfFormat)
                    {
                    case RDFStoreEnums.RDFFormats.NQuads:
                        return(RDFNQuads.Deserialize(filepath));

                    case RDFStoreEnums.RDFFormats.TriX:
                        return(RDFTriX.Deserialize(filepath));
                    }
                }
                throw new RDFStoreException("Cannot read RDF memory store from file because given \"filepath\" parameter (" + filepath + ") does not indicate an existing file.");
            }
            throw new RDFStoreException("Cannot read RDF memory store from file because given \"filepath\" parameter is null or empty.");
        }
Пример #4
0
        /// <summary>
        /// Reads the given file in the given RDF format to a memory store.
        /// </summary>
        public static RDFMemoryStore ReadRDF(RDFStoreEnums.RDFFormats rdfFormat, String filepath)
        {
            if (filepath != null)
            {
                if (File.Exists(filepath))
                {
                    switch (rdfFormat)
                    {
                    case RDFStoreEnums.RDFFormats.TriX:
                        return(RDFTriX.Deserialize(filepath));

                    case RDFStoreEnums.RDFFormats.NQuads:
                        return(RDFNQuads.Deserialize(filepath));
                    }
                }
                throw new RDFStoreException("Cannot read RDF file because given \"filepath\" parameter (" + filepath + ") does not indicate an existing file.");
            }
            throw new RDFStoreException("Cannot read RDF file because given \"filepath\" parameter is null.");
        }
Пример #5
0
        /// <summary>
        /// Writes the store into a stream in the given RDF format.
        /// </summary>
        public void ToStream(RDFStoreEnums.RDFFormats rdfFormat, Stream outputStream)
        {
            if (outputStream != null)
            {
                switch (rdfFormat)
                {
                case RDFStoreEnums.RDFFormats.NQuads:
                    RDFNQuads.Serialize(this, outputStream);
                    break;

                case RDFStoreEnums.RDFFormats.TriX:
                    RDFTriX.Serialize(this, outputStream);
                    break;
                }
            }
            else
            {
                throw new RDFStoreException("Cannot write RDF store to stream because given \"outputStream\" parameter is null.");
            }
        }
Пример #6
0
        /// <summary>
        /// Writes the store into a file in the given RDF format.
        /// </summary>
        public void ToFile(RDFStoreEnums.RDFFormats rdfFormat, String filepath)
        {
            if (filepath != null)
            {
                switch (rdfFormat)
                {
                case RDFStoreEnums.RDFFormats.NQuads:
                    RDFNQuads.Serialize(this, filepath);
                    break;

                case RDFStoreEnums.RDFFormats.TriX:
                    RDFTriX.Serialize(this, filepath);
                    break;
                }
            }
            else
            {
                throw new RDFStoreException("Cannot write RDF store to file because given \"filepath\" parameter is null or empty.");
            }
        }