}
public QueryTriplet.clone (QueryTriplet triplet) {
+ this.graph = triplet.graph;
this.subject = triplet.subject;
this.predicate = triplet.predicate;
chain_equal = a.next == b.next;
}
- return a.subject == b.subject &&
+ return a.graph == b.graph &&
+ a.subject == b.subject &&
a.obj == b.obj &&
a.predicate == b.predicate &&
chain_equal;
public string to_string (bool include_subject = true) {
string str = "";
- if (graph != null) {
- str += "GRAPH <%s> {".printf (this.graph);
- }
-
if (include_subject) {
str += " " + subject;
}
str += " " + this.obj;
}
- if (graph != null) {
- str += "}";
- }
-
return str;
}
}
var include_subject = true;
for (int i = 0; i < this.size; i++) {
+ if (this[i].graph != null && include_subject) {
+ str += "GRAPH <%s> {".printf (this[i].graph);
+ }
+
str += this[i].to_string (include_subject);
if (i < this.size - 1) {
if (include_subject) {
str += " . ";
+ // close the graph if we change the subject
+ if (this[i].graph != null) {
+ str += "} ";
+ }
} else {
str += " ; ";
}
+ } else {
+ // need to explicitly close the graph for the last triplet
+ if (this[i].graph != null) {
+ str += " . } ";
+ }
}
}