Package org.restlet.ext.rdf
Class RdfRepresentation
- java.lang.Object
-
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 aGraph.
-
-
Field Summary
Fields Modifier and Type Field Description private GraphgraphThe inner graph of links.private RepresentationrdfRepresentationThe inner RDF representation.-
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
-
-
Constructor Summary
Constructors Constructor Description RdfRepresentation()Constructor.RdfRepresentation(MediaType mediaType)Constructor with argument.RdfRepresentation(Graph linkSet, MediaType mediaType)Constructor with argument.RdfRepresentation(Representation rdfRepresentation)Constructor that parsed a given RDF representation into a link set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphHandlercreateBuilder(Graph graph)Returns an instance of a graph handler used when parsing the inner RDF representation.GraphHandlercreateWriter(MediaType mediaType, java.io.Writer writer)Returns an instance of a graph handler used when writing the inner set of links.private voiddiscoverNamespaces(Reference reference, GraphHandler graphHandler)Updates the list of known namespaces of the XML writer for the given reference.private voiddiscoverNamespaces(Graph linkset, GraphHandler graphHandler)Updates the list of known namespaces for the given graph of links.private voiddiscoverNamespaces(Link link, GraphHandler graphHandler)Updates the list of known namespaces of the XML writer for the given link.GraphgetGraph()Returns the graph of links.voidparse(GraphHandler graphHandler)Parses the inner RDF representation.voidsetGraph(Graph linkSet)Sets the graph of links.voidwrite(java.io.Writer writer)Writes the representation to a characters writer.voidwrite(GraphHandler graphHandler)Writes the-
Methods inherited from class org.restlet.representation.WriterRepresentation
getReader
-
Methods inherited from class org.restlet.representation.CharacterRepresentation
getChannel, getStream, write, write
-
Methods inherited from class org.restlet.representation.Representation
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getSize, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
-
Methods inherited from class org.restlet.representation.RepresentationInfo
getModificationDate, getTag, setModificationDate, setTag
-
Methods inherited from class org.restlet.representation.Variant
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
-
-
-
-
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.IOExceptionDescription copied from class:RepresentationWrites 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 givenWriterafter writing to it as this will be handled by the Restlet connectors automatically.- Specified by:
writein classRepresentation- Parameters:
writer- The characters writer.- Throws:
java.io.IOException
-
-