|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.any23.rdf.RDFUtils
public class RDFUtils
Basic class providing a set of utility methods when dealing with RDF.
Nested Class Summary | |
---|---|
static class |
RDFUtils.Parser
List of supported RDF parsers. |
Method Summary | |
---|---|
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 RDFUtils.Parser |
getParserFromExtension(String ext)
Returns a parser type from the given extension. |
static org.openrdf.rio.RDFParser |
getRDFParser(RDFUtils.Parser p)
Creates a new RDFParser 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(RDFUtils.Parser p,
InputStream is)
Parses the content of is input stream with the
specified parser p using '' as base URI. |
static org.openrdf.model.Statement[] |
parseRDF(RDFUtils.Parser p,
InputStream is,
String baseURI)
Parses the content of is input stream with the
specified parser p using baseURI . |
static org.openrdf.model.Statement[] |
parseRDF(RDFUtils.Parser p,
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.Value |
toRDF(String s)
Creates a Value . |
static org.openrdf.model.Statement |
toTriple(String s,
String p,
String o)
Creates a statement of type: toRDF(s), toRDF(p), toRDF(o) |
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.URI |
uri(String uri)
Creates a URI . |
static org.openrdf.model.URI |
uri(String namespace,
String localName)
Creates a URI . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static String fixAbsoluteURI(String uri)
uri
- An absolute URI, can have typical syntax errors
IllegalArgumentException
- 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 date
ParseException
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.URI uri(String namespace, String localName)
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, String l)
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 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.Value toRDF(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 org.openrdf.model.Statement toTriple(String s, String p, String o)
toRDF(s), toRDF(p), toRDF(o)
s
- subject.p
- predicate.o
- object.
public static org.openrdf.rio.RDFParser getRDFParser(RDFUtils.Parser p)
RDFParser
instance.
p
- parser type.
IllegalArgumentException
- if parser is unsupported.public static RDFUtils.Parser getParserFromExtension(String ext)
ext
- input extension.
IllegalArgumentException
- if no extension matches.public static org.openrdf.model.Statement[] parseRDF(RDFUtils.Parser p, InputStream is, String baseURI) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
is
input stream with the
specified parser p
using baseURI
.
p
- parser type.is
- input stream containing RDF.baseURI
- base uri.
- Returns:
- list of statements detected within the input stream.
- Throws:
org.openrdf.rio.RDFHandlerException
IOException
org.openrdf.rio.RDFParseException
public static org.openrdf.model.Statement[] parseRDF(RDFUtils.Parser p, InputStream is) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
is
input stream with the
specified parser p
using ''
as base URI.
p
- parser type.is
- input stream containing RDF.
- Returns:
- list of statements detected within the input stream.
- Throws:
org.openrdf.rio.RDFHandlerException
IOException
org.openrdf.rio.RDFParseException
public static org.openrdf.model.Statement[] parseRDF(RDFUtils.Parser p, String in) throws org.openrdf.rio.RDFHandlerException, IOException, org.openrdf.rio.RDFParseException
in
string with the
specified parser p
using ''
as base URI.
p
- parser type.in
- input string containing RDF.
- Returns:
- list of statements detected within the input string.
- Throws:
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |