Soprano  2.7.56
Public Types | Static Public Member Functions | Related Functions
Soprano::Node Class Reference

A Node represents one RDF resource. More...

#include <Soprano/Node>

List of all members.

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
Nodeoperator= (const Node &other)
Nodeoperator= (const QUrl &resource)
Nodeoperator= (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 QTextStreamoperator<< (QTextStream &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.

Author:
Daniele Galdi danie.nosp@m.le.g.nosp@m.aldi@.nosp@m.gmai.nosp@m.l.com
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org

Definition at line 53 of file node.h.


Member Enumeration Documentation

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

Definition at line 56 of file node.h.

Parsing flags to infuence the behaviour of the parser in fromN3() and fromN3Stream().

Since:
2.5
Enumerator:
NoFlags 

No parsing flags, default behaviour.

StrictLiteralTypes 

Use strict literal parsing, i.e. do not treat true and false as boolean literals or do not handle numbers as literals if they do not contain a literal type.

StrictUris 

Use strict URI parsing.

See also:
QUrl::StrictMode
IgnorePrefixes 

Do not make use of m_prefixes

Definition at line 444 of file node.h.


Constructor & Destructor Documentation

Default costructor. Creates an empty node.

See also:
createEmptyNode()
Soprano::Node::Node ( const QUrl uri)

Creates a resource node.

Parameters:
uriThe 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]

Creates a blank node.

Parameters:
idAn identifier for the blank node.
See also:
createBlankNode()
Soprano::Node::Node ( const LiteralValue value)

Creates a literal node.

Parameters:
valueThe 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:
valueThe value of a node. If empty the node will become an empty node.
languageThe language of the literal value.
See also:
createLiteralNode()
Deprecated:
Use Soprano::Node::Node( const LiteralValue& ) and Soprano::LiteralValue::createPlainLiteral( const QString&, const LanguageTag& )
Soprano::Node::Node ( const Node other)

Copy constructor.

Default costructor. Creates an empty node.

See also:
createEmptyNode()

Member Function Documentation

Node& Soprano::Node::operator= ( const Node other)

Assigns resource to this node and makes it a ResourceNode.

Node& Soprano::Node::operator= ( const QUrl resource)

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.

Returns:
true if this node and other are equal.
bool Soprano::Node::operator!= ( const Node other) const

Comparision operator.

Returns:
true if this node and other differ.
bool Soprano::Node::operator== ( const QUrl uri) const

Comparision operator.

Returns:
true if this node is a ResourceNode and has URI uri.
bool Soprano::Node::operator== ( const LiteralValue other) const

Comparision operator.

Returns:
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:

 // NOT always true:
 a.matches(b) == b.matches(a)
Returns:
true if this node matches other, false if not.
See also:
Statement::matches
Returns:
The node type.
bool Soprano::Node::isEmpty ( ) const
Returns:
true if the node is empty.
bool Soprano::Node::isValid ( ) const
Returns:
true if the node is a ResourceNode, LiteralNode or BlankNode.
bool Soprano::Node::isLiteral ( ) const
Returns:
true if the node is a LiteralNode.
bool Soprano::Node::isResource ( ) const
Returns:
true if the node is a ResourceNode.
bool Soprano::Node::isBlank ( ) const
Returns:
true if the node is a BlankNode (anonymous).
Returns:
The URI if the node is a ResourceNode. An null QUrl otherwise.

Retrieve a blank node's identifier.

Returns:
The node's identifier if it is a BlankNode, a null string otherwise.
Returns:
The literal value if the node is a LiteralNode. An null QString otherwise.
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

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().

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()

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:
resourceToN3(), literalToN3(), blankToN3(), fromN3(), toString()
Since:
2.2
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 Node Soprano::Node::createResourceNode ( const QUrl uri) [static]

Convenience method to create a resource node. Using this method instead of the constructor may result in better readable code.

Parameters:
uriThe URI of the node. If empty the type will be ignored and an empty node will be created.
Returns:
A resource Node or an empty Node if the specified URI is empty.
static Node Soprano::Node::createBlankNode ( const QString id) [static]

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:
idAn identifier for the blank node.
Returns:
A blank node or an empty Node if the specified identifier 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:
valueThe 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
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:
valueThe value of a node. If empty the node will become an empty node.
languageThe language of the literal value.
Returns:
A literal node or an empty node if the specified value was empty.
Deprecated:
Use Soprano::Node::createLiteralNode( const LiteralValue& ) and Soprano::LiteralValue::createPlainLiteral( const QString&, const LanguageTag& )
static QString Soprano::Node::resourceToN3 ( const QUrl resource) [static]

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(), fromN3()
Since:
2.3
static QString Soprano::Node::blankToN3 ( const QString blank) [static]

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(), fromN3()
Since:
2.3
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(), fromN3()
Since:
2.3
static Node Soprano::Node::fromN3 ( const QString n3,
N3ParserFlags  flags = NoFlags 
) [static]

Convert a node from its N3 representation.

Parameters:
n3The N3 representation of the node.
Returns:
A Node representing the parsed version of n3 or an invalid Node in case parsing failed.
See also:
resourceToN3(), literalToN3(), blankToN3(), toN3()
Since:
2.5
static Node Soprano::Node::fromN3Stream ( QTextStream stream,
N3ParserFlags  flags = NoFlags 
) [static]

Read a node from its N3 representation on a stream.

Parameters:
streamThe stream from which the N3 representation of the node will be read.
Returns:
A Node representing the parsed version of n3 or an invalid Node in case parsing failed.
See also:
resourceToN3(), literalToN3(), blankToN3(), toN3()
Since:
2.5

Friends And Related Function Documentation

SOPRANO_EXPORT uint qHash ( const Node node) [related]
SOPRANO_EXPORT QDebug operator<< ( QDebug  s,
const Soprano::Node  
) [related]
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()

The documentation for this class was generated from the following file: