public class RDFTool extends Object
This tool has been part of gnowsis.org.
Constructor and Description |
---|
RDFTool() |
Modifier and Type | Method and Description |
---|---|
static Model |
copyModel(Model m) |
static String |
date2String(Date date)
format the given date in a good date format: ISO 8601, using only the
date and not the T seperator example: 2003-01-22 Timezone is ignored.
|
static String |
dateTime2DateString(Date date)
Deprecated.
|
static String |
dateTime2String(Date dateTime)
format the given date in a good dateTime format: ISO 8601, using the T
seperator and the - and : seperators accordingly.
|
static Statement |
findStatement(Model model,
ResourceOrVariable subject,
UriOrVariable predicate,
NodeOrVariable object)
find the first statement that fits the passed triple pattern and return
it.
|
static DateFormat |
getDateFormat()
format to express dates in ISO 8601.
|
static DateFormat |
getDateTimeFormat()
get a DateFormat to format dates according to ISO 8601.
|
static String |
getGoodLabel(Node o,
Model source)
Get the Displaylabel of a Node.
|
static String |
getLabel(Node o)
Get the label of a Node.
|
static String |
getShortName(String uri)
The passed uri identifies something on the web, probably a namespace.
|
static Node |
getSingleValue(Model m,
Resource res,
URI pred)
get the property pred of the resource res.
|
static Node |
getSingleValue(ModelSet m,
Resource res,
URI pred) |
static String |
getSingleValueString(Model m,
Resource res,
URI pred)
read the values of a predicate of a resource.
|
static String |
getSingleValueString(ModelSet modelset,
Resource res,
URI pred)
read the values of a predicate of a resource.
|
static Syntax |
guessSyntax(String filenname)
guess the RDF syntax of a filename inspired by
com.hp.hpl.jena.graph.impl.FileGraph#guessLang with the addition of
toLowerCase
|
static String |
modelToString(Model model)
Convert a model to a string RDF/XML for serialisation
|
static String |
modelToString(ModelSet modelset) |
static String |
modelToString(ModelSet modelset,
Syntax syntax)
convert a modelset to a string for serialization
|
static String |
modelToString(Model model,
Syntax syntax)
convert a model to a string for serialisation
|
static void |
setSingleValue(Model m,
Resource res,
URI pred,
Node value)
set the property pred of the resource res.
|
static void |
setSingleValue(Model m,
Resource res,
URI pred,
String value)
set the property pred of the resource res.
|
static String |
sha1sum(String data)
compute the sha1sum of a string (useful for handling FOAF data).
|
static Date |
string2Date(String isodate)
Try to get a date out of a string.
|
static Date |
string2DateTime(String date)
format the given date in a good date format: ISO 8601, using only the
date and not the T seperator example: 2003-01-22 This ignores timezones.
|
static Model |
stringToModel(String rdfxml)
convenience function to create a memModel from an RDF/XML-ABBREV stream
|
static Model |
stringToModel(String string,
Syntax syntax)
convenience function to create a memModel from a string
|
public static Model copyModel(Model m)
m
- the model to copypublic static String dateTime2DateString(Date date)
date2String(Date)
date
- ..public static String dateTime2String(Date dateTime)
dateTime
- to be converted to stringpublic static String date2String(Date date)
date
- to be converted to stringpublic static Statement findStatement(Model model, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)
model
- the model to search onsubject
- subjectpredicate
- predicateobject
- objectRuntimeException
- if the model throws an exceptionpublic static DateFormat getDateFormat()
public static DateFormat getDateTimeFormat()
public static String getGoodLabel(Node o, Model source)
o
- the node to checksource
- the model to askpublic static String getLabel(Node o)
null
, returns null
.o
- the node to checknull
.public static String getShortName(String uri)
uri
- a URIpublic static Node getSingleValue(Model m, Resource res, URI pred)
m
- the model to read fromres
- the resourcepred
- the predicate to readpublic static String getSingleValueString(Model m, Resource res, URI pred)
m
- the model to read fromres
- the resourcepred
- the predicate to readpublic static String getSingleValueString(ModelSet modelset, Resource res, URI pred)
modelset
- the model to read fromres
- the resourcepred
- the predicate to readpublic static Syntax guessSyntax(String filenname)
filenname
- the filename, we will look at the suffix after "."public static String modelToString(Model model)
model
- the model to convertpublic static String modelToString(Model model, Syntax syntax)
model
- the model to convertsyntax
- the syntax to usepublic static String modelToString(ModelSet modelset, Syntax syntax)
modelset
- the model to convertsyntax
- the syntax to usepublic static void setSingleValue(Model m, Resource res, URI pred, Node value)
m
- the model to manipulateres
- the rsourcepred
- the predicate to setvalue
- a value or nullpublic static void setSingleValue(Model m, Resource res, URI pred, String value)
m
- the model to manipulateres
- the rsourcepred
- the predicate to setvalue
- a string or nullpublic static String sha1sum(String data)
data
- the string to parsepublic static Date string2Date(String isodate) throws ParseException
isodate
- the XSD date as string.ParseException
- if isodate could not be parsedpublic static Date string2DateTime(String date) throws ParseException
date
- the date-string to parseParseException
public static Model stringToModel(String rdfxml)
rdfxml
- the serialized form of the modelCopyright © 2005–2019 IT-Consulting Dr. Max Völkel | Project started at FZI Forschungszentrum Informatik, www.fzi.de. All rights reserved.