public class RDFUtils extends Object
Modifier and Type | Method and Description |
---|---|
static org.openrdf.model.BNode |
bnode() |
static org.openrdf.model.BNode |
bnode(String id)
Creates a
BNode . |
static String |
fixAbsoluteURI(String uri)
Fixes typical errors in an absolute URI, such as unescaped spaces.
|
static String |
fixURIWithException(String unescapedURI)
Tries to fix a potentially broken relative or absolute URI.
|
static org.openrdf.model.BNode |
getBNode(String id)
Creates a
BNode . |
static org.openrdf.rio.RDFFormat |
getFormatByExtension(String ext)
Returns a parser type from the given extension.
|
static Collection<org.openrdf.rio.RDFFormat> |
getFormats()
Returns all the available
RDFFormat s. |
static org.openrdf.rio.RDFParser |
getParser(org.openrdf.rio.RDFFormat format)
Creates a new
RDFParser instance. |
static org.openrdf.rio.RDFWriter |
getWriter(org.openrdf.rio.RDFFormat format,
OutputStream os)
Creates a new
RDFWriter instance. |
static org.openrdf.rio.RDFWriter |
getWriter(org.openrdf.rio.RDFFormat format,
Writer writer)
Creates a new
RDFWriter instance. |
static String |
getXSDDate(String dateToBeParsed,
String format)
This method allows to obtain an XML Schema compliant date
providing a textual representation of a date and textual a pattern for parsing it.
|
static boolean |
isAbsoluteURI(String href)
Checks if
href is absolute or not. |
static org.openrdf.model.Literal |
literal(boolean b)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(byte b)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(double d)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(float f)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(int i)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(long l)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(short s)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(String s)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(String s,
String l)
Creates a
Literal . |
static org.openrdf.model.Literal |
literal(String s,
org.openrdf.model.URI datatype)
Creates a
Literal . |
static org.openrdf.model.Statement[] |
parseRDF(org.openrdf.rio.RDFFormat format,
InputStream is)
Parses the content of
is input stream with the
specified parser p using '' as base URI. |
static org.openrdf.model.Statement[] |
parseRDF(org.openrdf.rio.RDFFormat format,
InputStream is,
String baseURI)
Parses the content of
is input stream with the
specified parser p using baseURI . |
static org.openrdf.model.Statement[] |
parseRDF(org.openrdf.rio.RDFFormat format,
String in)
Parses the content of
in string with the
specified parser p using '' as base URI. |
static org.openrdf.model.Statement[] |
parseRDF(String resource)
Parses the content of the
resource file
guessing the content format from the extension. |
static org.openrdf.model.Statement |
quad(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o,
org.openrdf.model.Resource g)
Creates a
Statement . |
static org.openrdf.model.Statement |
quad(String s,
String p,
String o,
String g)
Creates a statement of type:
toValue(s), toValue(p), toValue(o), toValue(g) |
static org.openrdf.model.Value |
toValue(String s)
Creates a
Value . |
static String |
toXSDDateTime(Date date)
Prints a
date to the XSD datetime format. |
static org.openrdf.model.Statement |
triple(org.openrdf.model.Resource s,
org.openrdf.model.URI p,
org.openrdf.model.Value o)
Creates a
Statement . |
static org.openrdf.model.Statement |
triple(String s,
String p,
String o)
Creates a statement of type:
toValue(s), toValue(p), toValue(o) |
static org.openrdf.model.URI |
uri(String uri)
Creates a
URI . |
static org.openrdf.model.URI |
uri(String namespace,
String localName)
Creates a
URI . |
public static String fixAbsoluteURI(String uri)
uri
- An absolute URI, can have typical syntax errorsIllegalArgumentException
- if URI is not fixablepublic static String getXSDDate(String dateToBeParsed, String format) throws ParseException, DatatypeConfigurationException
dateToBeParsed
- the String containing the date.format
- the pattern as descibed in SimpleDateFormat
String
representing the dateParseException
DatatypeConfigurationException
public static String toXSDDateTime(Date date)
date
to the XSD datetime format.date
- date to be printed.public static String fixURIWithException(String unescapedURI)
unescapedURI
- uri string to be unescaped.public static org.openrdf.model.URI uri(String uri)
URI
.public static org.openrdf.model.Literal literal(String s)
Literal
.public static org.openrdf.model.Literal literal(boolean b)
Literal
.public static org.openrdf.model.Literal literal(byte b)
Literal
.public static org.openrdf.model.Literal literal(short s)
Literal
.public static org.openrdf.model.Literal literal(int i)
Literal
.public static org.openrdf.model.Literal literal(long l)
Literal
.public static org.openrdf.model.Literal literal(float f)
Literal
.public static org.openrdf.model.Literal literal(double d)
Literal
.public static org.openrdf.model.Literal literal(String s, org.openrdf.model.URI datatype)
Literal
.public static org.openrdf.model.BNode bnode(String id)
BNode
.public static org.openrdf.model.BNode bnode()
bnode
with unique id.public static org.openrdf.model.BNode getBNode(String id)
BNode
.public static org.openrdf.model.Statement triple(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o)
Statement
.public static org.openrdf.model.Statement triple(String s, String p, String o)
toValue(s), toValue(p), toValue(o)
s
- subject.p
- predicate.o
- object.public static org.openrdf.model.Statement quad(org.openrdf.model.Resource s, org.openrdf.model.URI p, org.openrdf.model.Value o, org.openrdf.model.Resource g)
Statement
.public static org.openrdf.model.Statement quad(String s, String p, String o, String g)
toValue(s), toValue(p), toValue(o), toValue(g)
public static org.openrdf.model.Value toValue(String s)
Value
. If s == 'a'
returns
an RDF.TYPE
. If s.matches('[a-z0-9]+:.*')
expands the corresponding prefix using PopularPrefixes
.s
- public static Collection<org.openrdf.rio.RDFFormat> getFormats()
RDFFormat
s.RDFFormat.values()
public static org.openrdf.rio.RDFParser getParser(org.openrdf.rio.RDFFormat format)
RDFParser
instance.format
- parser format.IllegalArgumentException
- if format is not supported.public static org.openrdf.rio.RDFWriter getWriter(org.openrdf.rio.RDFFormat format, Writer writer)
RDFWriter
instance.format
- output format.writer
- data output writer.IllegalArgumentException
- if format is not supported.public static org.openrdf.rio.RDFWriter getWriter(org.openrdf.rio.RDFFormat format, OutputStream os)
RDFWriter
instance.format
- output format.os
- output stream.IllegalArgumentException
- if format is not supported.public static org.openrdf.rio.RDFFormat getFormatByExtension(String ext)
ext
- input extension.IllegalArgumentException
- if no extension matches.public static org.openrdf.model.Statement[] parseRDF(org.openrdf.rio.RDFFormat format, InputStream is, String baseURI) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
is
input stream with the
specified parser p
using baseURI
.format
- input format type.is
- input stream containing RDF.
baseURI
- base uri.org.openrdf.rio.RDFHandlerException
IOException
org.openrdf.rio.RDFParseException
public static org.openrdf.model.Statement[] parseRDF(org.openrdf.rio.RDFFormat format, InputStream is) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
is
input stream with the
specified parser p
using ''
as base URI.format
- input format type.is
- input stream containing RDF.
org.openrdf.rio.RDFHandlerException
IOException
org.openrdf.rio.RDFParseException
public static org.openrdf.model.Statement[] parseRDF(org.openrdf.rio.RDFFormat format, String in) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
in
string with the
specified parser p
using ''
as base URI.format
- input format type.in
- input string containing RDF.
org.openrdf.rio.RDFHandlerException
IOException
org.openrdf.rio.RDFParseException
public static org.openrdf.model.Statement[] parseRDF(String resource) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
resource
file
guessing the content format from the extension.resource
- resource name.IOException
- if an error occurs while reading file.org.openrdf.rio.RDFHandlerException
- if an error occurs while parsing file.org.openrdf.rio.RDFParseException
- if an error occurs while parsing file.public static boolean isAbsoluteURI(String href)
href
is absolute or not.href
- candidate URI.true
if href
is absolute,
false
otherwise.Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.