Deserialize() static private method

Deserializes the given N-Triples stream to a graph.
static private Deserialize ( Stream inputStream ) : RDFGraph
inputStream Stream
return RDFGraph
コード例 #1
0
        /// <summary>
        /// Creates a graph from a stream of the given RDF format.
        /// </summary>
        public static RDFGraph FromStream(RDFModelEnums.RDFFormats rdfFormat, Stream inputStream)
        {
            if (inputStream != null)
            {
                switch (rdfFormat)
                {
                case RDFModelEnums.RDFFormats.NTriples:
                    return(RDFNTriples.Deserialize(inputStream));

                case RDFModelEnums.RDFFormats.RdfXml:
                    return(RDFXml.Deserialize(inputStream));

                case RDFModelEnums.RDFFormats.TriX:
                    return(RDFTriX.Deserialize(inputStream));

                case RDFModelEnums.RDFFormats.Turtle:
                    return(RDFTurtle.Deserialize(inputStream));

                default:
                    throw new NotImplementedException();
                    break;
                }
            }
            throw new RDFModelException("Cannot read RDF graph from stream because given \"inputStream\" parameter is null.");
        }
コード例 #2
0
        /// <summary>
        /// Creates a graph from a file of the given RDF format.
        /// </summary>
        public static RDFGraph FromFile(RDFModelEnums.RDFFormats rdfFormat, String filepath)
        {
            if (!String.IsNullOrEmpty(filepath))
            {
                if (File.Exists(filepath))
                {
                    switch (rdfFormat)
                    {
                    case RDFModelEnums.RDFFormats.NTriples:
                        return(RDFNTriples.Deserialize(filepath));

                    case RDFModelEnums.RDFFormats.RdfXml:
                        return(RDFXml.Deserialize(filepath));

                    case RDFModelEnums.RDFFormats.TriX:
                        return(RDFTriX.Deserialize(filepath));

                    case RDFModelEnums.RDFFormats.Turtle:
                        return(RDFTurtle.Deserialize(filepath));

                    default:
                        throw new NotImplementedException();
                        break;
                    }
                }
                throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter (" + filepath + ") does not indicate an existing file.");
            }
            throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter is null or empty.");
        }
コード例 #3
0
ファイル: RDFGraph.cs プロジェクト: Mozes96/IBH
        /// <summary>
        /// Creates a graph from a file of the given RDF format.
        /// </summary>
        public static RDFGraph FromFile(RDFModelEnums.RDFFormats rdfFormat, String filepath)
        {
            if (filepath != null)
            {
                if (File.Exists(filepath))
                {
                    switch (rdfFormat)
                    {
                    case RDFModelEnums.RDFFormats.NTriples:
                        return(RDFNTriples.Deserialize(filepath));

                    case RDFModelEnums.RDFFormats.RdfXml:
                        return(RDFXml.Deserialize(filepath));

                    case RDFModelEnums.RDFFormats.TriX:
                        return(RDFTriX.Deserialize(filepath));

                    case RDFModelEnums.RDFFormats.Turtle:
                        throw new RDFModelException("Cannot read RDF graph from file because Turtle format is not supported. What about joining the project to contribute it?");
                    }
                }
                throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter (" + filepath + ") does not indicate an existing file.");
            }
            throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter is null or empty.");
        }
コード例 #4
0
ファイル: RDFGraph.cs プロジェクト: Mozes96/IBH
        /// <summary>
        /// Creates a graph from a stream of the given RDF format.
        /// </summary>
        public static RDFGraph FromStream(RDFModelEnums.RDFFormats rdfFormat, Stream inputStream)
        {
            if (inputStream != null)
            {
                switch (rdfFormat)
                {
                case RDFModelEnums.RDFFormats.NTriples:
                    return(RDFNTriples.Deserialize(inputStream));

                case RDFModelEnums.RDFFormats.RdfXml:
                    return(RDFXml.Deserialize(inputStream));

                case RDFModelEnums.RDFFormats.TriX:
                    return(RDFTriX.Deserialize(inputStream));

                case RDFModelEnums.RDFFormats.Turtle:
                    throw new RDFModelException("Cannot read RDF graph from stream because Turtle format is not supported. What about joining the project to contribute it?");
                }
            }
            throw new RDFModelException("Cannot read RDF graph from stream because given \"filepath\" parameter is null.");
        }
コード例 #5
0
ファイル: RDFGraph.cs プロジェクト: MMTim/RDFSharp
        internal static RDFGraph FromStream(RDFModelEnums.RDFFormats rdfFormat, Stream inputStream, Uri graphContext)
        {
            if (inputStream != null)
            {
                switch (rdfFormat)
                {
                case RDFModelEnums.RDFFormats.RdfXml:
                    return(RDFXml.Deserialize(inputStream, graphContext));

                case RDFModelEnums.RDFFormats.Turtle:
                    return(RDFTurtle.Deserialize(inputStream, graphContext));

                case RDFModelEnums.RDFFormats.NTriples:
                    return(RDFNTriples.Deserialize(inputStream, graphContext));

                case RDFModelEnums.RDFFormats.TriX:
                    return(RDFTriX.Deserialize(inputStream, graphContext));
                }
            }
            throw new RDFModelException("Cannot read RDF graph from stream because given \"inputStream\" parameter is null.");
        }