# class Node

###

Module | soprano
Namespace | Soprano
Class | Node
Inherits |

\class Node node.h 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 an optional language string (language()), and blank nodes have a string identifier.

Empty nodes can be used as wildcards in methods such as Model.listStatements.

Be aware that string literals in %Soprano always have type xsd:string. There is no direct support for rdfs:Literal. Backend implementations should honour this restriction.

Author Daniele Galdi <daniele.galdi@gmail.com>
Sebastian Trueg <trueg@kde.org>

### enums

- Type { EmptyNode, ResourceNode, LiteralNode, BlankNode }

enum details

### methods

- Node ( )

  returns ctor

  Default costructor. Creates an empty node.

  See also createEmptyNode()

- Node (uri)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  uri | QUrl |

  Creates a resource node.

  uri - The URI of the node. If empty the type will be ignored and an empty node will be created.

  See also createResourceNode()

- Node (id)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  id | QString |

  Creates a blank node.

  id - An identifier for the blank node.

  See also createBlankNode()

- Node (value, language)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  value | Soprano.LiteralValue |
  language | QString | QString()

  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.

  See also createLiteralNode()

- Node (other)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  other | Soprano.Node |

- createBlankNode (id)

  returns Soprano.Node
  static

  Argument | Type | Default
  --- | --- | ---
  id | QString |

  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.

  Returns A blank node or an empty Node if the specified identifier was empty.

- createEmptyNode ( )

  returns Soprano.Node
  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.

- createLiteralNode (value, language)

  returns Soprano.Node
  static

  Argument | Type | Default
  --- | --- | ---
  value | Soprano.LiteralValue |
  language | QString |

  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.

  Returns A literal node or an empty node if the specified value was empty.

- createResourceNode (uri)

  returns Soprano.Node
  static

  Argument | Type | Default
  --- | --- | ---
  uri | QUrl |

  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.

  Returns A resource Node or an empty Node if the specified URI is empty.

- dataType ( )

  returns QUrl

  Returns The datatype URI of a literal node, i.e. the XML schema type or an empty value if the node is not a literal.

  See also LiteralValue.dataTypeUri

- identifier ( )

  returns QString

  Retrieve a blank node's identifier. Returns The node's identifier if it is a blank node, a null string otherwise.

- isBlank ( )

  returns bool

  Returns true if the Node is a Blank node (anonymous).

- isEmpty ( )

  returns bool

  Returns true if the Node is empty.

- isLiteral ( )

  returns bool

  Returns true if the Node is a Literal.

- isResource ( )

  returns bool

  Returns true if the Node is a Resource.

- isValid ( )

  returns bool

  Returns true if the Node is a Resource,Literal or Blank.

- language ( )

  returns QString

  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.

- literal ( )

  returns Soprano.LiteralValue

  Returns The Literal value if the node is a Literal node. An null QString otherwise.

- matches (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | Soprano.Node |

  Match this node against other. The only difference to operator== is that empty nodes are matched as wildcards, i.e. they match any other node.

  Returns true if this node matches other, false if not.

- operator != (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | Soprano.Node |

- operator == (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | Soprano.Node |

- operator == (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | QUrl |

- operator == (other)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  other | Soprano.LiteralValue |

- toString ( )

  returns QString

  Converts the Node to a string.

  Returns A String representation of the Node.

  See also LiteralValue.toString(), QUrl.toString()

- type ( )

  returns Soprano.Node.Type

  Returns The Node type.

- uri ( )

  returns QUrl

  Returns The URI if the node is a Resource node. An null QUrl otherwise.

### enums - detail

- Type { EmptyNode, ResourceNode, LiteralNode, BlankNode }

  | EmptyNode | - 0 | - |
  | ResourceNode | - 1 | - |
  | LiteralNode | - 2 | - |
  | BlankNode | - 3 | - |