at.newmedialab.ldpath.backend.jena
Class GenericJenaBackend

java.lang.Object
  extended by at.newmedialab.ldpath.backend.jena.GenericJenaBackend
All Implemented Interfaces:
at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>

public class GenericJenaBackend
extends Object
implements at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>

Add file description here!

Author: Sebastian Schaffert


Constructor Summary
GenericJenaBackend(com.hp.hpl.jena.rdf.model.Model model)
           
 
Method Summary
 Boolean booleanValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the boolean value of a literal node.
 com.hp.hpl.jena.rdf.model.RDFNode createLiteral(String content)
          Create a literal node with the content passed as argument
 com.hp.hpl.jena.rdf.model.RDFNode createLiteral(String content, Locale language, URI type)
          Create a literal node with the content passed as argument
 com.hp.hpl.jena.rdf.model.RDFNode createURI(String uri)
          Create a URI mode with the URI passed as argument
 Date dateTimeValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          TODO
 Date dateValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          TODO
 BigDecimal decimalValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the decimal number of a literal node.
 Double doubleValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the double value of a literal node.
 Float floatValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the float value of a literal node.
 Locale getLiteralLanguage(com.hp.hpl.jena.rdf.model.RDFNode n)
          Return the language of the literal node passed as argument.
 URI getLiteralType(com.hp.hpl.jena.rdf.model.RDFNode n)
          Return the URI of the type of the literal node passed as argument.
 ThreadPoolExecutor getThreadPool()
          In case the backend supports threading, this method should return the ExecutorService representing the thread pool.
 BigInteger integerValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the arbitrary length integer value of a literal node.
 Integer intValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the 32bit integer value of a literal node.
 boolean isBlank(com.hp.hpl.jena.rdf.model.RDFNode n)
          Test whether the node passed as argument is a blank node
 boolean isLiteral(com.hp.hpl.jena.rdf.model.RDFNode n)
          Test whether the node passed as argument is a literal
 boolean isURI(com.hp.hpl.jena.rdf.model.RDFNode n)
          Test whether the node passed as argument is a URI
 Collection<com.hp.hpl.jena.rdf.model.RDFNode> listObjects(com.hp.hpl.jena.rdf.model.RDFNode subject, com.hp.hpl.jena.rdf.model.RDFNode property)
          List the objects of triples in the triple store underlying this backend that have the subject and property given as argument.
 Collection<com.hp.hpl.jena.rdf.model.RDFNode> listSubjects(com.hp.hpl.jena.rdf.model.RDFNode property, com.hp.hpl.jena.rdf.model.RDFNode object)
          List the subjects of triples in the triple store underlying this backend that have the object and property given as argument.
 Long longValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the long value of a literal node.
 String stringValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          Return the lexial representation of a node.
 boolean supportsThreading()
          Return true if the underlying backend supports the parallel execution of queries.
 Date timeValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
          TODO
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericJenaBackend

public GenericJenaBackend(com.hp.hpl.jena.rdf.model.Model model)
Method Detail

supportsThreading

public boolean supportsThreading()
Return true if the underlying backend supports the parallel execution of queries.

Specified by:
supportsThreading in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Returns:

getThreadPool

public ThreadPoolExecutor getThreadPool()
In case the backend supports threading, this method should return the ExecutorService representing the thread pool. LDPath lets the backend manage the thread pool to avoid excessive threading.

Specified by:
getThreadPool in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Returns:

isLiteral

public boolean isLiteral(com.hp.hpl.jena.rdf.model.RDFNode n)
Test whether the node passed as argument is a literal

Specified by:
isLiteral in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
n - the node to check
Returns:
true if the node is a literal

isURI

public boolean isURI(com.hp.hpl.jena.rdf.model.RDFNode n)
Test whether the node passed as argument is a URI

Specified by:
isURI in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
n - the node to check
Returns:
true if the node is a URI

isBlank

public boolean isBlank(com.hp.hpl.jena.rdf.model.RDFNode n)
Test whether the node passed as argument is a blank node

Specified by:
isBlank in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
n - the node to check
Returns:
true if the node is a blank node

getLiteralLanguage

public Locale getLiteralLanguage(com.hp.hpl.jena.rdf.model.RDFNode n)
Return the language of the literal node passed as argument.

Specified by:
getLiteralLanguage in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
n - the literal node for which to return the language
Returns:
a Locale representing the language of the literal, or null if the literal node has no language
Throws:
IllegalArgumentException - in case the node is no literal

getLiteralType

public URI getLiteralType(com.hp.hpl.jena.rdf.model.RDFNode n)
Return the URI of the type of the literal node passed as argument.

Specified by:
getLiteralType in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
n - the literal node for which to return the typer
Returns:
a URI representing the type of the literal content, or null if the literal is untyped
Throws:
IllegalArgumentException - in case the node is no literal

createLiteral

public com.hp.hpl.jena.rdf.model.RDFNode createLiteral(String content)
Create a literal node with the content passed as argument

Specified by:
createLiteral in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
content - string content to represent inside the literal
Returns:
a literal node in using the model used by this backend

createLiteral

public com.hp.hpl.jena.rdf.model.RDFNode createLiteral(String content,
                                                       Locale language,
                                                       URI type)
Create a literal node with the content passed as argument

Specified by:
createLiteral in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
content - string content to represent inside the literal
Returns:
a literal node in using the model used by this backend

createURI

public com.hp.hpl.jena.rdf.model.RDFNode createURI(String uri)
Create a URI mode with the URI passed as argument

Specified by:
createURI in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
uri - URI of the resource to create
Returns:
a URI node using the model used by this backend

stringValue

