Inherits from RedlandWrappedObject : NSObject
Declared in RedlandModel.h
RedlandModel.m

Overview

This class provides the RDF model support.

A model is a set of statements (duplicates are not allowed, except in separate Redland contexts). Models can have statements added and removed, be queried and stored which is implemented by the RedlandStorage class. Wraps librdf_model.

RedlandModel(SerializerConvenience)

Category to add convenience parsing methods to RedlandModel.

Tasks

Other Methods

SerializerConvenience Methods

Convenience Methods

ParserConvenience Methods

  • – loadURL:withContext:

    Fetches data from the given URL using the Cocoa NSURL loading system, parses it with a parser deduced from the returned MIME type, and adds the statements into the given context of the receiver.

Instance Methods

addStatement:

Adds a single statement to the receiver. Duplicate statements are ignored.

- (void)addStatement:(RedlandStatement *)aStatement

Parameters

aStatement

A complete statement (with non-nil subject, predicate, and object)

Discussion

Adds a single statement to the receiver. Duplicate statements are ignored.

Declared In

RedlandModel.m

addStatement:withContext:

Adds a single statement to the receiver with the given context.

- (void)addStatement:(RedlandStatement *)aStatement withContext:(RedlandNode *)contextNode

Parameters

aStatement

A complete statement

contextNode

The context to associate this statement with

Discussion

Adds a single statement to the receiver with the given context.

Declared In

RedlandModel.m

addStatementsFromStream:

Adds a stream of statements to the receiver. Duplicate statements are ignored.

- (void)addStatementsFromStream:(RedlandStream *)aStream

Parameters

aStream

A stream of complete statements

Discussion

Adds a stream of statements to the receiver. Duplicate statements are ignored.

Declared In

RedlandModel.m

addStatementsFromStream:withContext:

Adds a stream of statements to the receiver in the given context.

- (void)addStatementsFromStream:(RedlandStream *)aStream withContext:(RedlandNode *)contextNode

Parameters

aStream

A stream of complete statements

contextNode

The context to associate each statement with

Discussion

Adds a stream of statements to the receiver in the given context.

Declared In

RedlandModel.m

addSubmodel:

Add a submodel to the receiver.

- (BOOL)addSubmodel:(RedlandModel *)submodel

Parameters

submodel

The submodel to add to the model, must not be nil

Return Value

A BOOL whether the action was successful

Discussion

Add a submodel to the receiver.

Warning: Redland has a function “librdf_model_add_submodel”, however it is labelled with a “FIXME: Not tested” and I was having trouble getting it to work properly. For this reason this method currently simply adds the statements/triples found in the submodel to the model. This will fail if any statement already exists in the model (but it will not raise an exception).

Declared In

RedlandModel.m

arcWithSource:target:

Returns one matching arc in the receiver for the given sourceNode and targetNode.

- (RedlandNode *)arcWithSource:(RedlandNode *)sourceNode target:(RedlandNode *)targetNode

Parameters

sourceNode

The source (or subject)

targetNode

The target (or object)

Discussion

Returns one matching arc in the receiver for the given sourceNode and targetNode.

Declared In

RedlandModel.m

containsContext:

Check for a context in the model.

- (BOOL)containsContext:(RedlandNode *)contextNode

Parameters

contextNode

A RedlandNode representing the context

Return Value

YES if the model does contain the specified context

Discussion

Check for a context in the model.

Declared In

RedlandModel.m

containsStatement:

Returns YES if the receiver contains the given statement.

- (BOOL)containsStatement:(RedlandStatement *)aStatement

Parameters

aStatement

A complete statement

Discussion

Returns YES if the receiver contains the given statement.

Warning: May not work in all cases; use enumeratorOfStatementsLike: instead.

Declared In

RedlandModel.m

contextEnumerator

Returns an NSEnumerator of all contexts in the receiver.

- (NSEnumerator *)contextEnumerator

Return Value

An NSEnumerator

Discussion

Returns an NSEnumerator of all contexts in the receiver.

Declared In

RedlandModel-Convenience.m

enumeratorOfArcsIn:

Returns an enumerator of all arcs going into targetNode.

- (NSEnumerator *)enumeratorOfArcsIn:(RedlandNode *)targetNode

Parameters

targetNode

The node to use as target/object

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all arcs going into targetNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfArcsIn:context:

Returns an enumerator of all arcs going into targetNode in context contextNode.

- (NSEnumerator *)enumeratorOfArcsIn:(RedlandNode *)targetNode context:(RedlandNode *)contextNode

Parameters

targetNode

The node to use as target/object

contextNode

The node to use as context

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all arcs going into targetNode in context contextNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfArcsOut:

