org.gcube.data.streams.dsl
Class Streams

java.lang.Object
  extended by org.gcube.data.streams.dsl.Streams

public class Streams
extends Object

The definitions of an eDSL of stream and stream-related expressions.

Author:
Fabio Simeoni

Field Summary
static FaultHandler IGNORE_POLICY
          A IgnoreHandler for failure handling.
static NoOpGenerator<String> no_serialiser
          A NoOpGenerator.
static FaultHandler RETHROW_POLICY
          A RethrowHandler for failure handling.
static FaultHandler RETHROW_UNRECOVERABLE_POLICY
          A RethrowUnrecoverableHandler for failure handling.
static FaultHandler STOPFAST_POLICY
          A StopFastHandler for failure handling.
 
Constructor Summary
Streams()
           
 
Method Summary
static
<E> ConsumeWithClause<E>
consume(Stream<E> stream)
          Starts a sentence to consume a Stream
static
<E> Stream<E>
convert(E... elements)
          Converts one or more elements into a Stream.
static
<E> Stream<E>
convert(Iterable<E> iterable)
          Converts an Iterable to a Stream.
static
<E> Stream<E>
convert(Iterator<E> itarator)
          Converts an Iterator to a Stream.
static
<E> IteratorStream<E>
convert(IteratorAdapter<E> adapter)
          Converts a custom IteratorAdapter to a Stream.
static RsOfClause<gr.uoa.di.madgik.grs.record.Record> convert(URI locator)
          Starts a sentence to convert a resultset into a Stream.
static
<E> Stream<E>
convertWithFaults(Class<E> clazz, List<? extends Object> elements)
          Converts a mixture of exceptions and elements of a given type to a Stream of a that type.
static
<E> Stream<E>
convertWithFaults(Class<E> clazz, Object... elements)
          Converts a mixture of exceptions and elements of a given type to a Stream of a that type.
static
<E> InClause<E>
fold(Stream<E> stream)
          Starts a sentence to produce a Stream that groups of elements of another Stream.
static
<E> GuardWithClause<E>
guard(Stream<E> stream)
          Starts a sentence to produce a Stream that controls the error raised by another Stream.
static
<E> Stream<E>
log(Stream<E> stream)
          Returns a Stream that logs the throughput of an input Stream.
static
<E> MonitorWithClause<E>
monitor(Stream<E> stream)
          Starts a sentence to produce a Stream that notifies key events in the iteration of another Stream.
static
<E> NoOpGenerator<E>
no_op(Stream<E> stream)
          Returns a NoOpGenerator.
static
<E> PipeThroughClause<E>
pipe(Stream<E> stream)
          Starts a sentence to produce a Stream generated from another Stream.
static
<E> PublishRsUsingClause<E>
publish(Stream<E> stream)
          Starts a sentence to publish a Stream as a resultset.
static PublishRsWithClause<String> publishStringsIn(Stream<String> stream)
          Starts a sentence to publish a Stream as a resultset.
static Stream<String> stringsIn(URI locator)
          Returns a Stream of strings extracted from a resultset of RsStringRecordFactory.STRING_RECORDs.
static
<E> UnfoldThroughClause<E>
unfold(Stream<E> stream)
          Starts a sentence to produce a Stream that unfolds the elements of another Stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

no_serialiser

public static NoOpGenerator<String> no_serialiser
A NoOpGenerator.


RETHROW_POLICY

public static FaultHandler RETHROW_POLICY
A RethrowHandler for failure handling.


RETHROW_UNRECOVERABLE_POLICY

public static FaultHandler RETHROW_UNRECOVERABLE_POLICY
A RethrowUnrecoverableHandler for failure handling.


STOPFAST_POLICY

public static FaultHandler STOPFAST_POLICY
A StopFastHandler for failure handling.


IGNORE_POLICY

public static FaultHandler IGNORE_POLICY
A IgnoreHandler for failure handling.

Constructor Detail

Streams

public Streams()
Method Detail

consume

