Class RdfRepresentation


  • public class RdfRepresentation
    extends WriterRepresentation
    Generic RDF representation. Provides support for the Resource Description Framework (RDF) Semantic Web standard. It supports major RDF serialization formats (n3, Turtle, N-Triples and RDF/XML) and is able to both serialize and deserialize a Graph.
    • Field Detail

      • graph

        private Graph graph
        The inner graph of links.
      • rdfRepresentation

        private Representation rdfRepresentation
        The inner RDF representation.
    • Constructor Detail

      • RdfRepresentation

        public RdfRepresentation()
        Constructor.
      • RdfRepresentation

        public RdfRepresentation​(Graph linkSet,
                                 MediaType mediaType)
        Constructor with argument.
        Parameters:
        linkSet - The graph of links.
        mediaType - The representation's mediaType.
      • RdfRepresentation

        public RdfRepresentation​(MediaType mediaType)
        Constructor with argument.
        Parameters:
        mediaType - The representation's mediaType.
      • RdfRepresentation

        public RdfRepresentation​(Representation rdfRepresentation)
                          throws java.io.IOException
        Constructor that parsed a given RDF representation into a link set.
        Parameters:
        rdfRepresentation - The RDF representation to parse.
        Throws:
        java.io.IOException
    • Method Detail

      • createBuilder

        public GraphHandler createBuilder​(Graph graph)
        Returns an instance of a graph handler used when parsing the inner RDF representation.
        Parameters:
        graph - The graph to build.
        Returns:
        An instance of a graph handler used when parsing the inner RDF representation.
      • createWriter

        public GraphHandler createWriter​(MediaType mediaType,
                                         java.io.Writer writer)
                                  throws java.io.IOException
        Returns an instance of a graph handler used when writing the inner set of links.
        Parameters:
        mediaType - The given media type of the parsed RDF representation.
        writer - The character writer to write to.
        Returns:
        An instance of a graph handler used when writing the inner set of links.
        Throws:
        java.io.IOException
      • discoverNamespaces

        private void discoverNamespaces​(Graph linkset,
                                        GraphHandler graphHandler)
        Updates the list of known namespaces for the given graph of links.
        Parameters:
        linkset - The given graph of links.
        GraphHandler - the graph handler.
      • discoverNamespaces

        private void discoverNamespaces​(Link link,
                                        GraphHandler graphHandler)
        Updates the list of known namespaces of the XML writer for the given link.
        Parameters:
        link - The given link.
        GraphHandler - the graph handler.
      • discoverNamespaces

        private void discoverNamespaces​(Reference reference,
                                        GraphHandler graphHandler)
        Updates the list of known namespaces of the XML writer for the given reference.
        Parameters:
        reference - The given reference.
        xmlWriter - the XML writer.
      • getGraph

        public Graph getGraph()
                       throws java.io.IOException
        Returns the graph of links.
        Returns:
        The graph of links.
        Throws:
        java.io.IOException
      • parse

        public void parse​(GraphHandler graphHandler)
                   throws java.io.IOException
        Parses the inner RDF representation. The given graph handler is invoked each time a link is detected.
        Parameters:
        graphHandler - The graph handler.
        Throws:
        java.io.IOException
      • setGraph

        public void setGraph​(Graph linkSet)
        Sets the graph of links.
        Parameters:
        linkSet - The graph of links.
      • write

        public void write​(GraphHandler graphHandler)
                   throws java.io.IOException
        Writes the
        Parameters:
        graphHandler -
        Throws:
        java.io.IOException
      • write

        public void write​(java.io.Writer writer)
                   throws java.io.IOException
        Description copied from class: Representation
        Writes the representation to a characters writer. This method is ensured to write the full content for each invocation unless it is a transient representation, in which case an exception is thrown.

        Note that the class implementing this method shouldn't flush or close the given Writer after writing to it as this will be handled by the Restlet connectors automatically.
        Specified by:
        write in class Representation
        Parameters:
        writer - The characters writer.
        Throws:
        java.io.IOException