public static boolean isName(String str) { if (isNameStartChar(str.charAt(0))) { for (int i = 1; i < str.length(); i++) { if (!isNameChar(str.charAt(i))) { return false; } } return true; } else { return false; } }
public static boolean isNameStartChar(int c) { return c == '_' || isPrefixStartChar(c); }
protected void append(LIT lit) throws IOException { String val = lit.getValue(); if (val.indexOf('\n') > 0 || val.indexOf('\r') > 0 || val.indexOf('\t') > 0) { appendable.append("\"\"\""); appendable.append(TurtleUtil.encodeLongString(val)); appendable.append("\"\"\""); } else { appendable.append("\""); appendable.append(TurtleUtil.encodeString(val)); appendable.append("\""); } if (lit.getLang() != null) { appendable.append("@").append(LocaleUtil.toLang(lit.getLang())); } else if (!lit.getDatatype().equals(RDF.text)) { appendable.append("^^"); append(lit.getDatatype()); } }
public static boolean isPrefixChar(int c) { return isNameChar(c); }
public static boolean isNameChar(int c) { return isNameStartChar(c) || Character.isDigit(c) || c == '-' || c == 0x00B7 || c >= 0x0300 && c <= 0x036F || c >= 0x203F && c <= 0x2040; }
@Override public void begin() { try { for (Map.Entry<String, String> entry : prefixes.entrySet()) { appendable.append("@prefix "); appendable.append(entry.getValue()); appendable.append(": <"); appendable.append(TurtleUtil.encodeString(entry.getKey())); appendable.append("> .\n"); } appendable.append("\n"); } catch (IOException e) { throw new RepositoryException(e); } }
protected void append(UID uid) throws IOException { if (uid.ln().length() == 0 || !TurtleUtil.isName(uid.ln())) { appendFull(uid); } else { appendPrefixed(uid); } }