obj = ((RDFDataset.Literal) object).getValue(); final String lang = ((RDFDataset.Literal) object).getLanguage(); final String dt = ((RDFDataset.Literal) object).getDatatype(); if (lang != null) { obj = "\"" + obj + "\"";
@Override public int compareTo(Node o) { if (o == null) { // valid nodes are > null nodes return 1; } if (o.isIRI()) { // literals < iri return -1; } if (o.isBlankNode()) { // blank node < iri return -1; } if (this.getLanguage() == null && ((Literal) o).getLanguage() != null) { return -1; } else if (this.getLanguage() != null && ((Literal) o).getLanguage() == null) { return 1; } if (this.getDatatype() != null) { return this.getDatatype().compareTo(((Literal) o).getDatatype()); } else if (((Literal) o).getDatatype() != null) { return -1; } return 0; } }
@Override public int compareTo(Node o) { // NOTE: this will also compare getValue() early! final int nodeCompare = super.compareTo(o); if (nodeCompare != 0) { // null, different type or different value return nodeCompare; } if (this.getLanguage() != null || o.getLanguage() != null) { // We'll ignore type-checking if either has language tag // as language tagged literals should always have the type // rdf:langString in RDF 1.1 return nullSafeCompare(this.getLanguage(), o.getLanguage()); } else { return nullSafeCompare(this.getDatatype(), o.getDatatype()); } // NOTE: getValue() already compared by super.compareTo() } }
@Override public int compareTo(Node o) { // NOTE: this will also compare getValue() early! final int nodeCompare = super.compareTo(o); if (nodeCompare != 0) { // null, different type or different value return nodeCompare; } if (this.getLanguage() != null || o.getLanguage() != null) { // We'll ignore type-checking if either has language tag // as language tagged literals should always have the type // rdf:langString in RDF 1.1 return nullSafeCompare(this.getLanguage(), o.getLanguage()); } else { return nullSafeCompare(this.getDatatype(), o.getDatatype()); } // NOTE: getValue() already compared by super.compareTo() } }