1 5 6 7 8 package com.hp.hpl.jena.rdql.parser; 9 10 11 import com.hp.hpl.jena.rdql.Query; 12 13 public class Q_TextLiteral2 extends ParsedLiteral { 14 15 String seen = null ; 16 17 Q_TextLiteral2(int id) { 18 super(id); 19 } 20 21 Q_TextLiteral2(RDQLParser p, int id) { 22 super(p, id); 23 } 24 25 void set(String s) 26 { 27 seen = s ; 28 s = s.substring(1,s.length()-1) ; 30 super._setString(unescape(s,'\\')) ; 31 } 32 33 public void jjtClose() 34 { 35 } 37 38 public void postParse(Query query) 39 { 40 super.postParse(query) ; 41 com.hp.hpl.jena.graph.Node n = null ; 42 n = com.hp.hpl.jena.graph.Node.createLiteral(super.getString(), null, null) ; 43 super._setNode(n) ; 44 } 45 46 public String asQuotedString() 47 { 48 return seen ; 49 } 51 52 static String unescape(String s, char escape) 54 { 55 for ( int i = 0 ; i < s.length() ; i++ ) 56 { 57 if ( s.charAt(i) != escape ) 58 continue ; 59 if ( i >= s.length()-1 ) 61 continue ; 63 char ch2 = s.charAt(i+1) ; 64 if ( ch2 == 'n' ) ch2 = '\n' ; 65 if ( ch2 == 't' ) ch2 = '\t' ; 66 if ( ch2 == 'r' ) ch2 = '\r' ; 67 if ( ch2 == 'b' ) ch2 = '\b' ; 68 74 75 s = s.substring(0,i)+ch2+s.substring(i+2) ; 77 } 80 return s ; 81 } 82 } 83 84 110 | Popular Tags |