/** Round-trip setup */ static public NodeToLabel createNodeToLabelRT() { return NodeToLabel.createBNodeByLabelEncoded() ; } /** Round-trip setup */
@Override public void formatBNode(AWriter w, Node n) { String x = nodeToLabel.get(null, n) ; w.print(x) ; }
/** Raw string label setup */ static public NodeToLabel createNodeToLabelAsGiven() { return NodeToLabel.createBNodeByLabelAsGiven(); } /** Raw string label setup */
/** Allocation as per internal label */ public static NodeToLabel createBNodeByIRI() { return new NodeToLabel(new SingleScopePolicy(), new AllocatorBNodeAsIRI()) ; }
labelPolicy = NodeToLabel.labelByInternal() ; String label = labelPolicy.get(null, node) ; print(out,label) ; return ;
/** Default setup - scope by document, relabel BNodes ids to short forms */ static public NodeToLabel createNodeToLabel() { return NodeToLabel.createScopeByDocument() ; } /** Default setup - scope by document, relabel BNodes ids to short forms */
@Override public NodeToLabel create() { return NodeToLabel.labelByInternal() ; } @Override public String toString() { return "NodeToLabel.labelByInternal()" ; }
@Override public NodeToLabel create() { return NodeToLabel.createBNodeByIRI() ; } @Override public String toString() { return "NodeToLabel.createBNodeByIRI()" ; }
/** Allocation from a single scope; just the label matters. */ static public NodeToLabel createScopeByDocument() { return new NodeToLabel(new SingleScopePolicy(), new AllocatorIncLabel()) ; }
/** Default setup - scope by document, relabel BNodes ids to short forms */ static public NodeToLabel createNodeToLabel() { return NodeToLabel.createScopeByDocument() ; } static public LabelToNode createLabelToNode() { return LabelToNode.createScopeByDocumentHash() ; }
public NodeFormatterTTL(String baseIRI , PrefixMap prefixMap) //OutputPolicy outputPolicy) { this(baseIRI, prefixMap, NodeToLabel.createBNodeByLabelEncoded()) ; }
@Override public void formatBNode(AWriter w, Node n) { String x = nodeToLabel.get(null, n) ; w.print(x) ; }
/** Allocation as per internal label, with an encoded safe label. */ public static NodeToLabel createBNodeByLabelEncoded() { return new NodeToLabel(new SingleScopePolicy(), new AllocatorInternalSafe()) ; }
static public NodeFormatter createNodeFormatter(PrefixMap pmap, String baseURI, Context context) { if ( context != null && context.isTrue(RIOT.multilineLiterals) ) return new NodeFormatterTTL_MultiLine(baseURI, pmap, NodeToLabel.createScopeByDocument()) ; else return new NodeFormatterTTL(baseURI, pmap, NodeToLabel.createScopeByDocument()) ; }
@Override public NodeToLabel create() { return NodeToLabel.createBNodeByLabelAsGiven() ; } @Override public String toString() { return "NodeToLabel.createBNodeByLabelAsGiven()" ; }
public NodeFormatterTTL(String baseIRI, PrefixMap prefixMap) { this(baseIRI, prefixMap, NodeToLabel.createBNodeByLabelEncoded()) ; }
private String blankNodeOrIRIString(Node x) { if ( x.isURI() ) return x.getURI() ; if ( x.isBlank() ) return labels.get(null, x) ; return null ; } }
/** Allocation as per internal label */ public static NodeToLabel createBNodeByLabelAsGiven() { return new NodeToLabel(new SingleScopePolicy(), new AllocatorInternalRaw()) ; }
protected TurtleShell(IndentedWriter out, PrefixMap pmap, String baseURI) { this.out = out ; if ( pmap == null ) pmap = PrefixMapFactory.emptyPrefixMap() ; this.nodeFmt = new NodeFormatterTTL(baseURI, pmap, NodeToLabel.createScopeByDocument()) ; this.prefixMap = pmap ; this.baseURI = baseURI ; }