public virtual int CompareTo(RDFDataset.Quad o) { if (o == null) { return(1); } int rval = GetGraph().CompareTo(o.GetGraph()); if (rval != 0) { return(rval); } rval = GetSubject().CompareTo(o.GetSubject()); if (rval != 0) { return(rval); } rval = GetPredicate().CompareTo(o.GetPredicate()); if (rval != 0) { return(rval); } return(GetObject().CompareTo(o.GetObject())); }
internal static string ToNQuad(RDFDataset.Quad triple, string graphName, string bnode ) { RDFDataset.Node s = triple.GetSubject(); RDFDataset.Node p = triple.GetPredicate(); RDFDataset.Node o = triple.GetObject(); string quad = string.Empty; // subject is an IRI or bnode if (s.IsIRI()) { quad += "<" + Escape(s.GetValue()) + ">"; } else { // normalization mode if (bnode != null) { quad += bnode.Equals(s.GetValue()) ? "_:a" : "_:z"; } else { // normal mode quad += s.GetValue(); } } if (p.IsIRI()) { quad += " <" + Escape(p.GetValue()) + "> "; } else { // otherwise it must be a bnode (TODO: can we only allow this if the // flag is set in options?) quad += " " + Escape(p.GetValue()) + " "; } // object is IRI, bnode or literal if (o.IsIRI()) { quad += "<" + Escape(o.GetValue()) + ">"; } else { if (o.IsBlankNode()) { // normalization mode if (bnode != null) { quad += bnode.Equals(o.GetValue()) ? "_:a" : "_:z"; } else { // normal mode quad += o.GetValue(); } } else { string escaped = Escape(o.GetValue()); quad += "\"" + escaped + "\""; if (JSONLDConsts.RdfLangstring.Equals(o.GetDatatype())) { quad += "@" + o.GetLanguage(); } else { if (!JSONLDConsts.XsdString.Equals(o.GetDatatype())) { quad += "^^<" + Escape(o.GetDatatype()) + ">"; } } } } // graph if (graphName != null) { if (graphName.IndexOf("_:") != 0) { quad += " <" + Escape(graphName) + ">"; } else { if (bnode != null) { quad += " _:g"; } else { quad += " " + graphName; } } } quad += " .\n"; return(quad); }