org.gcube.data.tmf.impl
Class AbstractWriter

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

public abstract class AbstractWriter
extends Object
implements SourceWriter

Partial implementation of SourceWriter.

Plugins that extend this class need only to implement SourceWriter.add(Tree) and SourceWriter.update(Tree), as the implementation of the stream-based methods can be derived from these methods.

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

Author:
Fabio Simeoni
See Also:
SourceWriter, Serialized Form

Constructor Summary
AbstractWriter()
           
 
Method Summary
 org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> add(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> stream)
          Default implementation of SourceWriter.add(Stream) based on repeated delegation to SourceWriter.add(Tree).
 org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> update(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> deltaStream)
          Default implementation of SourceWriter.update(Stream) based on repeated delegation to SourceWriter.update(Tree).
 
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.SourceWriter
add, update
 

Constructor Detail

AbstractWriter

public AbstractWriter()
Method Detail

add

public org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> add(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> stream)
                                                                  throws UnsupportedOperationException,
                                                                         Exception
Default implementation of SourceWriter.add(Stream) based on repeated delegation to SourceWriter.add(Tree).

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

Specified by:
add in interface SourceWriter
Parameters:
stream - the stream of trees
Returns:
a stream with the outcomes of adding the input trees. Successful outcomes are trees; if not otherwise documented for this plugin, these are the input trees with modifications made at the point of addition if any. Unsuccessful outcomes are failures and will be raised as the stream is consumed.
Throws:
UnsupportedOperationException - if the data source does not support this operation
UnsupportedRequestException - if the data source does not support this request
Exception - if the operation fails as a whole for an unexpected error
See Also:
SourceWriter.add(Stream)

update

public org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> update(org.gcube.data.streams.Stream<org.gcube.data.trees.data.Tree> deltaStream)
                                                                     throws UnsupportedOperationException,
                                                                            Exception
Default implementation of SourceWriter.update(Stream) based on repeated delegation to SourceWriter.update(Tree).

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

Specified by:
update in interface SourceWriter
Parameters:
deltaStream - the delta trees
Returns:
a stream with the outcomes of updating the input trees. Successful outcomes are trees; if not otherwise documented for this plugin, these are the input trees with modifications made at the point of addition if any. Unsuccessful outcomes are failures and will be raised as the stream is consumed.
Throws:
UnsupportedOperationException - if the data source does not support this operation
UnsupportedRequestException - if the data source does not support this request
Exception - if the operation fails as a whole for an expected error
See Also:
SourceWriter.update(Stream)


Copyright © 2013. All Rights Reserved.