de.fuberlin.wiwiss.ng4j.trig
Class N3JenaWriterCommon
java.lang.Object
de.fuberlin.wiwiss.ng4j.trig.N3JenaWriterCommon
- All Implemented Interfaces:
- RDFWriter
- Direct Known Subclasses:
- N3JenaWriterPP
public class N3JenaWriterCommon
- extends Object
- implements RDFWriter
Common framework for implementing N3 writers.
- Version:
- $Id: N3JenaWriterCommon.java,v 1.2 2004/12/17 11:15:31 cyganiak Exp $
- Author:
- Andy Seaborne
Method Summary |
protected String |
absolutePropName(String propName)
|
protected int |
calcPropertyPadding(String propStr)
|
protected int |
countArcsTo(Property prop,
Resource resource)
|
protected int |
countArcsTo(Resource resource)
|
protected int |
countProperties(Resource r)
|
protected int |
countProperties(Resource r,
Property p)
|
protected void |
finishWriting()
|
protected String |
formatLiteral(Literal literal)
|
protected String |
formatNode(RDFNode node)
|
protected String |
formatProperty(Property p)
|
protected String |
formatResource(Resource r)
|
protected String |
formatURI(String uriStr)
|
protected boolean |
getBooleanValue(String prop,
boolean defaultValue)
|
protected int |
getIntValue(String prop,
int defaultValue)
|
protected String |
getPropValue(String prop)
|
protected String |
getStringValue(String prop,
String defaultValue)
|
protected String |
localPropName(String propName)
|
protected static String |
pad(int cols)
|
protected void |
prepare(Model model)
|
protected ClosableIterator |
preparePropertiesForSubject(Resource r)
|
protected void |
processModel(Model baseModel)
|
protected Iterator |
rdfListIterator(Resource r)
|
RDFErrorHandler |
setErrorHandler(RDFErrorHandler errHandler)
|
Object |
setProperty(String propName,
Object propValue)
|
protected boolean |
skipThisSubject(Resource r)
|
protected void |
startWriting()
|
protected static void |
string(StringBuffer sbuff,
String s,
boolean singleQuoteLiteral)
|
void |
write(Model model,
OutputStream output,
String base)
Write the model out in N3, encoded in in UTF-8 |
void |
write(Model baseModel,
Writer _out,
String base)
Write the model out in N3. |
protected void |
writeHeader(Model model)
|
protected void |
writeLiteral(Literal literal)
|
protected void |
writeModel(Model model)
|
protected void |
writeObject(RDFNode node)
|
protected void |
writeObjectList(Resource resource,
Property property)
|
protected void |
writeOneGraphNode(Resource subject)
|
protected void |
writePrefixes(Model model)
|
protected void |
writePropertiesForSubject(Resource subj)
|
protected void |
writeSubject(Resource subject)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
N3JenaWriterCommon
public N3JenaWriterCommon()
setErrorHandler
public RDFErrorHandler setErrorHandler(RDFErrorHandler errHandler)
- Specified by:
setErrorHandler
in interface RDFWriter
setProperty
public Object setProperty(String propName,
Object propValue)
- Specified by:
setProperty
in interface RDFWriter
write
public void write(Model baseModel,
Writer _out,
String base)
- Write the model out in N3. The writer should be one suitable for UTF-8 which
excludes a PrintWriter or a FileWriter which use default character set.
Examples:
try {
Writer w = new BufferedWriter(new OutputStreamWriter(output, "UTF-8")) ;
model.write(w, base) ;
try { w.flush() ; } catch (IOException ioEx) {}
} catch (java.io.UnsupportedEncodingException ex) {} //UTF-8 is required so can't happen
or
try {
OutputStream out = new FileOutputStream(file) ;
Writer w = new BufferedWriter(new OutputStreamWriter(out, "UTF-8")) ;
model.write(w, base) ;
}
catch (java.io.UnsupportedEncodingException ex) {}
catch (java.io.FileNotFoundException noFileEx) { ... }
- Specified by:
write
in interface RDFWriter
- See Also:
write(Model,Writer,String)
write
public void write(Model model,
OutputStream output,
String base)
- Write the model out in N3, encoded in in UTF-8
- Specified by:
write
in interface RDFWriter
- See Also:
write(Model,Writer,String)
startWriting
protected void startWriting()
finishWriting
protected void finishWriting()
prepare
protected void prepare(Model model)
processModel
protected void processModel(Model baseModel)
writeModel
protected void writeModel(Model model)
writeOneGraphNode
protected void writeOneGraphNode(Resource subject)
writePropertiesForSubject
protected void writePropertiesForSubject(Resource subj)
skipThisSubject
protected boolean skipThisSubject(Resource r)
writeSubject
protected void writeSubject(Resource subject)
writeHeader
protected void writeHeader(Model model)
writePrefixes
protected void writePrefixes(Model model)
writeObjectList
protected void writeObjectList(Resource resource,
Property property)
formatNode
protected String formatNode(RDFNode node)
writeObject
protected void writeObject(RDFNode node)
writeLiteral
protected void writeLiteral(Literal literal)
preparePropertiesForSubject
protected ClosableIterator preparePropertiesForSubject(Resource r)
formatResource
protected String formatResource(Resource r)
formatLiteral
protected String formatLiteral(Literal literal)
formatProperty
protected String formatProperty(Property p)
formatURI
protected String formatURI(String uriStr)
string
protected static void string(StringBuffer sbuff,
String s,
boolean singleQuoteLiteral)
calcPropertyPadding
protected int calcPropertyPadding(String propStr)
pad
protected static String pad(int cols)
countProperties
protected int countProperties(Resource r)
countProperties
protected int countProperties(Resource r,
Property p)
countArcsTo
protected int countArcsTo(Resource resource)
countArcsTo
protected int countArcsTo(Property prop,
Resource resource)
rdfListIterator
protected Iterator rdfListIterator(Resource r)
getStringValue
protected String getStringValue(String prop,
String defaultValue)
getBooleanValue
protected boolean getBooleanValue(String prop,
boolean defaultValue)
getIntValue
protected int getIntValue(String prop,
int defaultValue)
getPropValue
protected String getPropValue(String prop)
absolutePropName
protected String absolutePropName(String propName)
localPropName
protected String localPropName(String propName)