/** * Escapes a Unicode string to an all-ASCII character sequence. Any special characters are escaped using * backslashes (<tt>"</tt> becomes <tt>\"</tt>, etc.), and non-ascii/non-printable characters are escaped * using Unicode escapes (<tt>\uxxxx</tt> and <tt>\Uxxxxxxxx</tt>). * * @throws IOException */ public static void escapeString(String label, Appendable appendable) throws IOException { escapeString(label, appendable, true); }
/** * Escapes a Unicode string to an all-ASCII character sequence. Any special characters are escaped using * backslashes (<tt>"</tt> becomes <tt>\"</tt>, etc.), and non-ascii/non-printable characters are escaped * using Unicode escapes (<tt>\uxxxx</tt> and <tt>\Uxxxxxxxx</tt>). * * @throws IOException */ public static void escapeString(String label, Appendable appendable) throws IOException { escapeString(label, appendable, true); }
/** * Writes a Unicode string to an N-Triples compatible character sequence. Any special characters are * escaped using backslashes (<tt>"</tt> becomes <tt>\"</tt>, etc.), and non-ascii/non-printable * characters are escaped using Unicode escapes (<tt>\uxxxx</tt> and <tt>\Uxxxxxxxx</tt>) if the * writer config is enabled. * * @throws IOException */ private void writeString(String label) throws IOException { NTriplesUtil.escapeString(label, writer, escapeUnicode); } }
/** * Writes a Unicode string to an N-Triples compatible character sequence. Any special characters are * escaped using backslashes (<tt>"</tt> becomes <tt>\"</tt>, etc.), and non-ascii/non-printable * characters are escaped using Unicode escapes (<tt>\uxxxx</tt> and <tt>\Uxxxxxxxx</tt>) if the * writer config is enabled. * * @throws IOException */ private void writeString(String label) throws IOException { NTriplesUtil.escapeString(label, writer, escapeUnicode); } }
/** * Escapes a Unicode string to an all-ASCII character sequence. Any special characters are escaped using * backslashes (<tt>"</tt> becomes <tt>\"</tt>, etc.), and non-ascii/non-printable characters are escaped * using Unicode escapes (<tt>\uxxxx</tt> and <tt>\Uxxxxxxxx</tt>). */ public static String escapeString(String label) { try { StringBuilder sb = new StringBuilder(2 * label.length()); escapeString(label, sb); return sb.toString(); } catch (IOException e) { throw new AssertionError(); } }
/** * Escapes a Unicode string to an all-ASCII character sequence. Any special characters are escaped using * backslashes (<tt>"</tt> becomes <tt>\"</tt>, etc.), and non-ascii/non-printable characters are escaped * using Unicode escapes (<tt>\uxxxx</tt> and <tt>\Uxxxxxxxx</tt>). */ public static String escapeString(String label) { try { StringBuilder sb = new StringBuilder(2 * label.length()); escapeString(label, sb); return sb.toString(); } catch (IOException e) { throw new AssertionError(); } }
/** * Creates an N-Triples string for the supplied URI. */ public static String toNTriplesString(IRI uri) { return "<" + escapeString(uri.toString()) + ">"; }
/** * Creates an N-Triples string for the supplied URI. */ public static String toNTriplesString(IRI uri) { return "<" + escapeString(uri.toString()) + ">"; }
/** * Returns formatted string that filters the given variable for the given language * @param filterVariable * @return */ private static final String languageFilter(String filterVariable, String aLanguage) { StringBuilder fragment = new StringBuilder(); if (aLanguage != null) { // If a certain language is specified, we look exactly for that String escapedLang = NTriplesUtil.escapeString(aLanguage); fragment.append(" FILTER(LANGMATCHES(LANG(").append(filterVariable).append("), \"").append(escapedLang).append("\"))\n"); } else { // If no language is specified, we look for statements without a language as otherwise // we might easily run into trouble on multi-lingual resources where we'd get all the // labels in all the languages being retrieved if we simply didn't apply any filter. fragment.append(" FILTER(LANG(").append(filterVariable).append(") = \"\")\n"); } return fragment.toString(); }
/** * Returns formatted string that filters the given variable for the given language * @param filterVariable * @return */ private static final String languageFilter(String filterVariable, String aLanguage) { StringBuilder fragment = new StringBuilder(); if (aLanguage != null) { // If a certain language is specified, we look exactly for that String escapedLang = NTriplesUtil.escapeString(aLanguage); fragment.append(" FILTER(LANGMATCHES(LANG(").append(filterVariable).append("), \"").append(escapedLang).append("\"))\n"); } else { // If no language is specified, we look for statements without a language as otherwise // we might easily run into trouble on multi-lingual resources where we'd get all the // labels in all the languages being retrieved if we simply didn't apply any filter. fragment.append(" FILTER(LANG(").append(filterVariable).append(") = \"\")\n"); } return fragment.toString(); }
public static void append(IRI uri, Appendable appendable) throws IOException { StringBuilder sb = new StringBuilder(); escapeString(uri.toString(), sb); String s = sb.toString(); s = StringUtil.gsub("<", "\\u003C", s); s = StringUtil.gsub(">", "\\u003E", s); appendable.append("<").append(s).append(">"); }
public static void append(IRI uri, Appendable appendable) throws IOException { StringBuilder sb = new StringBuilder(); escapeString(uri.toString(), sb); String s = sb.toString(); s = StringUtil.gsub("<", "\\u003C", s); s = StringUtil.gsub(">", "\\u003E", s); appendable.append("<").append(s).append(">"); }
escapeString(lit.getLabel(), appendable); appendable.append("\"");
escapeString(lit.getLabel(), appendable); appendable.append("\"");