syndication/rdf
dublincore.cpp
00001 /* 00002 * This file is part of the syndication library 00003 * 00004 * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #include "dublincore.h" 00024 #include "dublincorevocab.h" 00025 #include "property.h" 00026 #include "statement.h" 00027 00028 #include <tools.h> 00029 00030 #include <QtCore/QList> 00031 #include <QtCore/QString> 00032 #include <QtCore/QStringList> 00033 00034 namespace Syndication { 00035 namespace RDF { 00036 00037 00038 00039 DublinCore::DublinCore(ResourcePtr resource) : ResourceWrapper(resource) 00040 { 00041 } 00042 00043 DublinCore::~DublinCore() 00044 { 00045 } 00046 00047 QString DublinCore::contributor() const 00048 { 00049 return resource()->property(DublinCoreVocab::self()->contributor())->asString(); 00050 } 00051 00052 QStringList DublinCore::contributors() const 00053 { 00054 QStringList res; 00055 QList<StatementPtr> list = resource()->properties(DublinCoreVocab::self()->contributor()); 00056 QList<StatementPtr>::ConstIterator it = list.constBegin(); 00057 QList<StatementPtr>::ConstIterator end = list.constEnd(); 00058 for ( ; it != end; ++it) 00059 { 00060 QString str = (*it)->asString(); 00061 if (!str.isNull()) 00062 res.append(str); 00063 } 00064 return res; 00065 } 00066 00067 QString DublinCore::coverage() const 00068 { 00069 return resource()->property(DublinCoreVocab::self()->coverage())->asString(); 00070 } 00071 00072 QString DublinCore::creator() const 00073 { 00074 return resource()->property(DublinCoreVocab::self()->creator())->asString(); 00075 } 00076 00077 QStringList DublinCore::creators() const 00078 { 00079 QStringList res; 00080 QList<StatementPtr> list = resource()->properties(DublinCoreVocab::self()->creator()); 00081 QList<StatementPtr>::ConstIterator it = list.constBegin(); 00082 QList<StatementPtr>::ConstIterator end = list.constEnd(); 00083 for ( ; it != end; ++it) 00084 { 00085 QString str = (*it)->asString(); 00086 if (!str.isNull()) 00087 res.append(str); 00088 } 00089 return res; 00090 } 00091 00092 time_t DublinCore::date() const 00093 { 00094 QString str = resource()->property(DublinCoreVocab::self()->date())->asString(); 00095 return parseDate(str, ISODate); 00096 00097 } 00098 00099 QString DublinCore::description() const 00100 { 00101 return resource()->property(DublinCoreVocab::self()->description())->asString(); 00102 } 00103 00104 QString DublinCore::format() const 00105 { 00106 return resource()->property(DublinCoreVocab::self()->format())->asString(); 00107 } 00108 00109 QString DublinCore::identifier() const 00110 { 00111 return resource()->property(DublinCoreVocab::self()->identifier())->asString(); 00112 } 00113 00114 QString DublinCore::language() const 00115 { 00116 return resource()->property(DublinCoreVocab::self()->language())->asString(); 00117 } 00118 00119 QString DublinCore::publisher() const 00120 { 00121 return resource()->property(DublinCoreVocab::self()->publisher())->asString(); 00122 } 00123 00124 QString DublinCore::relation() const 00125 { 00126 return resource()->property(DublinCoreVocab::self()->relation())->asString(); 00127 } 00128 00129 QString DublinCore::rights() const 00130 { 00131 return resource()->property(DublinCoreVocab::self()->rights())->asString(); 00132 } 00133 00134 QString DublinCore::source() const 00135 { 00136 return resource()->property(DublinCoreVocab::self()->source())->asString(); 00137 } 00138 00139 QString DublinCore::subject() const 00140 { 00141 return resource()->property(DublinCoreVocab::self()->subject())->asString(); 00142 } 00143 00144 QStringList DublinCore::subjects() const 00145 { 00146 QStringList res; 00147 QList<StatementPtr> list = resource()->properties(DublinCoreVocab::self()->subject()); 00148 QList<StatementPtr>::ConstIterator it = list.constBegin(); 00149 QList<StatementPtr>::ConstIterator end = list.constEnd(); 00150 for ( ; it != end; ++it) 00151 { 00152 QString str = (*it)->asString(); 00153 if (!str.isNull()) 00154 res.append(str); 00155 } 00156 return res; 00157 } 00158 00159 QString DublinCore::title() const 00160 { 00161 return resource()->property(DublinCoreVocab::self()->title())->asString(); 00162 } 00163 00164 QString DublinCore::type() const 00165 { 00166 return resource()->property(DublinCoreVocab::self()->type())->asString(); 00167 } 00168 00169 QString DublinCore::debugInfo() const 00170 { 00171 QString info; 00172 if (!contributor().isNull()) 00173 info += QString::fromLatin1("dc:contributor: #%1#\n").arg(contributor()); 00174 if (!coverage().isNull()) 00175 info += QString::fromLatin1("dc:coverage: #%1#\n").arg(coverage()); 00176 if (!creator().isNull()) 00177 info += QString::fromLatin1("dc:creator: #%1#\n").arg(creator()); 00178 00179 00180 QString ddate = dateTimeToString(date()); 00181 if (!ddate.isNull()) 00182 info += QString::fromLatin1("dc:date: #%1#\n").arg(ddate); 00183 00184 if (!description().isNull()) 00185 info += QString::fromLatin1("dc:description: #%1#\n").arg(description()); 00186 if (!format().isNull()) 00187 info += QString::fromLatin1("dc:format: #%1#\n").arg(format()); 00188 if (!identifier().isNull()) 00189 info += QString::fromLatin1("dc:identifier: #%1#\n").arg(identifier()); 00190 if (!language().isNull()) 00191 info += QString::fromLatin1("dc:language: #%1#\n").arg(language()); 00192 if (!publisher().isNull()) 00193 info += QString::fromLatin1("dc:publisher: #%1#\n").arg(publisher()); 00194 if (!relation().isNull()) 00195 info += QString::fromLatin1("dc:relation: #%1#\n").arg(relation()); 00196 if (!rights().isNull()) 00197 info += QString::fromLatin1("dc:rights: #%1#\n").arg(rights()); 00198 if (!source().isNull()) 00199 info += QString::fromLatin1("dc:source: #%1#\n").arg(source()); 00200 if (!subject().isNull()) 00201 info += QString::fromLatin1("dc:subject: #%1#\n").arg(subject()); 00202 if (!title().isNull()) 00203 info += QString::fromLatin1("dc:title: #%1#\n").arg(title()); 00204 if (!type().isNull()) 00205 info += QString::fromLatin1("dc:type: #%1#\n").arg(type()); 00206 return info; 00207 } 00208 00209 } // namespace RDF 00210 } // namespace Syndication 00211
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:53 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu Aug 2 2012 15:24:53 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.