Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
CLEREZZA-1001: Using rdf:langString datatype where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
retog committed Oct 3, 2015
1 parent 6677feb commit 4627115
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Expand Up @@ -98,6 +98,7 @@ final public static class SparqlsResultsHandler extends DefaultHandler {
private String value;
private Map<String, BlankNode> bNodeMap = new HashMap<>();
private static final IRI XSD_STRING = new IRI("http://www.w3.org/2001/XMLSchema#string");
private static final IRI RDF_LANG_STRING = new IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");

private RDFTerm getBNode(String value) {
if (!bNodeMap.containsKey(value)) {
Expand Down Expand Up @@ -195,6 +196,9 @@ public String getLexicalForm() {

@Override
public IRI getDataType() {
if (language != null) {
return RDF_LANG_STRING;
}
//TODO implement
return XSD_STRING;
}
Expand Down
Expand Up @@ -30,14 +30,11 @@
*/
public class PlainLiteralImpl extends AbstractLiteral implements Literal, Serializable {

private String lexicalForm;
private Language language = null;
private final String lexicalForm;
private final Language language;

public PlainLiteralImpl(String value) {
if (value == null) {
throw new IllegalArgumentException("The literal string cannot be null");
}
this.lexicalForm = value;
this(value, null);
}

public PlainLiteralImpl(String value, Language language) {
Expand All @@ -46,6 +43,11 @@ public PlainLiteralImpl(String value, Language language) {
}
this.lexicalForm = value;
this.language = language;
if (language == null) {
dataType = XSD_STRING;
} else {
dataType = RDF_LANG_STRING;
}
}

@Override
Expand All @@ -70,8 +72,10 @@ public String toString() {

@Override
public IRI getDataType() {
return XSD_STRING;
return dataType;
}
private final IRI dataType;
private static final IRI XSD_STRING = new IRI("http://www.w3.org/2001/XMLSchema#string");
private static final int XSD_STRING_HASH = XSD_STRING.hashCode();
private static final IRI RDF_LANG_STRING = new IRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString");
//private static final int XSD_STRING_HASH = dataType.hashCode();
}

0 comments on commit 4627115

Please sign in to comment.