|
Soprano
2.9.2
|
A Node represents one RDF resource. More...
#include <Soprano/Node>
Public Types | |
| enum | Type { EmptyNode = 0, ResourceNode = 1, LiteralNode = 2, BlankNode = 3 } |
| enum | N3ParserFlag { NoFlags = 0x0, StrictLiteralTypes = 0x1, StrictUris = 0x2, IgnorePrefixes = 0x4 } |
Public Member Functions | |
Constructors | |
| Node () | |
| Node (const QUrl &uri) | |
| Node (const QString &id) | |
| Node (const LiteralValue &value) | |
| SOPRANO_CONSTRUCTOR_DEPRECATED | Node (const LiteralValue &value, const QString &language) |
| Node (const Node &other) | |
| ~Node () | |
Operators | |
| Node & | operator= (const Node &other) |
| Node & | operator= (const QUrl &resource) |
| Node & | operator= (const LiteralValue &literal) |
| bool | operator== (const Node &other) const |
| bool | operator!= (const Node &other) const |
| bool | operator== (const QUrl &uri) const |
| bool | operator== (const LiteralValue &other) const |
| bool | matches (const Node &other) const |
Type information | |
| Type | type () const |
| bool | isEmpty () const |
| bool | isValid () const |
| bool | isLiteral () const |
| bool | isResource () const |
| bool | isBlank () const |
Resource nodes | |
| QUrl | uri () const |
Blank nodes | |
| QString | identifier () const |
Literal nodes | |
| LiteralValue | literal () const |
| QUrl | dataType () const |
| QString | language () const |
Conversion | |
| QString | toString () const |
| QString | toN3 () const |
Static Public Member Functions | |
| static Node | createEmptyNode () |
| static Node | createResourceNode (const QUrl &uri) |
| static Node | createBlankNode (const QString &id) |
| static Node | createLiteralNode (const LiteralValue &value) |
| static SOPRANO_DEPRECATED Node | createLiteralNode (const LiteralValue &value, const QString &language) |
| static QString | resourceToN3 (const QUrl &resource) |
| static QString | blankToN3 (const QString &blank) |
| static QString | literalToN3 (const LiteralValue &literal) |
| static Node | fromN3 (const QString &n3, N3ParserFlags flags=NoFlags) |
| static Node | fromN3Stream (QTextStream &stream, N3ParserFlags flags=NoFlags) |
Related Functions | |
(Note that these are not member functions.) | |
| SOPRANO_EXPORT uint | qHash (const Node &node) |
| SOPRANO_EXPORT QDebug | operator<< (QDebug s, const Soprano::Node &) |
| SOPRANO_EXPORT QTextStream & | operator<< (QTextStream &s, const Soprano::Node &) |
A Node represents one RDF resource.
Nodes are the cornerstone of RDF data in Soprano. Four Nodes form one Statement and a Model is essentially a set of Statements.
A Node can have one of four types: EmptyNode, ResourceNode, LiteralNode, and BlankNode. Resource nodes are identified through their URI (uri()), literal nodes have a LiteralValue (literal()), and blank nodes have a string identifier.
Empty nodes can be used as wildcards in methods such as Model::listStatements.
| enum Soprano::Node::Type |
| Enumerator | |
|---|---|
| EmptyNode |
An empty node, can be used as a wildcard in commands like Model::listStatements. |
| ResourceNode |
A resource node has a URI which can be accessed via uri() |
| LiteralNode |
A literal node has a literal value and an optional language. |
| BlankNode |
A blank node has an identifier string |
Parsing flags to infuence the behaviour of the parser in fromN3() and fromN3Stream().
| Soprano::Node::Node | ( | ) |
Default costructor. Creates an empty node.
| Soprano::Node::Node | ( | const QUrl & | uri | ) |
Creates a resource node.
| uri | The URI of the node. If empty the type will be ignored and an empty node will be created. |
|
explicit |
| Soprano::Node::Node | ( | const LiteralValue & | value | ) |
Creates a literal node.
| value | The value of a node. If empty the node will become an empty node. |
| SOPRANO_CONSTRUCTOR_DEPRECATED Soprano::Node::Node | ( | const LiteralValue & | value, |
| const QString & | language | ||
| ) |
Creates a literal node.
| value | The value of a node. If empty the node will become an empty node. |
| language | The language of the literal value. |
| Soprano::Node::Node | ( | const Node & | other | ) |
Copy constructor.
| Soprano::Node::~Node | ( | ) |
Default costructor. Creates an empty node.
Assigns resource to this node and makes it a ResourceNode.
Assigns resource to this node and makes it a ResourceNode.
| Node& Soprano::Node::operator= | ( | const LiteralValue & | literal | ) |
Assigns literal to this node and makes it a LiteralNode.
| bool Soprano::Node::operator== | ( | const Node & | other | ) | const |
Comparision operator.
true if this node and other are equal. | bool Soprano::Node::operator!= | ( | const Node & | other | ) | const |
Comparision operator.
true if this node and other differ. | bool Soprano::Node::operator== | ( | const QUrl & | uri | ) | const |
Comparision operator.
true if this node is a ResourceNode and has URI uri. | bool Soprano::Node::operator== | ( | const LiteralValue & | other | ) | const |
Comparision operator.
true if this node is a LiteralNode and has literal value other. | bool Soprano::Node::matches | ( | const Node & | other | ) | const |
Match this node against template node other. The only difference to operator== is that empty nodes are matched as wildcards, i.e. they match any other node.
Be aware that the following is NOT always true since only other is treated a a wildcard:
true if this node matches other, false if not.| Type Soprano::Node::type | ( | ) | const |
| bool Soprano::Node::isEmpty | ( | ) | const |
true if the node is empty. | bool Soprano::Node::isValid | ( | ) | const |
true if the node is a ResourceNode, LiteralNode or BlankNode. | bool Soprano::Node::isLiteral | ( | ) | const |
true if the node is a LiteralNode. | bool Soprano::Node::isResource | ( | ) | const |
true if the node is a ResourceNode. | bool Soprano::Node::isBlank | ( | ) | const |
true if the node is a BlankNode (anonymous). | QUrl Soprano::Node::uri | ( | ) | const |
| QString Soprano::Node::identifier | ( | ) | const |
Retrieve a blank node's identifier.
| LiteralValue Soprano::Node::literal | ( | ) | const |
| QUrl Soprano::Node::dataType | ( | ) | const |
| QString Soprano::Node::language | ( | ) | const |
Each literal value can have an associated language, thus each property can be stored for different languages. An empty language refers to the default language.
| QString Soprano::Node::toString | ( | ) | const |
Converts the Node to a string.
| QString Soprano::Node::toN3 | ( | ) | const |
Convert a Node into N3 notation to be used in SPARQL graph patterns.
Examples:
|
static |
Convenience method to create an empty node. Using this method instead of the default constructor may result in better readable code.
Convenience method to create a resource node. Using this method instead of the constructor may result in better readable code.
| uri | The URI of the node. If empty the type will be ignored and an empty node will be created. |
Convenience method to create a blank node. Using this method instead of the constructor may result in better readable code.
If you need to create a new blank node which is not used in the model yet and, thus, has a unique identifier see Model::createBlankNode().
| id | An identifier for the blank node. |
|
static |
Convenience method to create a literal node. Using this method instead of the constructor may result in better readable code.
| value | The value of a node. If empty the node will become an empty node. |
|
static |
Convenience method to create a literal node. Using this method instead of the constructor may result in better readable code.
| value | The value of a node. If empty the node will become an empty node. |
| language | The language of the literal value. |
|
static |
Format a literal value as N3 string to be used in SPARQL queries.
Examples:
Convert a node from its N3 representation.
| n3 | The N3 representation of the node. |
n3 or an invalid Node in case parsing failed.
|
static |
Read a node from its N3 representation on a stream.
| stream | The stream from which the N3 representation of the node will be read. |
n3 or an invalid Node in case parsing failed.
|
related |
|
related |
|
related |
Default Soprano::Node stream operator. The operator serializes the Node based on the N-Triples standard, except that it uses Unicode strings.
1.8.5