• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • Nepomuk2
  • Query
  • Term
Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Nepomuk2::Query::Term Class Reference

#include <Nepomuk2/Query/Term>

Inheritance diagram for Nepomuk2::Query::Term:
Inheritance graph
[legend]

Public Types

enum  Type {
  Invalid, Literal, Resource, And,
  Or, Comparison, ResourceType, Negation,
  Optional
}
 

Public Member Functions

 Term ()
 
 Term (const Term &other)
 
 ~Term ()
 
bool isAndTerm () const
 
bool isComparisonTerm () const
 
bool isLiteralTerm () const
 
bool isNegationTerm () const
 
bool isOptionalTerm () const
 
bool isOrTerm () const
 
bool isResourceTerm () const
 
bool isResourceTypeTerm () const
 
bool isValid () const
 
bool operator!= (const Term &term) const
 
QDebug operator<< (QDebug) const
 
Term & operator= (const Term &other)
 
bool operator== (const Term &term) const
 
Term optimized () const
 
void setUserData (const QString &key, const QVariant &value)
 
AndTerm toAndTerm () const
 
AndTerm & toAndTerm ()
 
ComparisonTerm toComparisonTerm () const
 
ComparisonTerm & toComparisonTerm ()
 
LiteralTerm toLiteralTerm () const
 
LiteralTerm & toLiteralTerm ()
 
NegationTerm toNegationTerm () const
 
NegationTerm & toNegationTerm ()
 
OptionalTerm toOptionalTerm () const
 
OptionalTerm & toOptionalTerm ()
 
OrTerm toOrTerm () const
 
OrTerm & toOrTerm ()
 
ResourceTerm toResourceTerm () const
 
ResourceTerm & toResourceTerm ()
 
ResourceTypeTerm toResourceTypeTerm () const
 
ResourceTypeTerm & toResourceTypeTerm ()
 
QString toString () const
 
Type type () const
 
QVariant userData (const QString &key) const
 

Static Public Member Functions

static Term fromString (const QString &s)
 
static Term fromVariant (const Variant &variant)
 

Related Functions

(Note that these are not member functions.)

static Term fromProperty (const Types::Property &property, const Variant &variant)
 

Detailed Description

The base class for all term types.

Queries are build from Term instances. A Term can have one of multiple types and subterms. See Term::Type for details on the different Term types.

Author
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org
Since
4.4

Definition at line 64 of file term.h.

Member Enumeration Documentation

enum Nepomuk2::Query::Term::Type

The type of a term identifying its meaning.

See also
type()
Enumerator
Invalid 

An invalid term matching nothing.

Literal 

A literal term is the simplest form of Term.

It simply contains a literal value.

See also
LiteralTerm
Resource 

A resource term matches one resource by URI.

See also
ResourceTerm
And 

Match all resources that match all sub terms.

See also
AndTerm
Or 

Match all resources that match one of the sub terms.

See also
OrTerm
Comparison 

A comparison.

The comparison operator needs to be specified in addition. A single subterm specifies the resource or value to match.

See also
ComparisonTerm
ResourceType 

Matches all resources of a specific type.

See also
ResourceTypeTerm
Negation 

A negation term inverts the meaning of its sub term.

See also
NegationTerm
Optional 

An optional term which marks its sub term as optional.

See also
OptionalTerm
Since
4.5

Definition at line 72 of file term.h.

Constructor & Destructor Documentation

Nepomuk2::Query::Term::Term ( )

Constructs an invalid term.

Definition at line 48 of file term.cpp.

Nepomuk2::Query::Term::Term ( const Term &  other)

Copy constructor.

Definition at line 54 of file term.cpp.

Nepomuk2::Query::Term::~Term ( )

Destructor.

Definition at line 66 of file term.cpp.

Member Function Documentation

Nepomuk2::Query::Term Nepomuk2::Query::Term::fromString ( const QString &  s)
static

Parse a Term that has been encoded as a string via toString().

Warning
This method can NOT parse SPARQL syntax.
See also
toString()
Since
4.5

Definition at line 344 of file term.cpp.

Nepomuk2::Query::Term Nepomuk2::Query::Term::fromVariant ( const Variant &  variant)
static

Construct a Term from a Variant value.

This is a convenience method that simplifies handling Nepomuk values. However, list variants are not supported and will result in an invalid Term.

Returns
A ResourceTerm in case variant is a resource, a LiteralTerm if variant is a supported literal value, or an invalid Term if variant is invalid or a list.
Since
4.6

Definition at line 351 of file term.cpp.

