コード例 #1
0
        void WriteGraph(RdfGraph graph, RdfSourceWrapper sourcewrapper, StatementSink sink)
        {
            java.util.Iterator iter = graph.iterator();
            while (iter.hasNext())
            {
                GraphStatement stmt = (GraphStatement)iter.next();
                Statement      s;
                if (stmt is GraphStatementWrapper)
                {
                    s = ((GraphStatementWrapper)stmt).s;
                }
                else
                {
                    s = new Statement(
                        sourcewrapper.ToEntity(stmt.getSubject()),
                        sourcewrapper.ToEntity(stmt.getPredicate()),
                        sourcewrapper.ToResource(stmt.getObject()),
                        stmt.getGraphName() == null ? Statement.DefaultMeta : sourcewrapper.ToEntity(stmt.getGraphName()));
                }

                if (s.AnyNull)
                {
                    continue;                            // unbound variable, or literal in bad position
                }
                sink.Add(s);
            }
        }
コード例 #2
0
        public void Describe(SelectableSource source, StatementSink sink)
        {
            if (!(query is DescribeQuery))
            {
                throw new InvalidOperationException("Only DESCRIBE queries are supported by this method (" + query.GetType() + ").");
            }
            DescribeQuery    q             = (DescribeQuery)query;
            RdfSourceWrapper sourcewrapper = new RdfSourceWrapper(source, QueryMeta, this);
            RdfGraph         graph         = q.execute(sourcewrapper);

            WriteGraph(graph, sourcewrapper, sink);
        }
コード例 #3
0
        public void Construct(SelectableSource source, StatementSink sink)
        {
            if (!(query is ConstructQuery))
            {
                throw new InvalidOperationException("Only CONSTRUCT queries are supported by this method (" + query.GetType() + ").");
            }
            ConstructQuery   q             = (ConstructQuery)query;
            RdfSourceWrapper sourcewrapper = new RdfSourceWrapper(source, QueryMeta, this);
            RdfGraph         graph         = q.execute(sourcewrapper);

            WriteGraph(graph, sourcewrapper, sink);
        }
コード例 #4
0
        void WriteGraph(RdfGraph graph, RdfSourceWrapper sourcewrapper, StatementSink sink)
        {
            if (sink is RdfWriter)
                ((RdfWriter)sink).Namespaces.AddFrom(GetQueryPrefixes());

            java.util.Iterator iter = graph.iterator();
            while (iter.hasNext()) {
                GraphStatement stmt = (GraphStatement)iter.next();
                Statement s;
                if (stmt is GraphStatementWrapper) {
                    s = ((GraphStatementWrapper)stmt).s;
                } else {
                    s = new Statement(
                        sourcewrapper.ToEntity(stmt.getSubject()),
                        sourcewrapper.ToEntity(stmt.getPredicate()),
                        sourcewrapper.ToResource(stmt.getObject()),
                        stmt.getGraphName() == null ? Statement.DefaultMeta : sourcewrapper.ToEntity(stmt.getGraphName()));
                }

                if (s.AnyNull) continue; // unbound variable, or literal in bad position
                sink.Add(s);
            }
        }