MARMOTTA-446: Added "includeInferred" flag to the SesameBackend 
constructors/factories.
MARMOTTA-445: Fixed


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/5c6e30dd
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/5c6e30dd
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/5c6e30dd

Branch: refs/heads/ldp
Commit: 5c6e30dd188af34357a18a90f29151a3e2180342
Parents: 638dea3
Author: Jakob Frank <[email protected]>
Authored: Wed Feb 26 12:16:44 2014 +0100
Committer: Jakob Frank <[email protected]>
Committed: Wed Feb 26 14:16:20 2014 +0100

----------------------------------------------------------------------
 .../backend/sesame/AbstractSesameBackend.java   | 144 +++----
 .../ContextAwareSesameConnectionBackend.java    |  23 +-
 .../backend/sesame/SesameConnectionBackend.java |  88 ++--
 .../backend/sesame/SesameRepositoryBackend.java |  32 +-
 .../backend/sesame/SesameValueBackend.java      | 420 +++++++++----------
 5 files changed, 376 insertions(+), 331 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c6e30dd/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
index 62fd5fe..08f7365 100644
--- 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
+++ 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/AbstractSesameBackend.java
@@ -36,60 +36,60 @@ import org.slf4j.LoggerFactory;
 
 public abstract class AbstractSesameBackend extends SesameValueBackend 