Returns an enumerator of all arcs coming out of sourceNode.

- (NSEnumerator *)enumeratorOfArcsOut:(RedlandNode *)sourceNode

Discussion

Returns an enumerator of all arcs coming out of sourceNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfArcsOut:context:

Returns an enumerator of all arcs coming out of sourceNode in context contextNode.

- (NSEnumerator *)enumeratorOfArcsOut:(RedlandNode *)targetNode context:(RedlandNode *)contextNode

Parameters

targetNode

The node to use as subject (!)

contextNode

The node to use as context

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all arcs coming out of sourceNode in context contextNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfArcsWithSource:target:

Returns an enumerator of all arcs in the receiver with the given sourceNode and targetNode.

- (NSEnumerator *)enumeratorOfArcsWithSource:(RedlandNode *)sourceNode target:(RedlandNode *)targetNode

Parameters

sourceNode

The node to use as source/subject

targetNode

The node to use as target/object

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all arcs in the receiver with the given sourceNode and targetNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfArcsWithSource:target:context:

Returns an enumerator of all arcs in the receiver with the given sourceNode, targetNode, and context.

- (NSEnumerator *)enumeratorOfArcsWithSource:(RedlandNode *)sourceNode target:(RedlandNode *)targetNode context:(RedlandNode *)contextNode

Parameters

sourceNode

The node to use as source/subject

targetNode

The node to use as target/object

contextNode

The node to use as context

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all arcs in the receiver with the given sourceNode, targetNode, and context.

Declared In

RedlandModel-Convenience.m

enumeratorOfSourcesWithArc:target:

Returns an enumerator of all sources in the receiver that have the given arcNode and targetNode.

- (NSEnumerator *)enumeratorOfSourcesWithArc:(RedlandNode *)arcNode target:(RedlandNode *)targetNode

Parameters

arcNode

The node to use as arc/predicate

targetNode

The node to use as target/object

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all sources in the receiver that have the given arcNode and targetNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfSourcesWithArc:target:context:

Returns an enumerator of all sources in the receiver that have the given arcNode, targetNode, and contextNode.

- (NSEnumerator *)enumeratorOfSourcesWithArc:(RedlandNode *)arcNode target:(RedlandNode *)targetNode context:(RedlandNode *)contextNode

Parameters

arcNode

The node to use as arc/predicate

targetNode

The node to use as target/object

contextNode

The node to use as context

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all sources in the receiver that have the given arcNode, targetNode, and contextNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfStatementsLike:

Returns an enumerator of all statements in the receiver that match the given statement.

- (RedlandStreamEnumerator *)enumeratorOfStatementsLike:(RedlandStatement *)aStatement

Parameters

aStatement

A (possibly partial) statement.

Return Value

A RedlandStreamEnumerator of the matching statements

Discussion

Returns an enumerator of all statements in the receiver that match the given statement.

Declared In

RedlandModel-Convenience.m

enumeratorOfStatementsLike:withContext:

Returns an enumerator of all statements in the receiver that match the given statement and context.

- (RedlandStreamEnumerator *)enumeratorOfStatementsLike:(RedlandStatement *)aStatement withContext:(RedlandNode *)contextNode

Parameters

aStatement

A (possibly partial) statement

contextNode

The context

Return Value

A RedlandStreamEnumerator of the matching statements

Discussion

Returns an enumerator of all statements in the receiver that match the given statement and context.

Declared In

RedlandModel-Convenience.m

enumeratorOfTargetsWithSource:arc:

Returns an enumerator of all targets in the receiver with the given sourceNode and arcNode.

- (NSEnumerator *)enumeratorOfTargetsWithSource:(RedlandNode *)sourceNode arc:(RedlandNode *)arcNode

Parameters

sourceNode

The node to use as source/subject

arcNode

The node to use as arc/predicate

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all targets in the receiver with the given sourceNode and arcNode.

Declared In

RedlandModel-Convenience.m

enumeratorOfTargetsWithSource:arc:context:

Returns an enumerator of all targets in the receiver with the given sourceNode, arcNode, and contextNode.

- (NSEnumerator *)enumeratorOfTargetsWithSource:(RedlandNode *)sourceNode arc:(RedlandNode *)arcNode context:(RedlandNode *)contextNode

Parameters

sourceNode

The node to use as source/subject

arcNode

The node to use as arc/predicate

contextNode

The node to use as context

Return Value

An NSEnumerator

Discussion

Returns an enumerator of all targets in the receiver with the given sourceNode, arcNode, and contextNode.

Declared In

RedlandModel-Convenience.m

initWithStorage:

Initialises a new RedlandModel using the given storage.

