net.rootdev.javardfa.output
Class NTripleSink

java.lang.Object
  extended by net.rootdev.javardfa.output.NTripleSink
All Implemented Interfaces:
StatementSink
Direct Known Subclasses:
TurtleSink

public class NTripleSink
extends Object
implements StatementSink

A pretty ropey NTriple serialiser. Advantages: streams, no dependencies.

Author:
pldms

Field Summary
protected  String[] comments
           
protected  PrintWriter out
           
 
Constructor Summary
NTripleSink(OutputStream os, String... comments)
           
NTripleSink(Writer writer, String... comments)
           
 
Method Summary
 void addLiteral(String subject, String predicate, String lex, String lang, String datatype)
          Add statement with a literal object.
 void addObject(String subject, String predicate, String object)
          Add statement with non-literal object.
 void addPrefix(String prefix, String uri)
          Add a prefix mapping.
protected  String enc(int codepoint)
           
protected  String encode(String s)
           
 void end()
          Complete parsing
protected  String longenc(int codepoint)
           
protected  String quote(String lex)
           
 void setBase(String base)
           
 void start()
          Begin parsing
protected  String toLiteral(String lex, String lang, String datatype)
           
protected  String toNode(String node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected final PrintWriter out

comments

protected final String[] comments
Constructor Detail

NTripleSink

public NTripleSink(OutputStream os,
                   String... comments)
            throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

NTripleSink

public NTripleSink(Writer writer,
                   String... comments)
Method Detail

start

public void start()
Description copied from interface: StatementSink
Begin parsing

Specified by:
start in interface StatementSink

end

public void end()
Description copied from interface: StatementSink
Complete parsing

Specified by:
end in interface StatementSink

addObject

public void addObject(String subject,
                      String predicate,
                      String object)
Description copied from interface: StatementSink
Add statement with non-literal object. Blank nodes begin with _:, variables with ?, otherwise IRI

Specified by:
addObject in interface StatementSink
Parameters:
subject - Subject of triple
predicate - Predicate
object - Object

addLiteral

public void addLiteral(String subject,
                       String predicate,
                       String lex,
                       String lang,
                       String datatype)
Description copied from interface: StatementSink
Add statement with a literal object. As above, blank nodes begin with _:, variables with ?, otherwise IRI

Specified by:
addLiteral in interface StatementSink
Parameters:
subject - Subject of triple
predicate - Predicate
lex - Lexical form
lang - Language (may be null)
datatype - Datatype IRI (may be null)

addPrefix

public void addPrefix(String prefix,
                      String uri)
Description copied from interface: StatementSink
Add a prefix mapping.

Specified by:
addPrefix in interface StatementSink

toNode

protected final String toNode(String node)

toLiteral

protected final String toLiteral(String lex,
                                 String lang,
                                 String datatype)

quote

protected final String quote(String lex)

encode

protected final String encode(String s)

enc

protected String enc(int codepoint)

longenc

protected String longenc(int codepoint)

setBase

public void setBase(String base)
Specified by:
setBase in interface StatementSink


Copyright © 2009-2012. All Rights Reserved.