Show / Hide Table of Contents

Class Triple

Class for representing RDF Triples in memory.

Inheritance
object
Triple
Implements
IComparable<Triple>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public sealed class Triple : IComparable<Triple>

Constructors

| Edit this page View Source

Triple(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.

| Edit this page View Source

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
[Obsolete("This constructor is obsolete and will be removed in a future version.")]
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.

| Edit this page View Source

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.

Properties

| Edit this page View Source

Context

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.

| Edit this page View Source

IsGroundTriple

Gets whether the Triple is a Ground Triple.

Declaration
public bool IsGroundTriple { get; }
Property Value
Type Description
bool
Remarks

A Ground Triple is any Triple considered to state a single fixed fact. In practice this means that the Triple does not contain any Blank Nodes, and does not quote any triples containing blank nodes.

| Edit this page View Source

Nodes

Gets an enumeration of the Nodes in the Triple.

Declaration
public IEnumerable<INode> Nodes { get; }
Property Value
Type Description
IEnumerable<INode>
Remarks

Returned as subject, predicate, object.

| Edit this page View Source

Object

Gets the Object of the Triple.

Declaration
public INode Object { get; }
Property Value
Type Description
INode
| Edit this page View Source

Predicate

Gets the Predicate of the Triple.

Declaration
public INode Predicate { get; }
Property Value
Type Description
INode
| Edit this page View Source

Subject

Gets the Subject of the Triple.

Declaration
public INode Subject { get; }
Property Value
Type Description
INode

Methods

| Edit this page View Source

CompareTo(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
int
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.

| Edit this page View Source

Equals(object)

Implementation of Equality for Triples.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

Object to compare with.

Returns
Type Description
bool
Overrides
object.Equals(object)
Remarks

Triples are considered equal on the basis of two things:.

  1. The Hash Codes of the Triples are identical
  2. 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)
| Edit this page View Source

GetHashCode()

Implementation of Hash Codes for Triples.

Declaration
public override int GetHashCode()
Returns
Type Description
int
Overrides
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 string.GetHashCode() for further details).

| Edit this page View Source

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
bool
| Edit this page View Source

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
bool
| Edit this page View Source

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
bool
| Edit this page View Source

Involves(Uri)

Checks whether the Triple involves a given Uri.

Declaration
public bool Involves(Uri uri)
Parameters
Type Name Description
Uri uri

The Uri to test upon.

Returns
Type Description
bool

True if the Triple has a UriNode with the given Uri.

| Edit this page View Source

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
bool

True if the Triple contains the given node or quotes a triple that involves the given node.

| Edit this page View Source

ToString()

Gets a String representation of a Triple in the form 'Subject , Predicate , Object'.

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()
| Edit this page View Source

ToString(bool)

Gets a String representation of a Triple in the form 'Subject , Predicate , Object' with optional compression of URIs to QNames.

Declaration
[Obsolete("This method is obsolete and will be removed in a future version. Use ToString() or ToString(ITripleFormatter) instead.")]
public string ToString(bool compress)
Parameters
Type Name Description
bool compress

Controls whether URIs will be compressed to QNames in the String representation.

Returns
Type Description
string
Remarks

As of dotNetRdf 3.0, this method is obsolete and does not perform an URI to QName compression. To produce a compressed string, use the ToString(ITripleFormatter) overload passing in a formatter configured with the desired INamespaceMapper.

| Edit this page View Source

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
string

Implements

IComparable<T>

Extension Methods

Extensions.ToSafeString(object)
Extensions.AsEnumerable<T>(T)
Extensions.MapTriple(Triple, IGraph, Dictionary<INode, INode>)
  • Edit this page
  • View Source
In this article
  • Constructors
    • Triple(INode, INode, INode)
    • Triple(INode, INode, INode, IGraph)
    • Triple(INode, INode, INode, ITripleContext)
  • Properties
    • Context
    • IsGroundTriple
    • Nodes
    • Object
    • Predicate
    • Subject
  • Methods
    • CompareTo(Triple)
    • Equals(object)
    • GetHashCode()
    • HasObject(INode)
    • HasPredicate(INode)
    • HasSubject(INode)
    • Involves(Uri)
    • Involves(INode)
    • ToString()
    • ToString(bool)
    • ToString(ITripleFormatter)
  • Implements
  • Extension Methods
Back to top Generated by DocFX