soprano
Soprano::Node Class Reference
A Node represents one RDF resource. More...
#include <Soprano/Node>
Public Types | |
| enum | Type { EmptyNode = 0, ResourceNode = 1, LiteralNode = 2, BlankNode = 3 } |
Public Member Functions | |
Constructors | |
| Node (const Node &other) | |
| SOPRANO_CONSTRUCTOR_DEPRECATED | Node (const LiteralValue &value, const QString &language) |
| Node (const LiteralValue &value) | |
| Node (const QString &id) | |
| Node (const QUrl &uri) | |
| Node () | |
| ~Node () | |
Literal nodes | |
| QUrl | dataType () const |
| QString | language () const |
| LiteralValue | literal () const |
Blank nodes | |
| QString | identifier () const |
Type information | |
| bool | isBlank () const |
| bool | isEmpty () const |
| bool | isLiteral () const |
| bool | isResource () const |
| bool | isValid () const |
| Type | type () const |
Operators | |
| bool | matches (const Node &other) const |
| bool | operator!= (const Node &other) const |
| Node & | operator= (const LiteralValue &literal) |
| Node & | operator= (const QUrl &resource) |
| Node & | operator= (const Node &other) |
| bool | operator== (const LiteralValue &other) const |
| bool | operator== (const QUrl &uri) const |
| bool | operator== (const Node &other) const |
Conversion | |
| QString | toN3 () const |
| QString | toString () const |
Resource nodes | |
| QUrl | uri () const |
Static Public Member Functions | |
| static QString | blankToN3 (const QString &blank) |
| static Node | createBlankNode (const QString &id) |
| static Node | createEmptyNode () |
| static SOPRANO_DEPRECATED Node | createLiteralNode (const LiteralValue &value, const QString &language) |
| static Node | createLiteralNode (const LiteralValue &value) |
| static Node | createResourceNode (const QUrl &uri) |
| static QString | literalToN3 (const LiteralValue &literal) |
| static QString | resourceToN3 (const QUrl &resource) |
Related Functions | |
(Note that these are not member functions.) | |
| SOPRANO_EXPORT QTextStream & | operator<< (QTextStream &s, const Soprano::Node &) |
| SOPRANO_EXPORT QDebug | operator<< (QDebug s, const Soprano::Node &) |
Detailed Description
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.
Definition at line 53 of file node.h.
Member Enumeration Documentation
| 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.
Constructor & Destructor Documentation
| Soprano::Node::Node | ( | ) |
| Soprano::Node::Node | ( | const QUrl & | uri | ) |
Creates a resource node.
- Parameters:
-
uri The URI of the node. If empty the type will be ignored and an empty node will be created.
- See also:
- createResourceNode()
| Soprano::Node::Node | ( | const QString & | id | ) | [explicit] |
| Soprano::Node::Node | ( | const LiteralValue & | value | ) |
Creates a literal node.
- Parameters:
-
value The value of a node. If empty the node will become an empty node.
- See also:
- createLiteralNode()
- Since:
- 2.3
| SOPRANO_CONSTRUCTOR_DEPRECATED Soprano::Node::Node | ( | const LiteralValue & | value, | |
| const QString & | language | |||
| ) |
Creates a literal node.
- Parameters:
-
value The value of a node. If empty the node will become an empty node. language The language of the literal value.
- See also:
- createLiteralNode()
| Soprano::Node::Node | ( | const Node & | other | ) |
Copy constructor.
| Soprano::Node::~Node | ( | ) |
Member Function Documentation
Format a blank node identifier as N3 string to be used in SPARQL queries.
- Returns:
- A string representing the blank identifier in N3 encoding or an empty string for invalid/empty ids.
Example:
_:blankNode
- See also:
- toN3
- Since:
- 2.3
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().
- Parameters:
-
id An identifier for the blank node.
- Returns:
- A blank node or an empty Node if the specified identifier was empty.
| static Node Soprano::Node::createEmptyNode | ( | ) | [static] |
Convenience method to create an empty node.
Using this method instead of the default constructor may result in better readable code.
- Returns:
- An empty Node.
| static SOPRANO_DEPRECATED Node Soprano::Node::createLiteralNode | ( | const LiteralValue & | value, | |
| const QString & | language | |||
| ) | [static] |
Convenience method to create a literal node.
Using this method instead of the constructor may result in better readable code.
- Parameters:
-
value The value of a node. If empty the node will become an empty node. language The language of the literal value.
- Returns:
- A literal node or an empty node if the specified value was empty.
| static Node Soprano::Node::createLiteralNode | ( | const LiteralValue & | value | ) | [static] |
Convenience method to create a literal node.
Using this method instead of the constructor may result in better readable code.
- Parameters:
-
value The value of a node. If empty the node will become an empty node.
- Returns:
- A literal node or an empty node if the specified value was empty.
- Since:
- 2.3
Convenience method to create a resource node.
Using this method instead of the constructor may result in better readable code.
- Parameters:
-
uri The URI of the node. If empty the type will be ignored and an empty node will be created.
| QUrl Soprano::Node::dataType | ( | ) | const |
- Returns:
- The datatype URI of a literal node, i.e. the XML schema type or an empty value if the node is not a LiteralNode.
- See also:
- LiteralValue::dataTypeUri
| QString Soprano::Node::identifier | ( | ) | const |
Retrieve a blank node's identifier.
- Returns:
- The node's identifier if it is a BlankNode, a null string otherwise.
| bool Soprano::Node::isBlank | ( | ) | const |
- Returns:
trueif the node is a BlankNode (anonymous).
| bool Soprano::Node::isEmpty | ( | ) | const |
- Returns:
trueif the node is empty.
| bool Soprano::Node::isLiteral | ( | ) | const |
- Returns:
trueif the node is a LiteralNode.
| bool Soprano::Node::isResource | ( | ) | const |
- Returns:
trueif the node is a ResourceNode.
| bool Soprano::Node::isValid | ( | ) | const |
- Returns:
trueif the node is a ResourceNode, LiteralNode or BlankNode.
| 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.
- Returns:
- A string representing the language of the literal value or an empty string if the node is not a literal.
- Deprecated:
- Language exists on the Soprano::LiteralValue. Use Soprano::Node::literal() and Soprano::LiteralValue::language().
| LiteralValue Soprano::Node::literal | ( | ) | const |
- Returns:
- The literal value if the node is a LiteralNode. An null QString otherwise.
| static QString Soprano::Node::literalToN3 | ( | const LiteralValue & | literal | ) | [static] |
Format a literal value as N3 string to be used in SPARQL queries.
- Returns:
- A string representing the literal in N3 encoding or an empty string for invalid literals.
Examples:
"Hello World"^^<http://www.w3.org/2001/XMLSchema#string> "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>
- See also:
- toN3
- Since:
- 2.3
| 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:
// NOT always true:
a.matches(b) == b.matches(a)
- Returns:
trueif this node matches other,falseif not.
- See also:
- Statement::matches
| bool Soprano::Node::operator!= | ( | const Node & | other | ) | const |
Comparision operator.
- Returns:
trueif this node andotherdiffer.
| Node& Soprano::Node::operator= | ( | const LiteralValue & | literal | ) |
Assigns literal to this node and makes it a LiteralNode.
Assigns resource to this node and makes it a ResourceNode.
| bool Soprano::Node::operator== | ( | const LiteralValue & | other | ) | const |
Comparision operator.
- Returns:
trueif this node is a LiteralNode and has literal valueother.
| bool Soprano::Node::operator== | ( | const QUrl & | uri | ) | const |
Comparision operator.
- Returns:
trueif this node is a ResourceNode and has URIuri.
| bool Soprano::Node::operator== | ( | const Node & | other | ) | const |
Comparision operator.
- Returns:
trueif this node andotherare equal.
Format a resource URI as N3 string to be used in SPARQL queries.
- Returns:
- A string representing the resource in N3 encoding or an empty string for invalid URIs.
Example:
<http://soprano.sourceforce.net/>
- See also:
- toN3
- Since:
- 2.3
| QString Soprano::Node::toN3 | ( | ) | const |
Convert a Node into N3 notation to be used in SPARQL graph patterns.
Examples:
<http://soprano.sourceforce.net/> "Hello World"^^<http://www.w3.org/2001/XMLSchema#string> "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> _:blankNode
- Returns:
- A string representing the node in N3 encoding or an empty string for invalid nodes.
- See also:
- toString()
- Since:
- 2.2
| QString Soprano::Node::toString | ( | ) | const |
Converts the Node to a string.
- Returns:
- A String representation of the Node, suitable for storage, not really suitable for user readable strings.
- See also:
- LiteralValue::toString(), QUrl::toString(), toN3()
| Type Soprano::Node::type | ( | ) | const |
- Returns:
- The node type.
| QUrl Soprano::Node::uri | ( | ) | const |
- Returns:
- The URI if the node is a ResourceNode. An null QUrl otherwise.
Friends And Related Function Documentation
| SOPRANO_EXPORT QTextStream & operator<< | ( | QTextStream & | s, | |
| const Soprano::Node & | ||||
| ) | [related] |
Default Soprano::Node stream operator.
The operator serializes the Node based on the N-Triples standard, except that it uses Unicode strings.
- See also:
- Soprano::Node::toN3()
| SOPRANO_EXPORT QDebug operator<< | ( | QDebug | s, | |
| const Soprano::Node & | ||||
| ) | [related] |
The documentation for this class was generated from the following files:
KDE 4.4 API Reference