- (id)initWithStorage:(RedlandStorage *)aStorage

Parameters

aStorage

The storage to use for the new model

Discussion

Initialises a new RedlandModel using the given storage.

Declared In

RedlandModel.m

loadURL:withContext:

Fetches data from the given URL using the Cocoa NSURL loading system, parses it with a parser deduced from the returned MIME type, and adds the statements into the given context of the receiver.

- (void)loadURL:(NSURL *)aURL withContext:(RedlandNode *)context

Parameters

aURL

The NSURL to load

context

an optional context

Discussion

Fetches data from the given URL using the Cocoa NSURL loading system, parses it with a parser deduced from the returned MIME type, and adds the statements into the given context of the receiver.

Warning: This is a nice and uncomplicated convenience function, but it will block until the data has been downloaded and parsed. If the parser type cannot be guessed from the MIME type, an RDF/XML parser will be used.

Declared In

RedlandParser.m

node:hasIncomingArc:

Returns YES if targetNode has at least one incoming arc arcNode.

- (BOOL)node:(RedlandNode *)targetNode hasIncomingArc:(RedlandNode *)arcNode

Parameters

targetNode

The node to query

arcNode

The arc (or predicate)

Discussion

Returns YES if targetNode has at least one incoming arc arcNode.

Declared In

RedlandModel.m

node:hasOutgoingArc:

Returns YES if sourceNode has at least one outgoing arc arcNode.

- (BOOL)node:(RedlandNode *)sourceNode hasOutgoingArc:(RedlandNode *)arcNode

Parameters

sourceNode

The node to query

arcNode

The arc (or predicate)

Discussion

Returns YES if sourceNode has at least one outgoing arc arcNode.

Declared In

RedlandModel.m

removeAllStatementsWithContext:

Removes all statements with the given context from the receiver.

- (void)removeAllStatementsWithContext:(RedlandNode *)contextNode

Parameters

contextNode

The context of the statements to remove

Discussion

Removes all statements with the given context from the receiver.

Declared In

RedlandModel.m

removeStatement:

Removes a single statement from the receiver.

- (BOOL)removeStatement:(RedlandStatement *)aStatement

Parameters

aStatement

A complete statement

Return Value

YES on success

Discussion

Removes a single statement from the receiver.

Declared In

RedlandModel.m

removeStatement:withContext:

Removes a single statement with the given context from the receiver.

- (BOOL)removeStatement:(RedlandStatement *)aStatement withContext:(RedlandNode *)contextNode

Parameters

aStatement

A complete statement

contextNode

The context of the statement to remove

Return Value

YES on success

Discussion

Removes a single statement with the given context from the receiver.

Declared In

RedlandModel.m

removeStatementsLike:

Removes all statements matching the given statement.

- (void)removeStatementsLike:(RedlandStatement *)aStatement

Parameters

aStatement

The RedlandStatement to find matches for

Discussion

Removes all statements matching the given statement.

At least one of the statement’s subject, predicate or object must be set.

Declared In

RedlandModel.m

removeSubmodel:

Remove a submodel from the receiver.

- (BOOL)removeSubmodel:(RedlandModel *)submodel

Parameters

submodel

The submodel to remove from the model, must not be nil

Return Value

A BOOL whether the action was successful

Discussion

Remove a submodel from the receiver.

Warning: Redland has a function “librdf_model_remove_submodel”, however it is labelled with a “FIXME: Not tested” and I was having trouble getting it to work properly. For this reason this method currently simply removes the statements/triples found in the submodel from the model. This will fail if any statement fails to be removed from the model (but it will not raise an exception).

Declared In

RedlandModel.m

serializedRDFXMLDataWithBaseURI:

Returns an RDF/XML serialization of the receiver using the given base URI.

- (NSData *)serializedRDFXMLDataWithBaseURI:(RedlandURI *)baseURI

Parameters

baseURI

The base-URI to use as RedlandURI

Return Value

NSData

Discussion

Returns an RDF/XML serialization of the receiver using the given base URI.

Declared In

RedlandSerializer.m

setValue:ofFeature:

Sets the model feature identified by featureURI to a new value.

- (void)setValue:(RedlandNode *)featureValue ofFeature:(id)featureURI

Parameters

featureValue

A RedlandNode representing the new value

featureURI

An NSString or a RedlandURI instance

Discussion

Sets the model feature identified by featureURI to a new value.

Warning: Raises a RedlandException is no such feature exists.

Declared In

RedlandModel.m

size

Returns the number of statements in the receiver.

- (int)size

Return Value

The number of statements in the model, or a negative value on failure.

Discussion

Returns the number of statements in the receiver.