public String stringValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the lexial representation of a node. For a literal, this will be the content, for a URI node it will be the URI itself, and for a blank node it will be the identifier of the node.

Specified by:
stringValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode -
Returns:

doubleValue

public Double doubleValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the double value of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. The method can throw a NumberFormatException or ArithmeticException indicating that the value cannot be represented as double, and an IllegalArgumentException, indicating that the passed node is not a literal

Specified by:
doubleValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the double value
Returns:
double value of the literal node
Throws:
NumberFormatException - in case the literal cannot be represented as double value
ArithmeticException - in case the literal cannot be represented as double value
IllegalArgumentException - in case the node passed as argument is not a literal

longValue

public Long longValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the long value of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. The method can throw a NumberFormatException or ArithmeticException indicating that the value cannot be represented as long, and an IllegalArgumentException, indicating that the passed node is not a literal

Specified by:
longValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the long value
Returns:
long value of the literal node
Throws:
NumberFormatException - in case the literal cannot be represented as long value
ArithmeticException - in case the literal cannot be represented as long value
IllegalArgumentException - in case the node passed as argument is not a literal

booleanValue

public Boolean booleanValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the boolean value of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. TODO: Define:

Specified by:
booleanValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the boolean value
Returns:
long value of the literal node
Throws:
IllegalArgumentException - in case the node passed as argument is not a literal

dateTimeValue

public Date dateTimeValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
TODO

Specified by:
dateTimeValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the dateTime value
Returns:
long value of the literal node
Throws:
IllegalArgumentException - in case the node passed as argument is not a literal

dateValue

public Date dateValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
TODO

Specified by:
dateValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the date value
Returns:
long value of the literal node
Throws:
IllegalArgumentException - in case the node passed as argument is not a literal

timeValue

public Date timeValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
TODO

Specified by:
timeValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the time value
Returns:
long value of the literal node
Throws:
IllegalArgumentException - in case the node passed as argument is not a literal

floatValue

public Float floatValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the float value of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. The method can throw a NumberFormatException or ArithmeticException indicating that the value cannot be represented as float, and an IllegalArgumentException, indicating that the passed node is not a literal

Specified by:
floatValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the float value
Returns:
long value of the literal node
Throws:
NumberFormatException - in case the literal cannot be represented as float value
ArithmeticException - in case the literal cannot be represented as float value
IllegalArgumentException - in case the node passed as argument is not a literal

intValue

public Integer intValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the 32bit integer value of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. The method can throw a NumberFormatException or ArithmeticException indicating that the value cannot be represented as integer, and an IllegalArgumentException, indicating that the passed node is not a literal.

Note that this is restricted to 32bit singed integer values as defined by xsd:int and Integer. For bigger nuber one might want to use xsd:integer represented by BigInteger.

Specified by:
intValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the Integer (xsd:int) value
Returns:
long value of the literal node
Throws:
NumberFormatException - in case the literal cannot be represented as 32 bit integer value
ArithmeticException - in case the literal cannot be represented as 32 bit integer value
IllegalArgumentException - in case the node passed as argument is not a literal

integerValue

public BigInteger integerValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the arbitrary length integer value of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. The method can throw a NumberFormatException or ArithmeticException indicating that the value cannot be represented as integer, and an IllegalArgumentException, indicating that the passed node is not a literal.

Specified by:
integerValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the xsd:integer value
Returns:
long value of the literal node
Throws:
NumberFormatException - in case the literal cannot be represented as integer value
ArithmeticException - in case the literal cannot be represented as long value
IllegalArgumentException - in case the node passed as argument is integer a literal

decimalValue

public BigDecimal decimalValue(com.hp.hpl.jena.rdf.model.RDFNode rdfNode)
Return the decimal number of a literal node. Depending on the backend implementing this method, the value can be retrieved directly or must be parsed from the string representation. The method can throw a NumberFormatException or ArithmeticException indicating that the value cannot be represented as decimal, and an IllegalArgumentException, indicating that the passed node is not a literal.

Specified by:
decimalValue in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
rdfNode - the literal node for which to return the xsd:decimal value
Returns:
long value of the literal node
Throws:
NumberFormatException - in case the literal cannot be represented as decimal value
ArithmeticException - in case the literal cannot be represented as decimal value
IllegalArgumentException - in case the node passed as argument is not a literal

listObjects

public Collection<com.hp.hpl.jena.rdf.model.RDFNode> listObjects(com.hp.hpl.jena.rdf.model.RDFNode subject,
                                                                 com.hp.hpl.jena.rdf.model.RDFNode property)
List the objects of triples in the triple store underlying this backend that have the subject and property given as argument.

Specified by:
listObjects in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
subject - the subject of the triples to look for
property - the property of the triples to look for, null is interpreted as wildcard
Returns:
all objects of triples with matching subject and property

listSubjects

public Collection<com.hp.hpl.jena.rdf.model.RDFNode> listSubjects(com.hp.hpl.jena.rdf.model.RDFNode property,
                                                                  com.hp.hpl.jena.rdf.model.RDFNode object)
List the subjects of triples in the triple store underlying this backend that have the object and property given as argument.

Specified by:
listSubjects in interface at.newmedialab.ldpath.api.backend.RDFBackend<com.hp.hpl.jena.rdf.model.RDFNode>
Parameters:
object - the object of the triples to look for
property - the property of the triples to look for, null is interpreted as wildcard
Returns:
all subjects of triples with matching object and property
Throws:
UnsupportedOperationException - in case reverse selection is not supported (e.g. when querying Linked Data)


Copyright © 2012-2013 Salzburg Research. All Rights Reserved.