/// <summary> /// Formats a Pattern Item in nicely formatted SPARQL syntax /// </summary> /// <param name="item">Pattern Item</param> /// <param name="segment">Triple Pattern Segment</param> /// <returns></returns> public virtual String Format(PatternItem item, TripleSegment?segment) { if (item is VariablePattern) { return(item.ToString()); } else if (item is NodeMatchPattern) { NodeMatchPattern match = (NodeMatchPattern)item; return(this.Format(match.Node, segment)); } else if (item is FixedBlankNodePattern) { if (segment != null) { if (segment == TripleSegment.Predicate) { throw new RdfOutputException("Cannot format a Fixed Blank Node Pattern Item as the Predicate of a Triple Pattern as Blank Nodes are not permitted as Predicates"); } } return(item.ToString()); } else if (item is BlankNodePattern) { return(item.ToString()); } else { throw new RdfOutputException("Unable to Format an unknown PatternItem implementation as a String"); } }
private string getName(PatternItem item) { if (item is VariablePattern || (item as NodeMatchPattern).Node.NodeType.ToString().Equals("Literal")) { return(item.ToString()); } else { var node = (item as NodeMatchPattern).ToString().Replace("<", "").Replace(">", ""); Uri uri = new Uri(node); var last = uri.Segments.Last <string>(); return(last); } }
/// <summary> /// Gets the String representation of the Algebra. /// </summary> /// <returns></returns> public override string ToString() { StringBuilder output = new StringBuilder(); output.Append("NegatedPropertySet("); output.Append(_start.ToString()); output.Append(", {"); for (int i = 0; i < _properties.Count; i++) { output.Append(_properties[i].ToString()); if (i < _properties.Count - 1) { output.Append(", "); } } output.Append("}, "); output.Append(_end.ToString()); output.Append(')'); return(output.ToString()); }