Class Triple
Class for representing RDF Triples in memory.
Inheritance
System.Object
Triple
Implements
System.IComparable<Triple>
System.Runtime.Serialization.ISerializable
System.Xml.Serialization.IXmlSerializable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: VDS.RDF
Assembly: dotNetRDF.dll
Syntax
[Serializable]
public sealed class Triple : IComparable<Triple>, ISerializable, IXmlSerializable
Constructors
| Improve this Doc View SourceTriple(INode, INode, INode)
Constructs a Triple from Nodes that belong to the same Graph/Node Factory.
Declaration
public Triple(INode subj, INode pred, INode obj)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject of the Triple. |
INode | pred | Predicate of the Triple. |
INode | obj | Object of the Triple. |
Remarks
Will throw an RdfException if the Nodes don't belong to the same Graph/Node Factory.
Exceptions
Type | Condition |
---|---|
RdfException | Thrown if the Nodes aren't all from the same Graph/Node Factory. |
Triple(INode, INode, INode, Uri)
Creates a Triple and associates it with the given Graph URI permanently (though not with a specific Graph as such).
Declaration
public Triple(INode subj, INode pred, INode obj, Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject of the Triple. |
INode | pred | Predicate of the Triple. |
INode | obj | Object of the Triple. |
System.Uri | graphUri | Graph URI. |
Remarks
Will throw an RdfException if the Nodes don't belong to the same Graph/Node Factory.
Exceptions
Type | Condition |
---|---|
RdfException | Thrown if the Nodes aren't all from the same Graph/Node Factory. |
Triple(INode, INode, INode, IGraph)
Constructs a Triple from Nodes that belong to the same Graph/Node Factory and associates this Triple with the given Graph (doesn't assert the Triple).
Declaration
public Triple(INode subj, INode pred, INode obj, IGraph g)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject. |
INode | pred | Predicate. |
INode | obj | Object. |
IGraph | g | Graph. |
Remarks
Will throw an RdfException if the Nodes don't belong to the same Graph/Node Factory.
Exceptions
Type | Condition |
---|---|
RdfException | Thrown if the Nodes aren't all from the same Graph/Node Factory. |
Triple(INode, INode, INode, ITripleContext)
Constructs a Triple from Nodes that belong to the same Graph/Node Factory with some Context.
Declaration
public Triple(INode subj, INode pred, INode obj, ITripleContext context)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject of the Triple. |
INode | pred | Predicate of the Triple. |
INode | obj | Object of the Triple. |
ITripleContext | context | Context Information for the Triple. |
Remarks
Will throw an RdfException if the Nodes don't belong to the same Graph/Node Factory.
Exceptions
Type | Condition |
---|---|
RdfException | Thrown if the Nodes aren't all from the same Graph/Node Factory. |
Triple(INode, INode, INode, ITripleContext, Uri)
Constructs a Triple from Nodes that belong to the same Graph/Node Factory with some Context.
Declaration
public Triple(INode subj, INode pred, INode obj, ITripleContext context, Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
INode | subj | Subject of the Triple. |
INode | pred | Predicate of the Triple. |
INode | obj | Object of the Triple. |
ITripleContext | context | Context Information for the Triple. |
System.Uri | graphUri | Graph URI. |
Remarks
Will throw an RdfException if the Nodes don't belong to the same Graph/Node Factory.
Exceptions
Type | Condition |
---|---|
RdfException | Thrown if the Nodes aren't all from the same Graph/Node Factory. |
Properties
| Improve this Doc View SourceContext
Gets the Context Information for this Triple.
Declaration
public ITripleContext Context { get; set; }
Property Value
Type | Description |
---|---|
ITripleContext |
Remarks
Context may be null where no Context for the Triple has been defined.
|
Improve this Doc
View Source
Graph
Gets the Graph this Triple was created for.
Declaration
public IGraph Graph { get; }
Property Value
Type | Description |
---|---|
IGraph |
Remarks
This is not necessarily the actual Graph this Triple is asserted in since this property is set from the Subject of the Triple when it is created and it is possible to create a Triple without asserting it into an actual Graph or to then assert it into a different Graph.
|
Improve this Doc
View Source
GraphUri
Gets the Uri of the Graph this Triple was created for.
Declaration
public Uri GraphUri { get; }
Property Value
Type | Description |
---|---|
System.Uri |
Remarks
This is not necessarily the actual Graph Uri of the Graph this Triple is asserted in since this property is set from the Subject of the Triple when it is created and it is possible to create a Triple without asserting it into an actual Graph or to then assert it into a different Graph.
|
Improve this Doc
View Source
IsGroundTriple
Gets whether the Triple is a Ground Triple.
Declaration
public bool IsGroundTriple { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
A Ground Triple is any Triple considered to state a single fixed fact. In practise this means that the Triple does not contain any Blank Nodes.
Nodes
Gets an enumeration of the Nodes in the Triple.
Declaration
public IEnumerable<INode> Nodes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<INode> |
Remarks
Returned as subject, predicate, object.
|
Improve this Doc
View Source
Object
Gets the Object of the Triple.
Declaration
public INode Object { get; }
Property Value
Type | Description |
---|---|
INode |
Predicate
Gets the Predicate of the Triple.
Declaration
public INode Predicate { get; }
Property Value
Type | Description |
---|---|
INode |
Subject
Gets the Subject of the Triple.
Declaration
public INode Subject { get; }
Property Value
Type | Description |
---|---|
INode |
Methods
| Improve this Doc View SourceCompareTo(Triple)
Implementation of CompareTo for Triples which allows Triples to be sorted.
Declaration
public int CompareTo(Triple other)
Parameters
Type | Name | Description |
---|---|---|
Triple | other | Triple to compare to. |
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
Triples are Ordered by Subjects, Predicates and then Objects. Triples are only partially orderable since the CompareTo methods on Nodes only define a partial ordering over Nodes.
|
Improve this Doc
View Source
Equals(Object)
Implementation of Equality for Triples.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Object to compare with. |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
System.Object.Equals(System.Object)
Remarks
Triples are considered equal on the basis of two things:.
|
Improve this Doc
View Source
- The Hash Codes of the Triples are identical
- The logical conjunction (AND) of the equality of the Subject, Predicate and Object is true. Each pair of Nodes must either be Equal using Node Equality or are both Blank Nodes and have identical Node IDs (i.e. are indistinguishable for equality purposes on a single Triple level)
GetHashCode()
Implementation of Hash Codes for Triples.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
System.Object.GetHashCode()
Remarks
Returns the Hash Code of the Triple which is calculated as the Hash Code of the String formed by concatenating the Hash Codes of its constituent Nodes. This Hash Code is precomputed in the Constructor of a Triple since it will be used a lot (in Triple Equality calculation, Triple Collections etc).
Since Hash Codes are based on a String representation there is no guarantee of uniqueness though the same Triple will always give the same Hash Code (on a given Platform - see the MSDN Documentation for System.String.GetHashCode for further details).
GetObjectData(SerializationInfo, StreamingContext)
Gets the data for serialization.
Declaration
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | Serilization Information. |
System.Runtime.Serialization.StreamingContext | context | Streaming Context. |
GetSchema()
Gets the schema for XML serialization.
Declaration
public XmlSchema GetSchema()
Returns
Type | Description |
---|---|
System.Xml.Schema.XmlSchema |
HasObject(INode)
Indicates whether the Triple has the given Node as the Object.
Declaration
public bool HasObject(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node to test upon. |
Returns
Type | Description |
---|---|
System.Boolean |
HasPredicate(INode)
Indicates whether the Triple has the given Node as the Predicate.
Declaration
public bool HasPredicate(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node to test upon. |
Returns
Type | Description |
---|---|
System.Boolean |
HasSubject(INode)
Indicates whether the Triple has the given Node as the Subject.
Declaration
public bool HasSubject(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | Node to test upon. |
Returns
Type | Description |
---|---|
System.Boolean |
Involves(Uri)
Checks whether the Triple involves a given Uri.
Declaration
public bool Involves(Uri uri)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | uri | The Uri to test upon. |
Returns
Type | Description |
---|---|
System.Boolean | True if the Triple has a UriNode with the given Uri. |
Involves(INode)
Checks whether the Triple involves a given Node.
Declaration
public bool Involves(INode n)
Parameters
Type | Name | Description |
---|---|---|
INode | n | The Node to test upon. |
Returns
Type | Description |
---|---|
System.Boolean | True if the Triple contains the given Node. |
ReadXml(XmlReader)
Reads the data for XML deserialization.
Declaration
public void ReadXml(XmlReader reader)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlReader | reader | XML Reader. |
ToString()
Gets a String representation of a Triple in the form 'Subject , Predicate , Object'.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
System.Object.ToString()
|
Improve this Doc
View Source
ToString(Boolean)
Gets a String representation of a Triple in the form 'Subject , Predicate , Object' with optional compression of URIs to QNames.
Declaration
public string ToString(bool compress)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | compress | Controls whether URIs will be compressed to QNames in the String representation. |
Returns
Type | Description |
---|---|
System.String |
ToString(ITripleFormatter)
Gets the String representation of a Triple using the given Triple Formatter.
Declaration
public string ToString(ITripleFormatter formatter)
Parameters
Type | Name | Description |
---|---|---|
ITripleFormatter | formatter | Formatter. |
Returns
Type | Description |
---|---|
System.String |
WriteXml(XmlWriter)
Writes the data for XML serialization.
Declaration
public void WriteXml(XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlWriter | writer | XML Writer. |
Implements
System.IComparable<T>
System.Runtime.Serialization.ISerializable
System.Xml.Serialization.IXmlSerializable