org.apache.clerezza.rdf.core.serializedform
Class Parser

java.lang.Object
  extended by org.apache.clerezza.rdf.core.serializedform.Parser

public class Parser
extends Object

This singleton class provides a method parse to transform serialized RDF forms into Graphs. Functionality is delegated to registered ParsingProviders. Such ParsingProviders can be registered and unregistered, later registered ParsingProviders shadow previously registered providers for the same format. Note on synchronization: ParsingProviders must be able to handle concurrent requests.

Author:
reto

Constructor Summary
Parser()
          the constructor sets the singleton instance to allow instantiation by OSGi-DS.
 
Method Summary
 void bindParsingProvider(ParsingProvider provider)
          Registers a parsing provider
static Parser getInstance()
          This returns the singleton instance, if an instance has been previously created (e.g.
 Set<String> getSupportedFormats()
          Get a set of supported formats
 Graph parse(InputStream serializedGraph, String formatIdentifier)
          Parses a serialized Graph from an InputStream.
 Graph parse(InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
          Parses a serialized Graph from an InputStream.
 void parse(MGraph target, InputStream serializedGraph, String formatIdentifier)
          Parses a serialized Graph from an InputStream.
 void parse(MGraph target, InputStream serializedGraph, String formatIdentifier, UriRef baseUri)
          Parses a serialized Graph from an InputStream.
 void unbindParsingProvider(ParsingProvider provider)
          Unregister a parsing provider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser()
the constructor sets the singleton instance to allow instantiation by OSGi-DS. This constructor should not be called except by OSGi-DS, otherwise the static getInstance method should be used.

Method Detail

getInstance

public static Parser getInstance()
This returns the singleton instance, if an instance has been previously created (e.g. by OSGi declarative services) this instance is returned, otherwise a new instance is created and providers are injected using the service provider interface (META-INF/services/)

Returns:
the singleton Parser instance

parse

public Graph parse(InputStream serializedGraph,
                   String formatIdentifier)
            throws UnsupportedFormatException
Parses a serialized Graph from an InputStream. This delegates the processing to the provider registered for the specified format, if the formatIdentifier contains a ';'-character only the section before that character is used for choosing the provider.

Parameters:
serializedGraph - an inputstream with the serialization
formatIdentifier - a string identifying the format (usually the MIME-type)
Returns:
the graph read from the stream
Throws:
UnsupportedFormatException

parse

public void parse(MGraph target,
                  InputStream serializedGraph,
                  String formatIdentifier)
           throws UnsupportedFormatException
Parses a serialized Graph from an InputStream. This delegates the processing to the provider registered for the specified format, if the formatIdentifier contains a ';'-character only the section before that character is used for choosing the provider.

Parameters:
target - the MGraph to which the parsed triples are added
serializedGraph - an inputstream with the serialization
formatIdentifier - a string identifying the format (usually the MIME-type)
Throws:
UnsupportedFormatException

parse

public Graph parse(InputStream serializedGraph,
                   String formatIdentifier,
                   UriRef baseUri)
            throws UnsupportedFormatException
Parses a serialized Graph from an InputStream. This delegates the processing to the provider registered for the specified format, if the formatIdentifier contains a ';'-character only the section before that character is used for choosing the provider.

Parameters:
serializedGraph - an inputstream with the serialization
formatIdentifier - a string identifying the format (usually the MIME-type)
baseUri - the uri against which relative uri-refs are evaluated
Returns:
the graph read from the stream
Throws:
UnsupportedFormatException

parse

public void parse(MGraph target,
                  InputStream serializedGraph,
                  String formatIdentifier,
                  UriRef baseUri)
           throws UnsupportedFormatException
Parses a serialized Graph from an InputStream. This delegates the processing to the provider registered for the specified format, if the formatIdentifier contains a ';'-character only the section before that character is used for choosing the provider.

Parameters:
target - the MGraph to which the parsed triples are added
serializedGraph - an inputstream with the serialization
formatIdentifier - a string identifying the format (usually the MIME-type)
baseUri - the uri against which relative uri-refs are evaluated
Throws:
UnsupportedFormatException

getSupportedFormats

public Set<String> getSupportedFormats()
Get a set of supported formats

Returns:
a set if stings identifying formats (usually the MIME-type)

bindParsingProvider

public void bindParsingProvider(ParsingProvider provider)
Registers a parsing provider

Parameters:
provider - the provider to be registered

unbindParsingProvider

public void unbindParsingProvider(ParsingProvider provider)
Unregister a parsing provider

Parameters:
provider - the provider to be deregistered


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.