/** Answer a human-readable representation of this Node. It will not compress URIs, nor quote literals (because at the moment too many places use toString() for something machine-oriented). */ @Override public String toString() { return toString( null ); }
/** Answer a human-readable representation of the Node, quoting literals and compressing URIs. */ public String toString( PrefixMapping pm ) { return toString( pm, true ); }
/** Answer a human-readable representation of this Node where literals are quoted according to <code>quoting</code> but URIs are not compressed. */ public String toString( boolean quoting ) { return toString( null, quoting ); }
public String asUnquotedString() { if ( ! isSet ) return "literal:unset" ; if ( isInt ) return Long.toString(valInt) ; if ( isDouble ) return Double.toString(valDouble) ; if ( isBoolean ) return (valBoolean?"true":"false") ; if ( isURI ) return valURI ; if ( isString ) return valString ; if ( isGraphNode ) return valGraphNode.toString() ; return "literal:unknown" ; }
/** * Set a {@link ParameterizedSparqlString} null * * @param pss * @param name */ public static void setNull(ParameterizedSparqlString pss, String name) { pss.setLiteral(name, Node.NULL.toString()); }
/** * Set a {@link ParameterizedSparqlString} null * * @param pss * @param name */ public static void setNull(ParameterizedSparqlString pss, String name) { pss.setLiteral(name, Node.NULL.toString()); }
private static String format(Node node, StringRepresentation representation) { if (node == Node.ANY) { return "?"; } return representation.apply(node.toString()); }
@Override public int getPartition(WritableTriple key, WritableTriple value, int i) { return abs(key.getTriple().getSubject().toString().hashCode()) % i; } }
@Override public String stringValue(Node node) { if(node.isLiteral()){ //we do not want '"example"@en' but 'example' return node.getLiteralLexicalForm(); } else { return node.toString(); } }
@Override public String stringValue(Node node) { if(node.isLiteral()){ //we do not want '"example"@en' but 'example' return node.getLiteralLexicalForm(); } else { return node.toString(); } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new IndividualImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to Individual"); } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new OntResourceImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to OntResource"); } }
@Override public EnhNode wrap( Node n, EnhGraph eg ) { if (canWrap( n, eg )) { return new OntClassImpl( n, eg ); } else { throw new ConversionException( "Cannot convert node " + n.toString() + " to OntClass: it does not have rdf:type owl:Class or equivalent"); } }
/** Answer a "nice" representation of <code>r</code>, suitable for appearance within an exception message. */ protected static String nice( Resource r ) { String rString = r.asNode().toString( r.getModel() ); return r.isAnon() ? rString + getLabels( r ) : rString; }
protected String resource(Node rsrc) { if (rsrc.isBlank()) { return "http://marklogic.com/semantics/blank/" + Long.toHexString( fuse(scramble((long)rsrc.hashCode()),fuse(scramble(milliSecs),randomValue))); } else { return escapeXml(rsrc.toString()); } }
private static String getLabels( Resource r ) { Model m = r.getModel(); String labels = "", prefix = "labels: "; for (StmtIterator it = r.listProperties( RDFS.label ); it.hasNext();) { String label = it.nextStatement().getObject().asNode().toString( m, true ); labels += prefix + label; prefix = ", "; } return labels.equals( "" ) ? getIncomingProperty( r ) : " [" + labels + "]"; }