SemWeb : SemWeb Namespace
Entity Class

An entity resource in a graph.

public class Entity : Resource


Remarks

Entities can have URIs, or they can be anonymous, in which case their URI is null. However, in order to construct a blank node, use new SemWeb.BNode().

Specialized stores will attach caching information to Entity objects to make interaction with the store faster. It is therefore better to reuse existing Entity objects where possible.

The == and != operators have been overloaded for entities. Two named entities are equal when they both have the same URI. Two anonymous Entity objects are equal if they were created by the same Store and were assigned the same resource key.

An implicit conversion operator is defined from strings to entities. The operator converts the string to an entity by returning an entity with that URI.

The following examples all create entities.

C# Example
Entity thing1 = new Entity("http://www.example.com/#thing");
Entity thing2 = "http://www.example.com/#thing"; // operator overload
Entity thing3 = (Entity)"http://www.example.com/#thing"; // operator overload with explicit cast

Console.WriteLine(thing1.Uri)

Members

See Also: Inherited members from Resource.

Constructors

Constructs a new entity with the given URI.

Properties

Uri [read-only]
abstract
string . The URI of this resource. (Inherited from Resource.)

Methods

CompareTo (Resource) : int
Compares two resources. (Inherited from Resource.)
GetResourceKey (object) : object
To be added. (Inherited from Resource.)
SetResourceKey (object, object)
To be added. (Inherited from Resource.)
static ValidateUri (string) : string
Validates that a string is a legitimate IRI-Reference, i.e. a legitimate URI in RDF.

Operators

Equality (Entity, Entity)
Tests whether two entities are equal.
Inequality (Entity, Entity)
Tests whether two entities are not equal.
Conversion to SemWeb.Entity (Implicit)
Implicitly converts a string URI to an entity.

Member Details

Entity Constructor

public Entity (string uri)

Constructs a new entity with the given URI.

Parameters

uri
The URI of the entity.

Remarks

uri may not be null. To construct a blank node, use new SemWeb.BNode().

Conversion Method

public static implicit operator Entity (string uri)

Implicitly converts a string URI to an entity.

Parameters

uri
A URI.

Returns

An entity whose URI is uri.

Remarks

None.

op_Equality Method

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

Tests whether two entities are equal.

Parameters

a
An entity.
b
An entity.

Returns

If both parameters are null, the operator returns true.

Otherwise, the operator returns true if the two entities are the same instance, or if their URIs are equal.

Remarks

Two anonymous entities are not equal unless they are the same instance, or if they represent the same resource and were created by the same store.

Note that the SemWeb.Resource class does not have an equality operator, so you must be comparing two variables typed as Entity to use this operator.


op_Inequality Method

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

Tests whether two entities are not equal.

Parameters

a
An entity.
b
An entity.

Returns

The negation of the result of applying the equality operator.

Remarks

See the equality operator.

ValidateUri Method

public static string ValidateUri (string uri)

Validates that a string is a legitimate IRI-Reference, i.e. a legitimate URI in RDF.

Parameters

uri
The URI to validate.

Returns

null if uri is valid, otherwise a string describing the problem.

Remarks

When creating an Entity instance, the string passed into the constructor as the URI is not validated (because validation is a somewhat expensive process). It is the caller's responsibility to validate the URI using this method.