implements RDFBackend<Value> {
 
-       private static final Logger log = 
LoggerFactory.getLogger(AbstractSesameBackend.class);
-
-       protected org.openrdf.model.URI createURIInternal(final ValueFactory 
valueFactory, String uri) {
-               return valueFactory.createURI(uri);
-       }
-
-       protected Literal createLiteralInternal(final ValueFactory 
valueFactory, String content) {
-               log.debug("creating literal with content \"{}\"",content);
-               return valueFactory.createLiteral(content);
-       }
-
-       protected Literal createLiteralInternal(final ValueFactory 
valueFactory, String content,
-                       Locale language, URI type) {
-               log.debug("creating literal with content \"{}\", language {}, 
datatype {}",new Object[]{content,language,type});
-               if(language == null && type == null) {
-                       return valueFactory.createLiteral(content);
-               } else if(type == null) {
-                       return 
valueFactory.createLiteral(content,language.getLanguage());
-               } else  {
-                       return valueFactory.createLiteral(content, 
valueFactory.createURI(type.toString()));
-               }
-       }
-
-       protected Collection<Value> listObjectsInternal(RepositoryConnection 
connection, Resource subject, org.openrdf.model.URI property, Resource... 
contexts)
-                       throws RepositoryException {
+    private static final Logger log = 
LoggerFactory.getLogger(AbstractSesameBackend.class);
+
+    protected org.openrdf.model.URI createURIInternal(final ValueFactory 
valueFactory, String uri) {
+        return valueFactory.createURI(uri);
+    }
+
+    protected Literal createLiteralInternal(final ValueFactory valueFactory, 
String content) {
+        log.debug("creating literal with content \"{}\"",content);
+        return valueFactory.createLiteral(content);
+    }
+
+    protected Literal createLiteralInternal(final ValueFactory valueFactory, 
String content,
+                                            Locale language, URI type) {
+        log.debug("creating literal with content \"{}\", language {}, datatype 
{}",new Object[]{content,language,type});
+        if(language == null && type == null) {
+            return valueFactory.createLiteral(content);
+        } else if(type == null) {
+            return valueFactory.createLiteral(content,language.getLanguage());
+        } else  {
+            return valueFactory.createLiteral(content, 
valueFactory.createURI(type.toString()));
+        }
+    }
+
+    protected Collection<Value> listObjectsInternal(RepositoryConnection 
connection, Resource subject, org.openrdf.model.URI property, boolean 
includeInferred, Resource... contexts)
+            throws RepositoryException {
         final ValueFactory valueFactory = connection.getValueFactory();
 
-               Set<Value> result = new HashSet<Value>();
-               RepositoryResult<Statement> qResult = 
connection.getStatements(merge(subject, valueFactory), merge(property, 
valueFactory), null, true);
-               try {
-                       while(qResult.hasNext()) {
-                               result.add(qResult.next().getObject());
-                       }
-               } finally {
-                       qResult.close();
-               }
-               return  result;
-       }
-
-       protected Collection<Value> listSubjectsInternal(final 
RepositoryConnection connection, org.openrdf.model.URI property, Value object, 
Resource... contexts)
-                       throws RepositoryException {
-           final ValueFactory valueFactory = connection.getValueFactory();
-           
-               Set<Value> result = new HashSet<Value>();
-        RepositoryResult<Statement> qResult = connection.getStatements(null, 
merge(property, valueFactory), merge(object, valueFactory), true);
-               try {
-                       while(qResult.hasNext()) {
-                               result.add(qResult.next().getSubject());
-                       }
-               } finally {
-                       qResult.close();
-               }
-               return  result;
-       }
+        Set<Value> result = new HashSet<Value>();
+        RepositoryResult<Statement> qResult = 
connection.getStatements(merge(subject, valueFactory), merge(property, 
valueFactory), null, includeInferred, contexts);
+        try {
+            while(qResult.hasNext()) {
+                result.add(qResult.next().getObject());
+            }
+        } finally {
+            qResult.close();
+        }
+        return  result;
+    }
+
+    protected Collection<Value> listSubjectsInternal(final 
RepositoryConnection connection, org.openrdf.model.URI property, Value object, 
boolean includeInferred, Resource... contexts)
+            throws RepositoryException {
+        final ValueFactory valueFactory = connection.getValueFactory();
+
+        Set<Value> result = new HashSet<Value>();
+        RepositoryResult<Statement> qResult = connection.getStatements(null, 
merge(property, valueFactory), merge(object, valueFactory), includeInferred, 
contexts);
+        try {
+            while(qResult.hasNext()) {
+                result.add(qResult.next().getSubject());
+            }
+        } finally {
+            qResult.close();
+        }
+        return  result;
+    }
 
     /**
      * Merge the value given as argument into the value factory given as 
argument
@@ -109,32 +109,32 @@ public abstract class AbstractSesameBackend extends 
SesameValueBackend implement
         }
     }
 
-       @Override
-       public abstract Literal createLiteral(String content);
+    @Override
+    public abstract Literal createLiteral(String content);
 
-       @Override
-       public abstract Literal createLiteral(String content, Locale language, 
URI type);
+    @Override
+    public abstract Literal createLiteral(String content, Locale language, URI 
type);
 
-       @Override
-       public abstract org.openrdf.model.URI createURI(String uri);
+    @Override
+    public abstract org.openrdf.model.URI createURI(String uri);
 
-       @Override
-       public abstract Collection<Value> listObjects(Value subject, Value 
property);
+    @Override
+    public abstract Collection<Value> listObjects(Value subject, Value 
property);
 
-       @Override
-       public abstract Collection<Value> listSubjects(Value property, Value 
object);
+    @Override
+    public abstract Collection<Value> listSubjects(Value property, Value 
object);
 
-       @Override
-       @Deprecated
-       public boolean supportsThreading() {
-               return false;
-       }
+    @Override
+    @Deprecated
+    public boolean supportsThreading() {
+        return false;
+    }
 
-       @Override
-       @Deprecated
-       public ThreadPoolExecutor getThreadPool() {
-               return null;
-       }
+    @Override
+    @Deprecated
+    public ThreadPoolExecutor getThreadPool() {
+        return null;
+    }
 
 
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c6e30dd/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ContextAwareSesameConnectionBackend.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ContextAwareSesameConnectionBackend.java
 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ContextAwareSesameConnectionBackend.java
index 3368269..2930a8c 100644
--- 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ContextAwareSesameConnectionBackend.java
+++ 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/ContextAwareSesameConnectionBackend.java
@@ -33,7 +33,17 @@ public class ContextAwareSesameConnectionBackend extends 
SesameConnectionBackend
      * @param contexts the contexts to look for, providing an empty array here 
will revert the functionality to {@link SesameConnectionBackend}.
      */
     public ContextAwareSesameConnectionBackend(RepositoryConnection 
connection, Resource... contexts) {
-        super(connection, contexts);
+        super(connection, true, contexts);
+    }
+
+    /**
+     * Create a new {@link ContextAwareSesameConnectionBackend} that considers 
only data from the provided contexts.
+     * @param connection the {@link RepositoryConnection} to use.
+     * @param includeInferred
+     * @param contexts the contexts to look for, providing an empty array here 
will revert the functionality to {@link SesameConnectionBackend}.
+     */
+    public ContextAwareSesameConnectionBackend(RepositoryConnection 
connection, boolean includeInferred, Resource... contexts) {
+        super(connection, includeInferred, contexts);
     }
 
     /**
@@ -44,4 +54,15 @@ public class ContextAwareSesameConnectionBackend extends 
SesameConnectionBackend
     public static ContextAwareSesameConnectionBackend 
withConnection(RepositoryConnection connection, Resource... contexts) {
         return new ContextAwareSesameConnectionBackend(connection, contexts);
     }
+
+
+    /**
+     * Create a new {@link ContextAwareSesameConnectionBackend} that considers 
only data from the provided contexts.
+     * @param connection the {@link RepositoryConnection} to use.
+     * @param includeInferred
+     * @param contexts the contexts to look for, providing an empty array here 
will revert the functionality to {@link SesameConnectionBackend}.
+     */
+    public static ContextAwareSesameConnectionBackend 
withConnection(RepositoryConnection connection, boolean includeInferred, 
Resource... contexts) {
+        return new ContextAwareSesameConnectionBackend(connection, 
includeInferred, contexts);
+    }
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c6e30dd/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
index afa3dea..ca4f427 100644
--- 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
+++ 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameConnectionBackend.java
@@ -30,59 +30,61 @@ import org.openrdf.repository.RepositoryException;
 
 public class SesameConnectionBackend extends AbstractSesameBackend {
 
-       private final RepositoryConnection connection;
-       private final ValueFactory valueFactory;
+    private final RepositoryConnection connection;
+    private final ValueFactory valueFactory;
     private final Resource[] contexts;
+    private final boolean includeInferred;
 
     /**
      * Create a new {@link SesameConnectionBackend}. This backend is 
context-agnostig (ignores all context information). 
      * @param connection the {@link RepositoryConnection} to use.
      * @see 
ContextAwareSesameConnectionBackend#ContextAwareSesameConnectionBackend(RepositoryConnection,
 Resource...)
      */
-       public SesameConnectionBackend(RepositoryConnection connection) {
-           this(connection, new Resource[] {});
-       }
+    public SesameConnectionBackend(RepositoryConnection connection) {
+        this(connection, true);
+    }
 
-       protected SesameConnectionBackend(RepositoryConnection connection, 
Resource[] contexts) {
-           this.connection = connection;
+    protected SesameConnectionBackend(RepositoryConnection connection, boolean 
includeInferred, Resource... contexts) {
+        this.connection = connection;
         this.contexts = contexts;
-           valueFactory = connection.getValueFactory();
+        this.valueFactory = connection.getValueFactory();
+        this.includeInferred = includeInferred;
     }
 
     @Override
-       public Literal createLiteral(String content) {
-               return createLiteralInternal(valueFactory, content);
-       }
+    public Literal createLiteral(String content) {
+        return createLiteralInternal(valueFactory, content);
+    }
 
-       @Override
-       public Literal createLiteral(String content, Locale language, URI type) 
{
-               return createLiteralInternal(valueFactory, content, language, 
type);
-       }
+    @Override
+    public Literal createLiteral(String content, Locale language, URI type) {
+        return createLiteralInternal(valueFactory, content, language, type);
+    }
 
-       @Override
-       public org.openrdf.model.URI createURI(String uri) {
-               return createURIInternal(valueFactory, uri);
-       }
+    @Override
+    public org.openrdf.model.URI createURI(String uri) {
+        return createURIInternal(valueFactory, uri);
+    }
 
-       @Override
-       public Collection<Value> listObjects(Value subject, Value property) {
-               try {
-                       return listObjectsInternal(connection, (Resource) 
subject, (org.openrdf.model.URI) property, contexts);
-               } catch (RepositoryException e) {
-                       throw new RuntimeException(
-                                       "error while querying Sesame 
repository!", e);
-               } catch (ClassCastException e) {
-                       throw new IllegalArgumentException(String.format(
-                                       "Subject needs to be a URI or blank 
node, property a URI node "
-                                                       + "(types: [subject: 
%s, property: %s])",
-                                       debugType(subject), 
debugType(property)), e);
-               }
-       }
+    @Override
+    public Collection<Value> listObjects(Value subject, Value property) {
+        try {
+            return listObjectsInternal(connection, (Resource) subject, 
(org.openrdf.model.URI) property, includeInferred, contexts);
+        } catch (RepositoryException e) {
+            throw new RuntimeException(
+                    "error while querying Sesame repository!", e);
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException(String.format(
+                    "Subject needs to be a URI or blank node, property a URI 
node "
+                            + "(types: [subject: %s, property: %s])",
+                    debugType(subject), debugType(property)), e);
+        }
+    }
 
-       @Override
-       public Collection<Value> listSubjects(Value property, Value object) {
+    @Override
+    public Collection<Value> listSubjects(Value property, Value object) {
         try {
-               return listSubjectsInternal(connection, (org.openrdf.model.URI) 
property, object, contexts);
+            return listSubjectsInternal(connection, (org.openrdf.model.URI) 
property, object, includeInferred, contexts);
         } catch (RepositoryException e) {
             throw new RuntimeException("error while querying Sesame 
repository!",e);
         } catch (ClassCastException e) {
@@ -90,15 +92,19 @@ public class SesameConnectionBackend extends 
AbstractSesameBackend {
                     "Property needs to be a URI node (property type: %s)",
                     
isURI(property)?"URI":isBlank(property)?"bNode":"literal"),e);
         }
-       }
+    }
 
     /**
      * Create a new {@link SesameConnectionBackend}. This backend is 
context-agnostig (ignores all context information). 
      * @param connection the {@link RepositoryConnection} to use.
      * @see 
ContextAwareSesameConnectionBackend#withConnection(RepositoryConnection, 
Resource...)
      */
-       public static SesameConnectionBackend 
withConnection(RepositoryConnection connection) {
-               return new SesameConnectionBackend(connection);
-       }
-       
+    public static SesameConnectionBackend withConnection(RepositoryConnection 
connection) {
+        return new SesameConnectionBackend(connection);
+    }
+
+    public static SesameConnectionBackend withConnection(RepositoryConnection 
connection, boolean includeInferred) {
+        return new SesameConnectionBackend(connection, includeInferred);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c6e30dd/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
index d98575a..392146c 100644
--- 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
+++ 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameRepositoryBackend.java
@@ -42,20 +42,38 @@ import org.openrdf.repository.RepositoryException;
 public class SesameRepositoryBackend extends AbstractSesameBackend {
 
     private Repository repository;
+    private final boolean includeInferred;
+    private final Resource[] contexts;
 
     /**
      * Initialise a new sesame backend. Repository needs to be set using 
setRepository.
      */
     protected SesameRepositoryBackend() {
+        this.includeInferred = false;
+        this.contexts = new Resource[0];
     }
 
     /**
      * Initialise a new sesame backend using the repository passed as argument.
+     * Queries will include inferred statements and all contexts.
      *
      * @param repository
      */
     public SesameRepositoryBackend(Repository repository) {
+        this(repository, true);
+    }
+
+    /**
+     * Initialise a new sesame backend using the repository.
+     *
+     * @param repository
+     * @param includeInferred
+     * @param contexts
+     */
+    public SesameRepositoryBackend(Repository repository, boolean 
includeInferred, Resource... contexts) {
         this.repository = repository;
+        this.includeInferred = includeInferred;
+        this.contexts = contexts;
     }
 
     public Repository getRepository() {
@@ -75,7 +93,7 @@ public class SesameRepositoryBackend extends 
AbstractSesameBackend {
      */
     @Override
     public Literal createLiteral(String content) {
-       return createLiteralInternal(repository.getValueFactory(), content);
+        return createLiteralInternal(repository.getValueFactory(), content);
     }
 
 
@@ -87,7 +105,7 @@ public class SesameRepositoryBackend extends 
AbstractSesameBackend {
      */
     @Override
     public Literal createLiteral(String content, Locale language, URI type) {
-       return createLiteralInternal(repository.getValueFactory(), content, 
language, type);
+        return createLiteralInternal(repository.getValueFactory(), content, 
language, type);
     }
 
 
@@ -116,8 +134,8 @@ public class SesameRepositoryBackend extends 
AbstractSesameBackend {
             RepositoryConnection connection = repository.getConnection();
 
             try {
-               connection.begin();
-               return listObjectsInternal(connection, (Resource) subject, 
(org.openrdf.model.URI) property);
+                connection.begin();
+                return listObjectsInternal(connection, (Resource) subject, 
(org.openrdf.model.URI) property, includeInferred, contexts);
             } finally {
                 connection.commit();
                 connection.close();
@@ -133,7 +151,7 @@ public class SesameRepositoryBackend extends 
AbstractSesameBackend {
 
     }
 
-       /**
+    /**
      * List the subjects of triples in the triple store underlying this 
backend that have the object and
      * property given as argument.
      *
@@ -148,8 +166,8 @@ public class SesameRepositoryBackend extends 
AbstractSesameBackend {
             final RepositoryConnection connection = repository.getConnection();
 
             try {
-               connection.begin();
-               return listSubjectsInternal(connection, (org.openrdf.model.URI) 
property, object);
+                connection.begin();
+                return listSubjectsInternal(connection, 
(org.openrdf.model.URI) property, object, includeInferred, contexts);
             } finally {
                 connection.commit();
                 connection.close();

http://git-wip-us.apache.org/repos/asf/marmotta/blob/5c6e30dd/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameValueBackend.java
----------------------------------------------------------------------
diff --git 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameValueBackend.java
 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameValueBackend.java
index b341a27..e127886 100644
--- 
a/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameValueBackend.java
+++ 
b/libraries/ldpath/ldpath-backend-sesame/src/main/java/org/apache/marmotta/ldpath/backend/sesame/SesameValueBackend.java
@@ -38,237 +38,237 @@ import org.slf4j.LoggerFactory;
 
 public class SesameValueBackend implements NodeBackend<Value>{
 
-       private static final Logger log = 
LoggerFactory.getLogger(SesameValueBackend.class);
+    private static final Logger log = 
LoggerFactory.getLogger(SesameValueBackend.class);
 
-       public SesameValueBackend() {
-               super();
-       }
+    public SesameValueBackend() {
+        super();
+    }
 
-       /**
-        * Test whether the node passed as argument is a literal
-        *
-        * @param n the node to check
-        * @return true if the node is a literal
-        */
-       @Override
-       public boolean isLiteral(Value n) {
-           return n instanceof Literal;
-       }
+    /**
+     * Test whether the node passed as argument is a literal
+     *
+     * @param n the node to check
+     * @return true if the node is a literal
+     */
+    @Override
+    public boolean isLiteral(Value n) {
+        return n instanceof Literal;
+    }
 
-       /**
-        * Test whether the node passed as argument is a URI
-        *
-        * @param n the node to check
-        * @return true if the node is a URI
-        */
-       @Override
-       public boolean isURI(Value n) {
-           return n instanceof org.openrdf.model.URI;
-       }
+    /**
+     * Test whether the node passed as argument is a URI
+     *
+     * @param n the node to check
+     * @return true if the node is a URI
+     */
+    @Override
+    public boolean isURI(Value n) {
+        return n instanceof org.openrdf.model.URI;
+    }
 
-       /**
-        * Test whether the node passed as argument is a blank node
-        *
-        * @param n the node to check
-        * @return true if the node is a blank node
-        */
-       @Override
-       public boolean isBlank(Value n) {
-           return n instanceof BNode;
-       }
+    /**
+     * Test whether the node passed as argument is a blank node
+     *
+     * @param n the node to check
+     * @return true if the node is a blank node
+     */
+    @Override
+    public boolean isBlank(Value n) {
+        return n instanceof BNode;
+    }
 
-       /**
-        * Return the language of the literal node passed as argument.
-        *
-        * @param n the literal node for which to return the language
-        * @return 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
-        */
-       @Override
-       public Locale getLiteralLanguage(Value n) {
-           try {
-               if(((Literal)n).getLanguage() != null) {
-                   return new Locale( ((Literal)n).getLanguage() );
-               } else {
-                   return null;
-               }
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value "+n.stringValue()+" 
is not a literal" +
-                       "but of type "+debugType(n));
-           }
-       }
+    /**
+     * Return the language of the literal node passed as argument.
+     *
+     * @param n the literal node for which to return the language
+     * @return 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
+     */
+    @Override
+    public Locale getLiteralLanguage(Value n) {
+        try {
+            if(((Literal)n).getLanguage() != null) {
+                return new Locale( ((Literal)n).getLanguage() );
+            } else {
+                return null;
+            }
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+n.stringValue()+" is 
not a literal" +
+                    "but of type "+debugType(n));
+        }
+    }
 
-       /**
-        * Return the URI of the type of the literal node passed as argument.
-        *
-        * @param n the literal node for which to return the typer
-        * @return 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
-        */
-       @Override
-       public URI getLiteralType(Value n) {
-           try {
-               if(((Literal)n).getDatatype() != null) {
-                   try {
-                       return new 
URI(((Literal)n).getDatatype().stringValue());
-                   } catch (URISyntaxException e) {
-                       log.error("literal datatype was not a valid URI: 
{}",((Literal) n).getDatatype());
-                       return null;
-                   }
-               } else {
-                   return null;
-               }
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value "+n.stringValue()+" 
is not a literal" +
-                       "but of type "+debugType(n));
-           }
-       }
+    /**
+     * Return the URI of the type of the literal node passed as argument.
+     *
+     * @param n the literal node for which to return the typer
+     * @return 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
+     */
+    @Override
+    public URI getLiteralType(Value n) {
+        try {
+            if(((Literal)n).getDatatype() != null) {
+                try {
+                    return new URI(((Literal)n).getDatatype().stringValue());
+                } catch (URISyntaxException e) {
+                    log.error("literal datatype was not a valid URI: 
{}",((Literal) n).getDatatype());
+                    return null;
+                }
+            } else {
+                return null;
+            }
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+n.stringValue()+" is 
not a literal" +
+                    "but of type "+debugType(n));
+        }
+    }
 
-       /**
-        * Return the string value 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.
-        *
-        * @param value
-        * @return
-        */
-       @Override
-       public String stringValue(Value value) {
-           return value.stringValue();
-       }
+    /**
+     * Return the string value 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.
+     *
+     * @param value
+     * @return
+     */
+    @Override
+    public String stringValue(Value value) {
+        return value.stringValue();
+    }
 
-       @Override
-       public BigDecimal decimalValue(Value node) {
-           try {
-               return ((Literal)node).decimalValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public BigDecimal decimalValue(Value node) {
+        try {
+            return ((Literal)node).decimalValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public BigInteger integerValue(Value node) {
-           try {
-               return ((Literal)node).integerValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public BigInteger integerValue(Value node) {
+        try {
+            return ((Literal)node).integerValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Boolean booleanValue(Value node) {
-           try {
-               return ((Literal)node).booleanValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Boolean booleanValue(Value node) {
+        try {
+            return ((Literal)node).booleanValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Date dateTimeValue(Value node) {
-           try {
-               XMLGregorianCalendar cal = ((Literal)node).calendarValue();
-               //TODO: check if we need to deal with timezone and Local here
-               return cal.toGregorianCalendar().getTime();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Date dateTimeValue(Value node) {
+        try {
+            XMLGregorianCalendar cal = ((Literal)node).calendarValue();
+            //TODO: check if we need to deal with timezone and Local here
+            return cal.toGregorianCalendar().getTime();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Date dateValue(Value node) {
-           try {
-               XMLGregorianCalendar cal = ((Literal)node).calendarValue();
-               return new GregorianCalendar(cal.getYear(), cal.getMonth(), 
cal.getDay()).getTime();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Date dateValue(Value node) {
+        try {
+            XMLGregorianCalendar cal = ((Literal)node).calendarValue();
+            return new GregorianCalendar(cal.getYear(), cal.getMonth(), 
cal.getDay()).getTime();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Date timeValue(Value node) {
-           //TODO: Unless someone knows how to create a Date that only has the 
time
-           //      from a XMLGregorianCalendar
-           return dateTimeValue(node);
-       }
+    @Override
+    public Date timeValue(Value node) {
+        //TODO: Unless someone knows how to create a Date that only has the 
time
+        //      from a XMLGregorianCalendar
+        return dateTimeValue(node);
+    }
 
-       @Override
-       public Long longValue(Value node) {
-           try {
-               return ((Literal)node).longValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Long longValue(Value node) {
+        try {
+            return ((Literal)node).longValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Double doubleValue(Value node) {
-           try {
-               return ((Literal)node).doubleValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Double doubleValue(Value node) {
+        try {
+            return ((Literal)node).doubleValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Float floatValue(Value node) {
-           try {
-               return ((Literal)node).floatValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Float floatValue(Value node) {
+        try {
+            return ((Literal)node).floatValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
-       @Override
-       public Integer intValue(Value node) {
-           try {
-               return ((Literal)node).intValue();
-           } catch (ClassCastException e) {
-               throw new IllegalArgumentException("Value 
"+node.stringValue()+" is not a literal" +
-                       "but of type "+debugType(node));
-           }
-       }
+    @Override
+    public Integer intValue(Value node) {
+        try {
+            return ((Literal)node).intValue();
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException("Value "+node.stringValue()+" 
is not a literal" +
+                    "but of type "+debugType(node));
+        }
+    }
 
 
-       /**
-        * Prints the type (URI,bNode,literal) by inspecting the parsed {@link 
Value}
-        * to improve error messages and other loggings. In case of literals 
-        * also the {@link #getLiteralType(Value) literal type} is printed
-        * @param value the value or <code>null</code> 
-        * @return the type as string.
-        */
-       protected String debugType(Value value) {
-           return value == null ? 
"null":isURI(value)?"URI":isBlank(value)?"bNode":
-                   "literal ("+getLiteralType(value)+")";
-       }
+    /**
+     * Prints the type (URI,bNode,literal) by inspecting the parsed {@link 
Value}
+     * to improve error messages and other loggings. In case of literals
+     * also the {@link #getLiteralType(Value) literal type} is printed
+     * @param value the value or <code>null</code>
+     * @return the type as string.
+     */
+    protected String debugType(Value value) {
+        return value == null ? 
"null":isURI(value)?"URI":isBlank(value)?"bNode":
+                "literal ("+getLiteralType(value)+")";
+    }
 
-       @Override
-       public Literal createLiteral(String content) {
-               return new LiteralImpl(content);
-       }
+    @Override
+    public Literal createLiteral(String content) {
+        return new LiteralImpl(content);
+    }
 
-       @Override
-       public Literal createLiteral(String content, Locale language, URI type) 
{
-               log.debug("creating literal with content \"{}\", language {}, 
datatype {}",new Object[]{content,language,type});
-               if(language == null && type == null) {
-                       return createLiteral(content);
-               } else if(type == null) {
-                       return new LiteralImpl(content,language.getLanguage());
-               } else  {
-                       return new LiteralImpl(content, 
createURI(type.toString()));
-               }
-       }
+    @Override
+    public Literal createLiteral(String content, Locale language, URI type) {
+        log.debug("creating literal with content \"{}\", language {}, datatype 
{}",new Object[]{content,language,type});
+        if(language == null && type == null) {
+            return createLiteral(content);
+        } else if(type == null) {
+            return new LiteralImpl(content,language.getLanguage());
+        } else  {
+            return new LiteralImpl(content, createURI(type.toString()));
+        }
+    }
 
-       @Override
-       public org.openrdf.model.URI createURI(String uri) {
-               return new URIImpl(uri);
-       }
+    @Override
+    public org.openrdf.model.URI createURI(String uri) {
+        return new URIImpl(uri);
+    }
 
 }
\ No newline at end of file

Reply via email to