Warning: Not all stores support this function. If you absolutely need an accurate size, you can enumerate the statements manually. Also, for submodels with the same store this still returns the size of the parent model.

Declared In

RedlandModel.m

sourceWithArc:target:

Returns one matching source in the receiver for the given arcNode and targetNode.

- (RedlandNode *)sourceWithArc:(RedlandNode *)arcNode target:(RedlandNode *)targetNode

Parameters

arcNode

The arc (or predicate)

targetNode

The target (or object)

Discussion

Returns one matching source in the receiver for the given arcNode and targetNode.

Declared In

RedlandModel.m

statementEnumerator

Returns an enumerator of all statements in the receiver.

- (RedlandStreamEnumerator *)statementEnumerator

Discussion

Returns an enumerator of all statements in the receiver.

Declared In

RedlandModel-Convenience.m

statementEnumeratorWithContext:

Returns an enumerator of all statements in the receiver with the given context.

- (RedlandStreamEnumerator *)statementEnumeratorWithContext:(RedlandNode *)contextNode

Parameters

contextNode

The context

Discussion

Returns an enumerator of all statements in the receiver with the given context.

Declared In

RedlandModel-Convenience.m

statementStream

Returns a stream of all statements in the receiver.

- (RedlandStream *)statementStream

Discussion

Returns a stream of all statements in the receiver.

Declared In

RedlandModel.m

statementsLike:withDescendants:

Returns all statements in the receiver that match the given statement, recursively if desired.

- (NSArray *)statementsLike:(RedlandStatement *)aStatement withDescendants:(BOOL)descendants

Parameters

aStatement

The statement/triple to match against

descendants

BOOL on whether to also retrieve descendant nodes

Return Value

An array full of matching RedlandStatement instances or nil if no statement was provided

Discussion

Returns all statements in the receiver that match the given statement, recursively if desired.

This method allows for recursive retrieval, i.e. it also returns nodes that as subject have the object of previously found triples.

Declared In

RedlandModel.m

storage

Returns the underlying RedlandStorage of the receiver.

- (RedlandStorage *)storage

Discussion

Returns the underlying RedlandStorage of the receiver.

Declared In

RedlandModel.m

streamOfAllStatementsWithContext:

Returns a stream of all statements with the given context.

- (RedlandStream *)streamOfAllStatementsWithContext:(RedlandNode *)contextNode

Parameters

contextNode

The context to stream

Discussion

Returns a stream of all statements with the given context.

Declared In

RedlandModel.m

streamOfStatementsLike:

Returns a RedlandStream of all statements matching the given statement.

- (RedlandStream *)streamOfStatementsLike:(RedlandStatement *)aStatement

Parameters

aStatement

A (possibly partial) statement

Discussion

Returns a RedlandStream of all statements matching the given statement.

Declared In

RedlandModel.m

streamOfStatementsLike:withContext:

Returns a RedlandStream of statements matching the given statement and context.

- (RedlandStream *)streamOfStatementsLike:(RedlandStatement *)aStatement withContext:(RedlandNode *)contextNode

Parameters

aStatement

A (possibly partial) statement

contextNode

The context

Discussion

Returns a RedlandStream of statements matching the given statement and context.

Declared In

RedlandModel.m

submodelForSubject:

Creates a sub-model from triples found in the receiver that relate to the given subject node.

- (RedlandModel *)submodelForSubject:(RedlandNode *)aSubject

Parameters

aSubject

The subject node for which to retrieve triples

Return Value

A RedlandModel instance or nil if no subject was provided

Discussion

Creates a sub-model from triples found in the receiver that relate to the given subject node.

Declared In

RedlandModel.m

sync

Synchronises the model to the model implementation.

- (void)sync

Discussion

Synchronises the model to the model implementation.

Declared In

RedlandModel.m

targetWithSource:arc:

Returns one matching target in the receiver for the given sourceNode and arcNode.

- (RedlandNode *)targetWithSource:(RedlandNode *)sourceNode arc:(RedlandNode *)arcNode

Parameters

sourceNode

The source (or subject)

arcNode

The arc (or predicate)

Discussion

Returns one matching target in the receiver for the given sourceNode and arcNode.

Declared In

RedlandModel.m

valueOfFeature:

Returns the value of the model feature identified by featureURI.

- (RedlandNode *)valueOfFeature:(id)featureURI

Parameters

featureURI

An NSString or a RedlandURI instance

Discussion

Returns the value of the model feature identified by featureURI.

Declared In

RedlandModel.m

wrappedModel

Returns the underlying librdf_model pointer of the receiver.

- (librdf_model *)wrappedModel

Discussion

Returns the underlying librdf_model pointer of the receiver.

Declared In

RedlandModel.m