Class RdfXmlWriter


  • public class RdfXmlWriter
    extends GraphHandler
    Handler of RDF content according to the RDF XML syntax.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Reference lastSource
      The last source reference written, to try to factor statements.
      private java.lang.String RDF_SYNTAX
      URI of the RDF SYNTAX namespace.
      private XmlWriter writer
      XML writer.
    • Constructor Summary

      Constructors 
      Constructor Description
      RdfXmlWriter​(java.io.Writer writer)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void endGraph()
      Callback method used after the graph is parsed or written.
      private java.lang.String getNamespace​(Reference reference)
      Returns the namespace of the given reference.
      private java.lang.String getPrefix​(Reference ref)
      Returns the prefix of the qualified name representing the given reference.
      void link​(Reference source, Reference typeRef, Reference target)
      Callback method used when a link is parsed or written.
      void link​(Reference source, Reference typeRef, Literal target)
      Callback method used when a link is parsed or written.
      void link​(Graph source, Reference typeRef, Reference target)
      Callback method used when a link is parsed or written.
      void link​(Graph source, Reference typeRef, Literal target)
      Callback method used when a link is parsed or written.
      void startGraph()
      Callback method used before the graph is parsed or written.
      void startPrefixMapping​(java.lang.String prefix, Reference reference)
      Callback method used at the start of a Namespace mapping.
      private void writeNode​(Reference reference, boolean subject)
      Writes a subject or object node.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lastSource

        private Reference lastSource
        The last source reference written, to try to factor statements.
      • RDF_SYNTAX

        private final java.lang.String RDF_SYNTAX
        URI of the RDF SYNTAX namespace.
      • writer

        private XmlWriter writer
        XML writer.
    • Constructor Detail

      • RdfXmlWriter

        public RdfXmlWriter​(java.io.Writer writer)
                     throws java.io.UnsupportedEncodingException
        Constructor.
        Parameters:
        writer - The character writer.
        Throws:
        java.io.UnsupportedEncodingException
    • Method Detail

      • endGraph

        public void endGraph()
                      throws java.io.IOException
        Description copied from class: GraphHandler
        Callback method used after the graph is parsed or written. Does nothing by default.
        Overrides:
        endGraph in class GraphHandler
        Throws:
        java.io.IOException
      • getNamespace

        private java.lang.String getNamespace​(Reference reference)
        Returns the namespace of the given reference.
        Parameters:
        reference - the given reference.
        Returns:
        The namespace of the given reference.
      • getPrefix

        private java.lang.String getPrefix​(Reference ref)
        Returns the prefix of the qualified name representing the given reference.
        Parameters:
        ref - the given reference.
        Returns:
        The prefix of the qualified name representing the given reference. Context .getCurrentLogger() .warning( "Cannot write the end of the graph" + e.getMessage());
      • link

        public void link​(Graph source,
                         Reference typeRef,
                         Literal target)
        Description copied from class: GraphHandler
        Callback method used when a link is parsed or written.
        Specified by:
        link in class GraphHandler
        Parameters:
        source - The source or subject of the link.
        typeRef - The type reference of the link.
        target - The target or object of the link.
      • link

        public void link​(Graph source,
                         Reference typeRef,
                         Reference target)
        Description copied from class: GraphHandler
        Callback method used when a link is parsed or written.
        Specified by:
        link in class GraphHandler
        Parameters:
        source - The source or subject of the link.
        typeRef - The type reference of the link.
        target - The target or object of the link.
      • link

        public void link​(Reference source,
                         Reference typeRef,
                         Literal target)
        Description copied from class: GraphHandler
        Callback method used when a link is parsed or written.
        Specified by:
        link in class GraphHandler
        Parameters:
        source - The source or subject of the link.
        typeRef - The type reference of the link.
        target - The target or object of the link.
      • link

        public void link​(Reference source,
                         Reference typeRef,
                         Reference target)
        Description copied from class: GraphHandler
        Callback method used when a link is parsed or written.
        Specified by:
        link in class GraphHandler
        Parameters:
        source - The source or subject of the link.
        typeRef - The type reference of the link.
        target - The target or object of the link.
      • startGraph

        public void startGraph()
                        throws java.io.IOException
        Description copied from class: GraphHandler
        Callback method used before the graph is parsed or written. Does nothing by default.
        Overrides:
        startGraph in class GraphHandler
        Throws:
        java.io.IOException
      • startPrefixMapping

        public void startPrefixMapping​(java.lang.String prefix,
                                       Reference reference)
        Description copied from class: GraphHandler
        Callback method used at the start of a Namespace mapping. Does nothing by default.
        Overrides:
        startPrefixMapping in class GraphHandler
        Parameters:
        prefix - The Namespace prefix being declared.
        reference - The Namespace URI mapped to the prefix.
      • writeNode

        private void writeNode​(Reference reference,
                               boolean subject)
                        throws org.xml.sax.SAXException
        Writes a subject or object node.
        Parameters:
        ref - The reference of the subject or object node.
        subject - True if the node is the subject of a predicate
        Throws:
        org.xml.sax.SAXException