Ejemplo n.º 1
0
        public org.openrdf.query.GraphQueryResult evaluate()
        {
            IGraph        g       = this.EvaluateQuery();
            SesameMapping mapping = new SesameMapping(g, new dotSesame.impl.GraphImpl());
            IEnumerable <dotSesame.Statement> stmts = from t in g.Triples
                                                      select SesameConverter.ToSesame(t, mapping);

            DotNetEnumerableWrapper wrapper = new DotNetEnumerableWrapper(stmts);

            java.util.HashMap map = new java.util.HashMap();
            foreach (String prefix in g.NamespaceMap.Prefixes)
            {
                map.put(prefix, g.NamespaceMap.GetNamespaceUri(prefix).ToString());
            }
            dotSesameQuery.impl.GraphQueryResultImpl results = new org.openrdf.query.impl.GraphQueryResultImpl(map, wrapper);
            return(results);
        }
Ejemplo n.º 2
0
        public void evaluate(org.openrdf.rio.RDFHandler rdfh)
        {
            IGraph        g       = this.EvaluateQuery();
            SesameMapping mapping = new SesameMapping(g, new dotSesame.impl.GraphImpl());


            rdfh.startRDF();
            foreach (String prefix in g.NamespaceMap.Prefixes)
            {
                rdfh.handleNamespace(prefix, g.NamespaceMap.GetNamespaceUri(prefix).ToString());
            }
            foreach (Triple t in g.Triples)
            {
                rdfh.handleStatement(SesameConverter.ToSesame(t, mapping));
            }
            rdfh.endRDF();
        }
Ejemplo n.º 3
0
        public object[] toArray(object[] objarr)
        {
            if (objarr.Length < this._g.Triples.Count)
            {
                objarr = new object[this._g.Triples.Count];
            }

            int i = 0;

            foreach (Triple t in this._g.Triples)
            {
                objarr[i] = SesameConverter.ToSesame(t, this._mapping);
                i++;
            }
            if (i < objarr.Length)
            {
                objarr[i] = null;
            }
            return(objarr);
        }
Ejemplo n.º 4
0
 protected override void Delete(Triple t)
 {
     this._g.remove(SesameConverter.ToSesame(t, this._mapping));
 }
Ejemplo n.º 5
0
 public override bool Contains(Triple t)
 {
     return(this._g.contains(SesameConverter.ToSesame(t, this._mapping)));
 }
Ejemplo n.º 6
0
 protected override void Add(Triple t)
 {
     this._g.add(SesameConverter.ToSesame(t, this._mapping));
 }
Ejemplo n.º 7
0
        public java.util.Iterator match(dotSesame.Resource r, dotSesame.URI uri, dotSesame.Value v, params dotSesame.Resource[] rarr)
        {
            INode s = (r != null) ? SesameConverter.FromSesameResource(r, this._mapping) : null;
            INode p = (uri != null) ? SesameConverter.FromSesameUri(uri, this._mapping) : null;
            INode o = (v != null) ? SesameConverter.FromSesameValue(v, this._mapping) : null;
            //Contexts are Ignored for matches on a single Graph

            IEnumerable <Triple> ts;

            if (s != null)
            {
                if (p != null)
                {
                    if (o != null)
                    {
                        //Matching on Subject Predicate and Object
                        Triple t = new Triple(s, p, o);
                        if (this._g.ContainsTriple(t))
                        {
                            ts = t.AsEnumerable();
                        }
                        else
                        {
                            ts = Enumerable.Empty <Triple>();
                        }
                    }
                    else
                    {
                        //Just matching on Subject Predicate
                        ts = this._g.GetTriplesWithSubjectPredicate(s, p);
                    }
                }
                else
                {
                    if (o != null)
                    {
                        //Matching on Subject Object
                        ts = this._g.GetTriplesWithSubjectObject(s, o);
                    }
                    else
                    {
                        //Just Matching on Subject
                        ts = this._g.GetTriplesWithSubject(s);
                    }
                }
            }
            else if (p != null)
            {
                if (o != null)
                {
                    //Matching on Predicate Object
                    ts = this._g.GetTriplesWithPredicateObject(p, o);
                }
                else
                {
                    //Just Matching on Predicate
                    ts = this._g.GetTriplesWithPredicate(p);
                }
            }
            else if (o != null)
            {
                //Matching on Object only
                ts = this._g.GetTriplesWithObject(o);
            }
            else
            {
                //Matching anything
                ts = this._g.Triples;
            }

            return(new DotNetEnumerableWrapper(ts.Select(t => SesameConverter.ToSesame(t, this._mapping))));
        }
Ejemplo n.º 8
0
 public object[] toArray()
 {
     return(this._g.Triples.Select(t => SesameConverter.ToSesame(t, this._mapping)).ToArray());
 }