com.hp.hpl.jena.n3
Class N3JenaWriter

java.lang.Object
  |
  +--com.hp.hpl.jena.n3.N3JenaWriter
All Implemented Interfaces:
RDFWriter

public class N3JenaWriter
extends java.lang.Object
implements RDFWriter

An N3 pretty printer. Tries to make N3 data look readable - works better on regular data.

Version:
$Id: N3JenaWriter.java,v 1.7 2003/01/10 09:16:22 andy_seaborne Exp $
Author:
Andy Seaborne

Field Summary
static boolean DEBUG
           
static java.lang.String propWriteSimple
           
 
Fields inherited from interface com.hp.hpl.mesa.rdf.jena.model.RDFWriter
NSPREFIXPROPBASE
 
Constructor Summary
N3JenaWriter()
           
 
Method Summary
 RDFErrorHandler setErrorHandler(RDFErrorHandler errHandler)
          Set an error handler.
 void setNsPrefix(java.lang.String prefix, java.lang.String ns)
          Set the the namespace prefix to be used for a particular namespace.
 java.lang.Object setProperty(java.lang.String propName, java.lang.Object propValue)
          Set a property to control the behaviour of this writer.
 void write(Model model, java.io.OutputStream output, java.lang.String base)
          Write the model out in N3, encoded in in UTF-8
 void write(Model model, java.io.Writer _out, java.lang.String base)
          Write the model out in N3.
 void writeSimple(Model model, java.io.Writer _out, java.lang.String base)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

propWriteSimple

public static final java.lang.String propWriteSimple
See Also:
Constant Field Values
Constructor Detail

N3JenaWriter

public N3JenaWriter()
Method Detail

setErrorHandler

public RDFErrorHandler setErrorHandler(RDFErrorHandler errHandler)
Description copied from interface: RDFWriter
Set an error handler.

Specified by:
setErrorHandler in interface RDFWriter
Parameters:
errHandler - The new error handler to be used.
Returns:
the old error handler

setNsPrefix

public void setNsPrefix(java.lang.String prefix,
                        java.lang.String ns)
Description copied from interface: RDFWriter
Set the the namespace prefix to be used for a particular namespace.

Specified by:
setNsPrefix in interface RDFWriter
Parameters:
prefix - the prefix to be used
ns - the namespace

setProperty

public java.lang.Object setProperty(java.lang.String propName,
                                    java.lang.Object propValue)
                             throws RDFException
Description copied from interface: RDFWriter
Set a property to control the behaviour of this writer.

An RDFWriter's behaviour can be influenced by defining property values interpreted by that particular writer class. The values for such properties can be changed by calling this method.

No standard properties are defined. For the properties recognised by any particular writer implementation, see the the documentation for that implementation. The properties recognised by writers provided in the standard distribution can be found in the description of their setProperty method. Consult the list of implementors of this interface given above.

Specified by:
setProperty in interface RDFWriter
Parameters:
propName - The name of the property.
propValue - The new value of the property
Returns:
the old value for this property, or null if no value was set.
Throws:
RDFException - Throws a generic RDF exception

write

public void write(Model model,
                  java.io.Writer _out,
                  java.lang.String base)
           throws RDFException
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
Parameters:
_out - The Writer to which the serialization should be sent.
model - The model to be written.
base - the base URI for relative URI calculations. null means use only absolute URI's.
Throws:
RDFException - Generic RDF exception.

write

public void write(Model model,
                  java.io.OutputStream output,
                  java.lang.String base)
           throws RDFException
Write the model out in N3, encoded in in UTF-8

RDFException
See Also:
write(Model,Writer,String)

writeSimple

public void writeSimple(Model model,
                        java.io.Writer _out,
                        java.lang.String base)
                 throws RDFException
RDFException


Copyright © 2001 Hewlett-Packard. All Rights Reserved.