org.gcube.data.tmf.impl
Class AbstractReader

java.lang.Object
  extended by org.gcube.data.tmf.impl.AbstractReader
All Implemented Interfaces:
Serializable, SourceReader

public abstract class AbstractReader
extends Object
implements SourceReader

Partial implementation of SourceReader.

Plugins that extend this class need only to implement SourceReader.get(String, Pattern) and SourceReader.get(Pattern), as the implementation of the other methods are derived from these methods.

Note that the derived implementations are inefficient in principle if the data source supports more direct implementations. In this case, plugins can override derived implementations selectively.

Author:
Fabio Simeoni
See Also:
SourceReader, Serialized Form

Constructor Summary
AbstractReader()
           
 
Method Summary
 org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> get(org.gcube.data.streams.Stream<String> stream, org.gcube.data.trees.patterns.Pattern pattern)
          Default implementation of SourceReader.get(Stream, Pattern) based on repeated delegation to SourceReader.get(String,Pattern).
 org.gcube.data.trees.data.Node getNode(String... path)
          Default implementation of SourceReader#getNodes(RemoteIterator) based on delegation to SourceReader.get(String,Pattern).
 org.gcube.data.streams.Stream<org.gcube.data.trees.data.Node> getNodes(org.gcube.data.streams.Stream<org.gcube.data.tm.stubs.Path> stream)
          Default implementation of SourceReader.getNodes(Stream) based on repeated delegation to SourceReader.getNode(String...).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gcube.data.tmf.api.SourceReader
get, get
 

Constructor Detail

AbstractReader

public AbstractReader()
Method Detail

get

public org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> get(org.gcube.data.streams.Stream<String> stream,
                                                                         org.gcube.data.trees.patterns.Pattern pattern)
                                                                  throws UnsupportedOperationException,
                                                                         org.gcube.data.tml.exceptions.UnknownTreeException,
                                                                         org.gcube.data.tml.exceptions.InvalidTreeException,
                                                                         Exception
Default implementation of SourceReader.get(Stream, Pattern) based on repeated delegation to SourceReader.get(String,Pattern).

It should be inherited only if the source does not not support stream-based tree retrieval.

Specified by:
get in interface SourceReader
Parameters:
stream - a stream of tree identifiers
pattern - the pattern
Returns:
a stream over the pruned trees, relatively ordered as their identifiers
Throws:
UnsupportedOperationException - if the data source does not support this operation
Exception - if the operation fails for an unexpected error
org.gcube.data.tml.exceptions.UnknownTreeException
org.gcube.data.tml.exceptions.InvalidTreeException
See Also:
SourceReader.get(Stream, Pattern)

getNode

public org.gcube.data.trees.data.Node getNode(String... path)
                                       throws UnsupportedOperationException,
                                              org.gcube.data.tml.exceptions.UnknownPathException,
                                              Exception
Default implementation of SourceReader#getNodes(RemoteIterator) based on delegation to SourceReader.get(String,Pattern).

It should be inherited only if the source does not support node retrieval

Specified by:
getNode in interface SourceReader
Parameters:
path - the identifiers
Returns:
the node
Throws:
UnsupportedOperationException - if the data source does not support this operation
org.gcube.data.tml.exceptions.UnknownPathException - if the path does not lead to a node
org.gcube.common.clients.exceptions.UnsupportedRequestException - if the data source does not support this request
Exception - if the operation fails for any other error
See Also:
SourceReader#getNodes(RemoteIterator)

getNodes

public org.gcube.data.streams.Stream<org.gcube.data.trees.data.Node> getNodes(org.gcube.data.streams.Stream<org.gcube.data.tm.stubs.Path> stream)
                                                                       throws UnsupportedOperationException,
                                                                              Exception
Default implementation of SourceReader.getNodes(Stream) based on repeated delegation to SourceReader.getNode(String...).

It should be inherited only if the source does not support stream-based node retrieval

Specified by:
getNodes in interface SourceReader
Parameters:
stream - a stream of paths to the nodes
Returns:
a stream of tree nodes, relatively ordered as the corresponding paths
Throws:
UnsupportedOperationException - if the data source does not support this operation
org.gcube.common.clients.exceptions.UnsupportedRequestException - if the data source does not support this request
Exception - if the operation fails for an unexpected error
See Also:
SourceReader.getNodes(Stream)


Copyright © 2012. All Rights Reserved.