SemWeb.Statement

SemWeb : SemWeb Namespace
Statement Struct

A statement, comprising a subject, predicate, and object.

public struct Statement : System.IComparable<SemWeb.Statement>, System.IEquatable<SemWeb.Statement>

#### Remarks

RDF requires that subjects and predicates be entities (non-literals).

The SemWeb.Statement.Meta property optionally contains an entity that has meta-information about the statement. The use of the Meta property is left up to application writers.

The subject, predicate, and object fields should not normally be `null`. They must not be `null` in a call to SemWeb.Store.Add(SemWeb.Statement). They may be `null` when used in a call to SemWeb.Store.Select.

## Members

See Also: Inherited members from ValueType.

### Constructors

Statement (Entity, Entity, Resource) Creates a new Statement.
Statement (Entity, Entity, Resource, Entity) Creates a new Statement with a meta entity.

### Fields

All static | Statement . A statement whose fields are all `null`.
DefaultMeta static | Entity . The entity used for the SemWeb.Statement.Meta field of statements when a Meta value is not given by the caller.
Meta | Entity . The meta field for the statement.
Object | Resource . The object of the statement.
Predicate | Entity . The predicate of the statement.
Subject | Entity . The subject of the statement.

### Properties

AnyNull [read-only] | bool . Gets whether any of the Subject, Predicate, Object, or Meta fields are `null`.

### Methods

| CompareTo (Statement) : int Compares two statements.
| Invert () : Statement Returns a new statement with the same predicate but with subject and object reversed.
| Matches (Statement) : bool To be added.
| Replace (Hashtable) : Statement Replaces instances of resources in the statement with other resources.
| Replace (Resource, Resource) : Statement Replaces occurrences of a resource with another resource.

### Operators

Equality (Statement, Statement) Tests two statements for equality.
Inequality (Statement, Statement) Tests two statements for inequality.

## Member Details

### Statement Constructor

public Statement (Entity subject, Entity predicate, Resource object)

Creates a new Statement.

#### Parameters

subject
  The subject of the statement.
predicate
  The predicate of the statement.
object
  The object of the statement.

#### Remarks

No arguments to this constructor may be `null` if this statement will be used in a call to the Add method of SemWeb.Store or SemWeb.StatementSink. Any of the arguments may be `null` if the statement will be used as a template for calls to a Contains or Select method.

The value of the SemWeb.Statement.Meta is set to SemWeb.Statement.DefaultMeta.

### Statement Constructor

public Statement (Entity subject, Entity predicate, Resource object, Entity meta)

Creates a new Statement with a meta entity.

#### Parameters

subject
  The subject of the statement.
predicate
  The predicate of the statement.
object
  The object of the statement.
meta
  An entity providing meta-information about the statement.

#### Remarks

No arguments to this constructor may be `null` if this statement will be used in a call to the Add method of SemWeb.Store or SemWeb.StatementSink. Any of the arguments may be `null` if the statement will be used as a template for calls to a Contains or Select method.

### Invert Method

public Statement Invert ()

Returns a new statement with the same predicate but with subject and object reversed.

#### Returns

The inverse of this statement.

#### Remarks

A stem.ArgumentException is thrown if the object of the statement is not an entity, since subjects can only be entities.

### op_Equality Method

public static bool == (Statement a, Statement b)

Tests two statements for equality.

#### Parameters

a
  A statement.
b
  A statement.

#### Returns

Whether the two statements are equal.

#### Remarks

Statements are considered equal when their subjects, predicates, objects, and meta entities are considered equal, or both are `null`.

### op_Inequality Method

public static bool != (Statement a, Statement b)

Tests two statements for inequality.

#### Parameters

a
  A statement.
b
  A statement.

#### Returns

Whether the two statements are not equal.

#### Remarks

Statements are considered equal when their subjects, predicates, objects, and meta entities are considered equal, or both are `null`.

### DefaultMeta Field

public static Entity DefaultMeta

The entity used for the SemWeb.Statement.Meta field of statements when a Meta value is not given by the caller.

#### Remarks

None.

### All Field

public static Statement All

A statement whose fields are all `null`.

#### Remarks

This statement is provided as a convience to easily select all statements in a source by a call to Select.

The following expression writes out all statements in a store.

C# Example
    using (StatementSink sink = new N3Writer(Console.Out)) {
        store.Select(Statement.All);
    }

### AnyNull Property

public bool AnyNull { get; }

Gets whether any of the Subject, Predicate, Object, or Meta fields are `null`.

#### Value

`true` if any of the Subject, Predicate, Object, or Meta fields are `null`.

#### Remarks

This is used to detect whether the Statement is a template.

### Replace Method

public Statement Replace (Resource find, Resource replacement)

Replaces occurrences of a resource with another resource.

#### Parameters

find
  The resource to be replaced.
replacement
  The new resource to use.

#### Returns

A new statement in which occurrences of find have been replaced with replacement.

#### Remarks

An ArgumentException is thrown if find is the subject, predicate, or meta of the statement and replacement is not an SemWeb.Entity.

### Subject Field

public Entity Subject

The subject of the statement.

#### Remarks

None.

### Predicate Field

public Entity Predicate

The predicate of the statement.

#### Remarks

None.

### Object Field

public Resource Object

The object of the statement.

#### Remarks

Objects can be entities or literals.

### Meta Field

public Entity Meta

The meta field for the statement.

#### Remarks

This field is often left as its default value, which is SemWeb.Statement.DefaultMeta, but the value of this field can be used for any application-specific purpose. Uses include tracking context and provenance, reification, and for formulas and named graphs.

### Replace Method

public Statement Replace (Hashtable resourceMap)

Replaces instances of resources in the statement with other resources.

#### Parameters

resourceMap
  A mapping from resources to resources.

#### Returns

A new statement in which instances of the keys of resourceMap have been replaced by their corresponding values.

#### Remarks

An exception will be thrown if a resource in subject, predicate, or meta position is mapped to a literal value.

### Matches Method

public bool Matches (Statement statement)

To be added.

#### Parameters

statement
  To be added.

#### Returns

To be added.

#### Remarks

To be added.

### CompareTo Method

public int CompareTo (Statement s)

Compares two statements.

#### Parameters

s
  Another statement.

#### Returns

0 if the two statements are equal, -1 if this statement should be ordered before s, otherwise 1 if s should be ordered before this statement.

#### Remarks

Statements are ordered first by subject, then by predicate, then object, then meta. For each of those fields, this statement comes first if its field is null or if the resource in the field would be ordered first compared to the corresponding resource in s, according to the ordering defined in the Resource class.