bool Nepomuk2::Query::Term::isAndTerm ( ) const
Returns
true if this term is an AndTerm.

Definition at line 187 of file term.cpp.

bool Nepomuk2::Query::Term::isComparisonTerm ( ) const
Returns
true if this term is a ComparisonTerm.

Definition at line 199 of file term.cpp.

bool Nepomuk2::Query::Term::isLiteralTerm ( ) const
Returns
true if this term is a LiteralTerm.

Definition at line 163 of file term.cpp.

bool Nepomuk2::Query::Term::isNegationTerm ( ) const
Returns
true if this term is a NegationTerm.

Definition at line 175 of file term.cpp.

bool Nepomuk2::Query::Term::isOptionalTerm ( ) const
Returns
true if this term is a OptionalTerm.
Since
4.5

Definition at line 181 of file term.cpp.

bool Nepomuk2::Query::Term::isOrTerm ( ) const
Returns
true if this term is an OrTerm.

Definition at line 193 of file term.cpp.

bool Nepomuk2::Query::Term::isResourceTerm ( ) const
Returns
true if this term is a ResourceTerm.

Definition at line 169 of file term.cpp.

bool Nepomuk2::Query::Term::isResourceTypeTerm ( ) const
Returns
true if this term is a ResourceTypeTerm.

Definition at line 205 of file term.cpp.

bool Nepomuk2::Query::Term::isValid ( ) const
Returns
true if the term is valid. A valid term can be used to construct a Query.

Definition at line 78 of file term.cpp.

bool Nepomuk2::Query::Term::operator!= ( const Term &  term) const

Comparison operator.

Returns
true if this term differs from term.
Since
4.6

Definition at line 390 of file term.cpp.

QDebug Nepomuk2::Query::Term::operator<< ( QDebug  dbg) const

Definition at line 533 of file term.cpp.

Nepomuk2::Query::Term & Nepomuk2::Query::Term::operator= ( const Term &  other)

Copy operator.

Definition at line 71 of file term.cpp.

bool Nepomuk2::Query::Term::operator== ( const Term &  term) const

Comparison operator.

Returns
true if this term is equal to term.

Definition at line 384 of file term.cpp.

Nepomuk2::Query::Term Nepomuk2::Query::Term::optimized ( ) const

Optimizes the term without changing its meaning.

This removes redundant terms such as NegationTerm and OptionalTerm nestings and flattens AndTerm and OrTerm hierarchies.

Returns
An optimized version of this term.
Since
4.6
See also
Query::optimized()

Definition at line 99 of file term.cpp.

void Nepomuk2::Query::Term::setUserData ( const QString &  key,
const QVariant &  value 
)

Store user data in the term.

Parameters
keykey identifying the use data. It must be unique for each each user of the Term class. This can be something like "yourapplication.some_data".
valuevalue associated with the key
Since
4.12

Definition at line 89 of file term.cpp.

Nepomuk2::Query::AndTerm Nepomuk2::Query::Term::toAndTerm ( ) const

Interpret this term as a AndTerm.

Returns
A copy of this term if its type is And, a new AndTerm otherwise.

Definition at line 248 of file term.cpp.

Nepomuk2::Query::AndTerm & Nepomuk2::Query::Term::toAndTerm ( )

Convert this term into a AndTerm.

If type is not And it will be changed and the result is a new AndTerm.

Returns
A reference to this term as a AndTerm.

Definition at line 313 of file term.cpp.

Nepomuk2::Query::ComparisonTerm Nepomuk2::Query::Term::toComparisonTerm ( ) const

Interpret this term as a ComparisonTerm.

Returns
A copy of this term if its type is Comparison, a new ComparisonTerm otherwise.

Definition at line 266 of file term.cpp.

Nepomuk2::Query::ComparisonTerm & Nepomuk2::Query::Term::toComparisonTerm ( )

Convert this term into a ComparisonTerm.

If type is not Comparison it will be changed and the result is a new ComparisonTerm.

Returns
A reference to this term as a ComparisonTerm.

Definition at line 325 of file term.cpp.

Nepomuk2::Query::LiteralTerm Nepomuk2::Query::Term::toLiteralTerm ( ) const

Interpret this term as a LiteralTerm.

Returns
A copy of this term if its type is Literal, a new LiteralTerm otherwise.

Definition at line 211 of file term.cpp.

Nepomuk2::Query::LiteralTerm & Nepomuk2::Query::Term::toLiteralTerm ( )

Convert this term into a LiteralTerm.

