com.hp.hpl.mesa.rdf.jena.common.prettywriter
Class PrettyWriter
java.lang.Object
|
+--com.hp.hpl.mesa.rdf.jena.common.prettywriter.PrettyWriter
- All Implemented Interfaces:
- RDFErrorHandler, RDFWriter
- public class PrettyWriter
- extends java.lang.Object
- implements RDFWriter, RDFErrorHandler
Writes out RDF in the abbreviated syntax, for human consumption
not only machine readable.
It is not normal to call the constructor directly, but to use
the method RDFWriterF.getWriter("RDF/XML-ABBREV").
Does not support the NSPREFIXPROPBASE
system properties.
Use setNsPrefix
.
For best results it is necessary to set the property
"prettyTypes"
. See setProperty for information.
- Version:
- Release='$Name: $' Revision='$Revision: 1.4 $' Date='$Date: 2002/01/04 12:47:55 $'
- Author:
- jjc
- See Also:
RDFWriterF.getWriter()
Method Summary |
void |
error(java.lang.Exception e)
report an error |
void |
fatalError(java.lang.Exception e)
report a catastrophic error. |
static void |
main(java.lang.String[] args)
|
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)
Sets the types of the principal objects in the model. |
void |
warning(java.lang.Exception e)
report a warning |
void |
write(Model model,
java.io.Writer out,
java.lang.String base)
Serialize Model model to Writer out. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PrettyWriter
public PrettyWriter()
setErrorHandler
public RDFErrorHandler setErrorHandler(RDFErrorHandler errHandler)
- 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)
- Set the the namespace prefix to be used for a particular namespace.
- Specified by:
setNsPrefix
in interface RDFWriter
- Parameters:
prefix
- the prefix to be usedns
- the namespace
setProperty
public java.lang.Object setProperty(java.lang.String propName,
java.lang.Object propValue)
throws RDFException
- Sets the types of the principal objects in the model. PrettyWriter
will tend to create RDF/XML with resources of these types at the
top level.
Example usage showing the default value:
prettyWriter.setProperty("prettyTypes",new Resource[]{
DAML.Ontology,
DAML.Class,
DAML.Datatype,
DAML.Property,
DAML.ObjectProperty,
DAML.DatatypeProperty,
DAML.TransitiveProperty,
DAML.UnambigousProperty,
DAML.UniqueProperty,
});
- Specified by:
setProperty
in interface RDFWriter
- Parameters:
propName
- Must be "prettyTypes"propValue
- An array of Resource's being types of objects to show
at the top level.- Returns:
- the old value for this property, or
null
if no value was set.
write
public void write(Model model,
java.io.Writer out,
java.lang.String base)
throws RDFException
- Serialize Model
model
to Writer out.
- 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.
error
public void error(java.lang.Exception e)
- Description copied from interface:
RDFErrorHandler
- report an error
- Specified by:
error
in interface RDFErrorHandler
- Following copied from interface:
com.hp.hpl.mesa.rdf.jena.model.RDFErrorHandler
- Parameters:
e
- an exception representing the error
warning
public void warning(java.lang.Exception e)
- Description copied from interface:
RDFErrorHandler
- report a warning
- Specified by:
warning
in interface RDFErrorHandler
- Following copied from interface:
com.hp.hpl.mesa.rdf.jena.model.RDFErrorHandler
- Parameters:
e
- an exception representing the error
fatalError
public void fatalError(java.lang.Exception e)
- Description copied from interface:
RDFErrorHandler
- report a catastrophic error. Must not return.
- Specified by:
fatalError
in interface RDFErrorHandler
- Following copied from interface:
com.hp.hpl.mesa.rdf.jena.model.RDFErrorHandler
- Parameters:
e
- an exception representing the error- Throws:
RDFError
- a generic RDF exception
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
Copyright © 2001 Hewlett-Packard. All Rights Reserved.