public static <E> ConsumeWithClause<E> consume(Stream<E> stream)
Starts a sentence to consume a Stream

Parameters:
stream - the stream
Returns:
the next clause of the sentence

convert

public static <E> Stream<E> convert(Iterator<E> itarator)
Converts an Iterator to a Stream.

Parameters:
itarator - the iterator
Returns:
the stream

convert

public static <E> IteratorStream<E> convert(IteratorAdapter<E> adapter)
Converts a custom IteratorAdapter to a Stream.

Parameters:
adapter - the adapter
Returns:
the stream

convert

public static <E> Stream<E> convert(Iterable<E> iterable)
Converts an Iterable to a Stream.

Parameters:
iterable - the iterable
Returns:
the stream

convert

public static <E> Stream<E> convert(E... elements)
Converts one or more elements into a Stream.

Parameters:
elements - the elements
Returns:
the stream

convertWithFaults

public static <E> Stream<E> convertWithFaults(Class<E> clazz,
                                              Object... elements)
Converts a mixture of exceptions and elements of a given type to a Stream of a that type. It's the client's responsibility to ensure that the elements that are not exceptions are homogeneously typed as the type indicated in input.

Parameters:
clazz - the stream type
elements - the elements
Returns:
the stream

convertWithFaults

public static <E> Stream<E> convertWithFaults(Class<E> clazz,
                                              List<? extends Object> elements)
Converts a mixture of exceptions and elements of a given type to a Stream of a that type. It's the client's responsibility to ensure that the elements that are not exceptions are homogeneously typed as the type indicated in input.

Parameters:
clazz - the stream type
elements - the elements
Returns:
the stream

convert

public static RsOfClause<gr.uoa.di.madgik.grs.record.Record> convert(URI locator)
Starts a sentence to convert a resultset into a Stream.

Parameters:
locator - the locator of the resultset
Returns:
the next clause of the sentence

stringsIn

public static Stream<String> stringsIn(URI locator)
Returns a Stream of strings extracted from a resultset of RsStringRecordFactory.STRING_RECORDs.

Parameters:
locator - the locator of the resultset
Returns:
the stream

pipe

public static <E> PipeThroughClause<E> pipe(Stream<E> stream)
Starts a sentence to produce a Stream generated from another Stream.

Parameters:
stream - the input stream.
Returns:
the next clause of the sentence

fold

public static <E> InClause<E> fold(Stream<E> stream)
Starts a sentence to produce a Stream that groups of elements of another Stream.

Parameters:
stream - the input stream.
Returns:
the next clause of the sentence

unfold

public static <E> UnfoldThroughClause<E> unfold(Stream<E> stream)
Starts a sentence to produce a Stream that unfolds the elements of another Stream.

Parameters:
stream - the input stream.
Returns:
the next clause of the sentence

guard

public static <E> GuardWithClause<E> guard(Stream<E> stream)
Starts a sentence to produce a Stream that controls the error raised by another Stream.

Parameters:
stream - the input stream.
Returns:
the next clause of the sentence

monitor

public static <E> MonitorWithClause<E> monitor(Stream<E> stream)
Starts a sentence to produce a Stream that notifies key events in the iteration of another Stream.

Parameters:
stream - the input stream.
Returns:
the next clause of the sentence

publish

public static <E> PublishRsUsingClause<E> publish(Stream<E> stream)
Starts a sentence to publish a Stream as a resultset.

Parameters:
stream - the stream
Returns:
the next clause of the sentence

publishStringsIn

public static PublishRsWithClause<String> publishStringsIn(Stream<String> stream)
Starts a sentence to publish a Stream as a resultset.

Parameters:
stream - the stream
Returns:
the next clause of the sentence

log

public static <E> Stream<E> log(Stream<E> stream)
Returns a Stream that logs the throughput of an input Stream.

Parameters:
stream - the input stream
Returns:
the output stream

no_op

public static <E> NoOpGenerator<E> no_op(Stream<E> stream)
Returns a NoOpGenerator.

Returns:
the generator


Copyright © 2012. All Rights Reserved.