jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [5/6] jena git commit: Escape \" in LiteralLabel.toString.
Date Sun, 23 Nov 2014 11:04:08 GMT
Escape \" in LiteralLabel.toString.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2111efcf
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2111efcf
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2111efcf

Branch: refs/heads/master
Commit: 2111efcf4ed6e378fe8491872e54ce3868c5f509
Parents: d753212
Author: Andy Seaborne <andy@apache.org>
Authored: Sat Nov 22 17:33:18 2014 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Sat Nov 22 17:33:18 2014 +0000

----------------------------------------------------------------------
 .../hpl/jena/graph/impl/LiteralLabelImpl.java   | 24 ++++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2111efcf/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
index 97d6015..cb8be15 100644
--- a/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
+++ b/jena-core/src/main/java/com/hp/hpl/jena/graph/impl/LiteralLabelImpl.java
@@ -24,9 +24,11 @@ import java.util.Objects ;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.hp.hpl.jena.JenaRuntime ;
 import com.hp.hpl.jena.datatypes.*;
 import com.hp.hpl.jena.datatypes.xsd.*;
 import com.hp.hpl.jena.datatypes.xsd.impl.*;
+import com.hp.hpl.jena.rdf.model.impl.Util ;
 import com.hp.hpl.jena.shared.impl.JenaParameters;
 
 /**
@@ -267,13 +269,21 @@ final /*public*/ class LiteralLabelImpl implements LiteralLabel {
 	*/
 	@Override
     public String toString(boolean quoting) {
-		StringBuilder b = new StringBuilder();
-		if (quoting) b.append('"');
-		b.append(getLexicalForm());
-		if (quoting) b.append('"');
-		if (lang != null && !lang.equals( "" )) b.append( "@" ).append(lang);
-		if (dtype != null) b.append( "^^" ).append(dtype.getURI());
-		return b.toString();
+        StringBuilder b = new StringBuilder() ;
+        if ( quoting )
+            b.append('"') ;
+        String lex = getLexicalForm() ;
+        lex = Util.replace(lex, "\"", "\\\"") ;
+        b.append(lex) ;
+        if ( quoting )
+            b.append('"') ;
+        if ( lang != null && !lang.equals("") )
+            b.append("@").append(lang) ;
+        else if ( dtype != null ) {
+            if ( ! ( JenaRuntime.isRDF11 && dtype.equals(XSDDatatype.XSDstring) )
)  
+                b.append("^^").append(dtype.getURI()) ;
+        }
+        return b.toString() ;
 	}
 
 	@Override


Mime
View raw message