If type is not Literal it will be changed and the result is a new LiteralTerm.

Returns
A reference to this term as a LiteralTerm.

Definition at line 289 of file term.cpp.

Nepomuk2::Query::NegationTerm Nepomuk2::Query::Term::toNegationTerm ( ) const

Interpret this term as a NegationTerm.

Returns
A copy of this term if its type is Negation, a new NegationTerm otherwise.

Definition at line 230 of file term.cpp.

Nepomuk2::Query::NegationTerm & Nepomuk2::Query::Term::toNegationTerm ( )

Convert this term into a NegationTerm.

If type is not Negation it will be changed and the result is a new NegationTerm.

Returns
A reference to this term as a NegationTerm.

Definition at line 301 of file term.cpp.

Nepomuk2::Query::OptionalTerm Nepomuk2::Query::Term::toOptionalTerm ( ) const

Interpret this term as a OptionalTerm.

Returns
A copy of this term if its type is Optional, a new OptionalTerm otherwise.
Since
4.5

Definition at line 239 of file term.cpp.

Nepomuk2::Query::OptionalTerm & Nepomuk2::Query::Term::toOptionalTerm ( )

Convert this term into a OptionalTerm.

If type is not Optional it will be changed and the result is a new OptionalTerm.

Returns
A reference to this term as a OptionalTerm.
Since
4.5

Definition at line 307 of file term.cpp.

Nepomuk2::Query::OrTerm Nepomuk2::Query::Term::toOrTerm ( ) const

Interpret this term as a OrTerm.

Returns
A copy of this term if its type is Or, a new OrTerm otherwise.

Definition at line 257 of file term.cpp.

Nepomuk2::Query::OrTerm & Nepomuk2::Query::Term::toOrTerm ( )

Convert this term into a OrTerm.

If type is not Or it will be changed and the result is a new OrTerm.

Returns
A reference to this term as a OrTerm.

Definition at line 319 of file term.cpp.

Nepomuk2::Query::ResourceTerm Nepomuk2::Query::Term::toResourceTerm ( ) const

Interpret this term as a ResourceTerm.

Returns
A copy of this term if its type is Resource, a new ResourceTerm otherwise.

Definition at line 221 of file term.cpp.

Nepomuk2::Query::ResourceTerm & Nepomuk2::Query::Term::toResourceTerm ( )

Convert this term into a ResourceTerm.

If type is not Resource it will be changed and the result is a new ResourceTerm.

Returns
A reference to this term as a ResourceTerm.

Definition at line 295 of file term.cpp.

Nepomuk2::Query::ResourceTypeTerm Nepomuk2::Query::Term::toResourceTypeTerm ( ) const

Interpret this term as a ResourceTypeTerm.

Returns
A copy of this term if its type is ClassType, a new ResourceTypeTerm otherwise.

Definition at line 275 of file term.cpp.

Nepomuk2::Query::ResourceTypeTerm & Nepomuk2::Query::Term::toResourceTypeTerm ( )

Convert this term into a ResourceTypeTerm.

If type is not ClassType it will be changed and the result is a new ResourceTypeTerm.

Returns
A reference to this term as a ResourceTypeTerm.

Definition at line 331 of file term.cpp.

QString Nepomuk2::Query::Term::toString ( ) const

Encode the Term in a string.

Be aware that this does NOT create a SPARQL query. The returned string can be used to serialize terms that can later be read via fromString().

See also
fromString()
Since
4.5

Definition at line 337 of file term.cpp.

Nepomuk2::Query::Term::Type Nepomuk2::Query::Term::type ( ) const
Returns
the Term type.

Definition at line 84 of file term.cpp.

QVariant Nepomuk2::Query::Term::userData ( const QString &  key) const

Get the user data associated with a key.

If the key does not exist, an invalid QVariant is returned.

Since
4.12

Definition at line 94 of file term.cpp.

Friends And Related Function Documentation

Nepomuk2::Query::Term Nepomuk2::Query::Term::fromProperty ( const Types::Property &  property,
const Variant &  variant 
)
related

Create a term using a Types::Property and a Variant.

Sadly this cannot be modelled as an operator since it would clash with Entity::operator==().

Parameters
propertyThe property to be used in the ComparisonTerm.
variantThe value to be compared to. Either ResourceTerm or LiteralTerm is used. List variants (Variant::isList()) are handled via an AndTerm meaning all values need to match.
Since
4.6

Definition at line 369 of file term.cpp.


The documentation for this class was generated from the following files:
  • term.h
  • term.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal