| java.lang.Object org.ontoware.rdf2go.util.RDFTool
RDFTool | public class RDFTool (Code) | | RDFTool, a helper utility to cope with RDF in general.
The accessor methods are also handled by the RDFReactor runtime.
This tool has been part of gnowsis.org.
author: Leo Sauermann (leo@gnowsis.com), 2003-2007 author: Max Völkel |
Method Summary | |
public static Model | copyModel(Model m) | public 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. | public static String | dateTime2DateString(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. | public static String | dateTime2String(Date date) format the given date in a good dateTime format: ISO 8601, using the T
seperator and the - and : seperators accordingly. | public static Statement | findStatement(Model model, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) find the first statement that fits the passed triple pattern and return
it. | public static DateFormat | getDateFormat() format to express dates in ISO 8601. | public static DateFormat | getDateTimeFormat() get a DateFormat to format dates according to ISO 8601. | public static String | getGoodLabel(Node o, Model source) Get the Displaylabel of a Node. | public static String | getLabel(Node o) Get the label of a Node. | public static String | getShortName(String uri) The passed uri identifies something on the web, probably a namespace. | public static Node | getSingleValue(Model m, Resource res, URI pred) get the property pred of the resource res. | public static Node | getSingleValue(ModelSet m, Resource res, URI pred) | public static String | getSingleValueString(Model m, Resource res, URI pred) read the values of a predicate of a resource. | public static String | getSingleValueString(ModelSet modelset, Resource res, URI pred) read the values of a predicate of a resource. | public static Syntax | guessSyntax(String filenname) | public static String | modelToString(Model model) | public static String | modelToString(ModelSet modelset) | public static String | modelToString(Model model, Syntax syntax) | public static String | modelToString(ModelSet modelset, Syntax syntax) | public static void | setSingleValue(Model m, Resource res, URI pred, Node value) set the property pred of the resource res. | public static void | setSingleValue(Model m, Resource res, URI pred, String value) set the property pred of the resource res. | public static String | sha1sum(String data) compute the sha1sum of a string (useful for handling FOAF data). | public static Date | string2Date(String isodate) try to get a date out of a string. | public 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. | public static Model | stringToModel(String rdfxml) | public static Model | stringToModel(String string, Syntax syntax) |
copyModel | public static Model copyModel(Model m)(Code) | | Parameters: m - the model to copy a copy of the model in a memory model |
date2String | public static String date2String(Date date)(Code) | | 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.
Parameters: date - a formatted string. |
dateTime2DateString | public static String dateTime2DateString(Date date)(Code) | | 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.
Parameters: date - a formatted string.RDFTool.date2String(Date) |
dateTime2String | public static String dateTime2String(Date date)(Code) | | format the given date in a good dateTime format: ISO 8601, using the T
seperator and the - and : seperators accordingly. example:
2003-01-22T17:00:00
Parameters: date - a formatted string. |
findStatement | public static Statement findStatement(Model model, ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object)(Code) | | find the first statement that fits the passed triple pattern and return
it.
Parameters: model - the model to search on Parameters: subject - subject Parameters: predicate - predicate Parameters: object - object a statement (the first found) or null, if nothing matched throws: RuntimeException - if the model throws an exception |
getDateFormat | public static DateFormat getDateFormat()(Code) | | format to express dates in ISO 8601. Timezone is ignored.
the DateFormat to format dates (without time) according toISO8601. |
getDateTimeFormat | public static DateFormat getDateTimeFormat()(Code) | | get a DateFormat to format dates according to ISO 8601. This ignored
timezones.
a dateformat. |
getGoodLabel | public static String getGoodLabel(Node o, Model source)(Code) | | Get the Displaylabel of a Node. For resources, the "rdfs:label" property
is returned, if there is none, the url is shortened to a localname. If it
is a Literal, return the Lexical Form. If it is null, returns null
Results may vary.
Parameters: o - the node to check Parameters: source - the model to ask a string representation of the node or null. |
getLabel | public static String getLabel(Node o)(Code) | | Get the label of a Node. If it is a resource, return the local name (the
last part of the URI). If it is a Literal, return the Lexical Form (the
value). If it is null , returns null .
Parameters: o - the node to check a string representation of the node or null . |
getShortName | public static String getShortName(String uri)(Code) | | The passed uri identifies something on the web, probably a namespace. To
shorten this, parse the url for something like a localname. Returns the
last string after a '#' or a '/'.
Parameters: uri - a URI a short name for it, for display. |
getSingleValue | public static Node getSingleValue(Model m, Resource res, URI pred)(Code) | | get the property pred of the resource res. If there is none, return null.
If there are mutliple, return any.
Parameters: m - the model to read from Parameters: res - the resource Parameters: pred - the predicate to read the value or null |
getSingleValueString | public static String getSingleValueString(Model m, Resource res, URI pred)(Code) | | read the values of a predicate of a resource. If a value exists, return a
string representation of it. When multiple triples with this
subject/predicate exist, choose one at random.
Parameters: m - the model to read from Parameters: res - the resource Parameters: pred - the predicate to read a string representation of the value, or null. Literals arereturned using their Value (not toString()). |
getSingleValueString | public static String getSingleValueString(ModelSet modelset, Resource res, URI pred)(Code) | | read the values of a predicate of a resource. If a value exists, return a
string representation of it. When multiple triples with this
subject/predicate exist, choose one at random.
Parameters: modelset - the model to read from Parameters: res - the resource Parameters: pred - the predicate to read a string representation of the value, or null. Literals arereturned using their Value (not toString()). |
guessSyntax | public static Syntax guessSyntax(String filenname)(Code) | | guess the RDF syntax of a filename inspired by
com.hp.hpl.jena.graph.impl.FileGraph#guessLang with the addition of
toLowerCase
Parameters: filenname - the filename, we will look at the suffix after "." the guessed RDF syntax, fallback is RDF/XML |
modelToString | public static String modelToString(Model model)(Code) | | convert a model to a string RDF/XML for serialization
Parameters: model - the model to convert |
modelToString | public static String modelToString(Model model, Syntax syntax)(Code) | | convert a model to a string for serialization
Parameters: model - the model to convert Parameters: syntax - the syntax to use a string of this model, according to the passed syntax |
modelToString | public static String modelToString(ModelSet modelset, Syntax syntax)(Code) | | convert a modelset to a string for serialization
Parameters: modelset - the model to convert Parameters: syntax - the syntax to use a string of this model, according to the passed syntax |
setSingleValue | public static void setSingleValue(Model m, Resource res, URI pred, Node value)(Code) | | set the property pred of the resource res. If it exists, change it. If it
not exists, create it. If the passed value is null, delete the statement
Parameters: m - the model to manipulate Parameters: res - the rsource Parameters: pred - the predicate to set Parameters: value - a value or null |
setSingleValue | public static void setSingleValue(Model m, Resource res, URI pred, String value)(Code) | | set the property pred of the resource res. If it exists, change it. If it
not exists, create it. If value is null, delete the triple.
Parameters: m - the model to manipulate Parameters: res - the rsource Parameters: pred - the predicate to set Parameters: value - a string or null |
sha1sum | public static String sha1sum(String data)(Code) | | compute the sha1sum of a string (useful for handling FOAF data).
Parameters: data - the string to parse the sha1sum as string. |
string2Date | public static Date string2Date(String isodate) throws ParseException(Code) | | try to get a date out of a string. If this works, return it, otherwise
return null. Btw: the namespace of dateTime is
http://www.w3.org/2001/XMLSchema#dateTime Timezone is ignored.
Parameters: isodate - the XSD date as string. a parsed date or null, if this breaks throws: ParseException - |
string2DateTime | public static Date string2DateTime(String date) throws ParseException(Code) | | 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.
Parameters: date - the date-string to parse a formatted string. |
stringToModel | public static Model stringToModel(String rdfxml)(Code) | | convenience function to create a memModel from an RDF/XML-ABBREV stream
Parameters: rdfxml - the serialized form of the model a Model |
stringToModel | public static Model stringToModel(String string, Syntax syntax)(Code) | | convenience function to create a memModel from a string
Parameters: string - the string with the serialized model Parameters: syntax - the syntax to use the model that was serialised. |
|
|