org.apache.jena.atlas.io.AWriter Java Examples
The following examples show how to use
org.apache.jena.atlas.io.AWriter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RDFChangesWriteUpdate.java From rdf-delta with Apache License 2.0 | 6 votes |
public RDFChangesWriteUpdate(AWriter out) { this.out = out; this.pmap = PrefixMapFactory.create(); // Without prefixes on output - set pmap to null. // Avoid Jena 3.10.0 and earlier error that deleting prefixes does not stop abbreviation. // Fixes in Jena 3.11.0 when "pmap" can be used. this.formatter = new NodeFormatterTTL(null, /*pmap*/null) { @Override // Fix NodeFormatterTTL in Jena. public void formatBNode(AWriter w, Node n) { formatBNode(w, n.getBlankNodeLabel()); } // Write as a URI. @Override public void formatBNode(AWriter w, String label) { w.print("<_:"); String lab = NodeFmtLib.encodeBNodeLabel(label); w.print(lab); w.print(">"); } }; }
Example #2
Source File: TestFileStore.java From rdf-delta with Apache License 2.0 | 6 votes |
@Test public void fs_write_01() throws IOException { FileStore fs = FileStore.attach(STORE, "FILE"); assertEquals(0, fs.getCurrentIndex()); FileEntry entry = fs.writeNewFile(out->{ try(AWriter aw = IO .wrapUTF8(out)) { aw.write("abc"); } }) ; assertNotNull(entry); assertNotNull(entry.datafile); int idx = checkFilename(entry.datafile); assertEquals(1, idx); // Read it back in again. String s = FileUtils.readWholeFileAsUTF8(entry.getDatafileName()); assertEquals("abc", s); }
Example #3
Source File: patch2update.java From rdf-delta with Apache License 2.0 | 6 votes |
@Override protected void exec() { AWriter out = IO.wrapUTF8(System.out); // Generalize to abstract class for any "apply" - patch2rdf RDFChanges c = new RDFChangesWriteUpdate(out); // Patches if ( getPositional().isEmpty() ) execOne(System.in); getPositional().forEach(fn->{ // Check patch threading? RDFPatch patch = RDFPatchOps.read(fn); if ( isVerbose() ) { System.err.printf("# Patch id=%s", Id.str(patch.getId())); if ( patch.getPrevious() != null ) System.err.printf(" prev=%s", Id.str(patch.getPrevious())); System.err.println(); } patch.apply(c); }); out.flush(); }
Example #4
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Override public void format(AWriter w, Node n) { if ( n instanceof Node_Triple ) Helper.format(w, (Node_Triple) n, this); else wrappedFormatter.format(w, n); }
Example #5
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 5 votes |
@Override public void format(AWriter w, Node n) { if ( n.isBlank() ) formatBNode(w, n); else super.format(w, n); }
Example #6
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 5 votes |
public TokenWriterText(String label, NodeFormatter formatter, AWriter out) { if ( formatter == null ) // For the number abbreviations. formatter = new NodeFormatterTTL(null, PrefixMapFactory.emptyPrefixMap()); // Must write bNodes as <_:....> formatter = new NodeFormatterBNode(formatter); this.fmt = formatter; this.out = out; this.label = label; }
Example #7
Source File: AbstractNodeFormatterTurtleStarTest.java From RDFstarTools with Apache License 2.0 | 5 votes |
protected String serialize( Node n ) { StringWriter w = new StringWriter(); try ( AWriter aw = Writer2.wrap(w) ) { formatter.format(aw, n); } return w.toString(); }
Example #8
Source File: NodeFormatterTurtleStarExtImpl.java From RDFstarTools with Apache License 2.0 | 5 votes |
@Override public void format(AWriter w, Node n) { if ( n instanceof Node_Triple ) Helper.format(w, (Node_Triple) n, this); else super.format(w, n); }
Example #9
Source File: NodeFormatterTurtleStar.java From RDFstarTools with Apache License 2.0 | 5 votes |
static public void format(AWriter w, Node_Triple n, NodeFormatter nf) { final Triple t = n.get(); w.print("<<"); nf.format(w, t.getSubject()); w.print(' '); nf.format(w, t.getPredicate()); w.print(' '); nf.format(w, t.getObject()); w.print(">>"); }
Example #10
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatBNode(AWriter w, Node n) { fmt.formatBNode(w, n); }
Example #11
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatVar(AWriter w, String name) { fmt.formatVar(w, name); }
Example #12
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatBNode(AWriter w, String label) { fmt.formatBNode(w, label); }
Example #13
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatLiteral(AWriter w, Node n) { fmt.formatLiteral(w, n); }
Example #14
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatLitString(AWriter w, String lex) { fmt.formatLitString(w, lex); }
Example #15
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatLitLang(AWriter w, String lex, String langTag) { fmt.formatLitLang(w, lex, langTag); }
Example #16
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatLitDT(AWriter w, String lex, String datatypeURI) { fmt.formatLitDT(w, lex, datatypeURI); }
Example #17
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatVar(AWriter w, Node n) { fmt.formatVar(w, n); }
Example #18
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatURI(AWriter w, String uriStr) { fmt.formatURI(w, uriStr); }
Example #19
Source File: RDFChangesWriteUpdate.java From rdf-delta with Apache License 2.0 | 4 votes |
private void outputNode(AWriter out, Node node) { formatter.format(out, node); }
Example #20
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatURI(AWriter w, Node n) { wrappedFormatter.formatURI(w, n); }
Example #21
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatURI(AWriter w, Node n) { fmt.formatURI(w, n); }
Example #22
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void format(AWriter w, Node n) { fmt.format(w, n); }
Example #23
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatBNode(AWriter w, String label) { w.print("<_:"); w.print(label); w.print(">"); }
Example #24
Source File: TokenWriterText.java From rdf-delta with Apache License 2.0 | 4 votes |
@Override public void formatBNode(AWriter w, Node n) { formatBNode(w, n.getBlankNodeLabel()); }
Example #25
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatLitDT(AWriter w, String lex, String datatypeURI) { wrappedFormatter.formatLitDT(w, lex, datatypeURI); }
Example #26
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatLitLang(AWriter w, String lex, String langTag) { wrappedFormatter.formatLitLang(w, lex, langTag); }
Example #27
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatLitString(AWriter w, String lex) { wrappedFormatter.formatLitString(w, lex); }
Example #28
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatLiteral(AWriter w, Node n) { wrappedFormatter.formatLiteral(w, n); }
Example #29
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatBNode(AWriter w, String label) { wrappedFormatter.formatBNode(w, label); }
Example #30
Source File: NodeFormatterTurtleStarWrapperImpl.java From RDFstarTools with Apache License 2.0 | 4 votes |
@Override public void formatBNode(AWriter w, Node n) { wrappedFormatter.formatBNode(w, n); }