KDE 4.7 PyKDE API Reference

- KDE's Python API

# Statement Class Reference

`from PyKDE4.soprano import *`

Namespace: Soprano

## Detailed Description

\class Statement statement.h Soprano/Statement

A Statement instance represents one RDF quadruple.

In %Soprano statements are quadruples, i.e. in addition to the subject, predicate, and object nodes, they have a fourth node, the context. The context represents the named graph in which the statement is stored. If the context is an empty node the statement is stored in the default graph.

A Statement is valid if subject, predicate, and object are valid. Invalid statements can, however, be used in many methods such as Model.listStatements as wildwards.

\sa Node

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

## Methods
| __init__ (self)
| __init__ (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
| __init__ (self, Soprano.Statement other)
Soprano.Node | context (self)
bool | isValid (self)
bool | matches (self, Soprano.Statement other)
Soprano.Node | object (self)
bool | operator != (self, Soprano.Statement other)
bool | operator == (self, Soprano.Statement other)
Soprano.Node | predicate (self)
| setContext (self, Soprano.Node context)
| setObject (self, Soprano.Node object)
| setPredicate (self, Soprano.Node predicate)
| setSubject (self, Soprano.Node subject)
Soprano.Node | subject (self)

## Method Documentation

__init__ | ( |  | self ) |

Default Constructor, build an empty (invalid) Statement.

__init__ | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Build a Statement with the given subject, predicate and object.

Parameters:

  | subject | The subject (cannot be of type Node.LiteralNode)

Parameters:

  | predicate | The predicate (has to be of type Node.ResourceNode or Node.EmptyNode)

Parameters:

  | object | The object can be of either Node type.

Parameters:

  | context | The context node (has to be of type Node.ResourceNode or Node.EmptyNode)

__init__ | ( | self, |
|  | Soprano.Statement | other
| ) |  |  |

Soprano.Node context | ( |  | self ) |

Returns:
  The Context node.

bool isValid | ( |  | self ) |

A Statement is valid if the subject is a resource or blank node, the predicate is a resource node, and the object is a valid node.

Returns:
  true if the Statement is valid, false otherwise

bool matches | ( | self, |
|  | Soprano.Statement | other
| ) |  |  |

Match this statement against template statement 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 statement matches other, false if not.

\sa Node.matches()

Soprano.Node object | ( |  | self ) |

Returns:
  The object.

bool operator != | ( | self, |
|  | Soprano.Statement | other
| ) |  |  |

bool operator == | ( | self, |
|  | Soprano.Statement | other
| ) |  |  |

Soprano.Node predicate | ( |  | self ) |

Returns:
  The predicate.

setContext | ( | self, |
|  | Soprano.Node | context
| ) |  |  |

Change the Statement context.

Parameters:

  | context | The new Context.

setObject | ( | self, |
|  | Soprano.Node | object
| ) |  |  |

Change the Statement object.

Parameters:

  | object | The new object.

setPredicate | ( | self, |
|  | Soprano.Node | predicate
| ) |  |  |

Change the Statement predicate.

Parameters:

  | predicate | The new predicate.

setSubject | ( | self, |
|  | Soprano.Node | subject
| ) |  |  |

Change the Statement subject.

Parameters:

  | subject | The new subject.

Soprano.Node subject | ( |  | self ) |

Returns:
  The subject.