org.gcube.contentmanagement.gcubedocumentlibrary.streams.dsl
Class Streams

java.lang.Object
  extended by org.gcube.contentmanagement.gcubedocumentlibrary.streams.dsl.Streams

public class Streams
extends java.lang.Object

An embedded language for manipulation of streams based on Iterators, RemoteIterators, and result sets.

Author:
Fabio Simeoni (University of Strathclyde)

Field Summary
static boolean CONTINUE
          An alias for true to improve legibility of fault handling policies.
static IFaultPolicy<java.lang.RuntimeException> FAILFAST_POLICY
          The IFaultPolicy that fails at iteration errors.
static IFaultPolicy<java.lang.RuntimeException> IGNORE_POLICY
          The IFaultPolicy that ignores iteration errors.
static  PASSTHROUGH_PARSER
           
static IFaultPolicy<java.lang.Exception> RETHROW_POLICY
          The IFaultPolicy that propagates iteration errors.
static boolean STOP
          An alias for false to improve legibility of fault handling policies.
static  URI_PARSER
           
 
Constructor Summary
Streams()
           
 
Method Summary
static  alternativesIn( docs)
          Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeAlternatives.
static java.util.Iterator<GCubeAlternative> alternativesIn(java.util.Iterator<GCubeDocument> docs)
          Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeAlternatives.
static  alternativesIn(java.net.URI locator)
          Converts a result set of into a RemoteIterator over GCubeAlternative.
static  annotationsIn( docs)
          Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeAnnotations.
static java.util.Iterator<GCubeAnnotation> annotationsIn(java.util.Iterator<GCubeDocument> docs)
          Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeAnnotations.
static  annotationsIn(java.net.URI locator)
          Converts a result set of into a RemoteIterator over GCubeAnnotation.
static
<T> WithLocalClause<T,T>
convert( rit)
          Converts a RemoteIterator into an Iterator using the IGNORE_POLICY for faults.
static
<T>
convert(java.util.Iterator<T> it)
          Converts an Iterator in a RemoteIterator.
static  documentsIn( it)
          Converts a RemoteIterator over strings into a RemoteIterator over GCubeDocuments.
static  documentsIn(java.net.URI locator)
          Converts a result set of into a RemoteIterator over GCubeDocuments.
static
<FROM> InClause<FROM>
group( rit)
          group clause for an RemoteIterator.
static
<FROM> InClause<FROM>
group(java.util.Iterator<FROM> it)
          group clause for an Iterator.
static  metadataIn( docs)
          Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeMetadatas.
static java.util.Iterator<GCubeMetadata> metadataIn(java.util.Iterator<GCubeDocument> docs)
          Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeMetadatas.
static  metadataIn(java.net.URI locator)
          Converts a result set of into a RemoteIterator over GCubeMetadata.
static  partsIn( docs)
          Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeParts.
static java.util.Iterator<GCubePart> partsIn(java.util.Iterator<GCubeDocument> docs)
          Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeParts.
static  partsIn(java.net.URI locator)
          Converts a result set of into a RemoteIterator over GCubePart.
static  payloadsIn(java.net.URI locator)
          Converts a result set into a RemoteIterator.
static
<FROM> ThroughClause<FROM>
pipe( rit)
          pipe clause for an RemoteIterator.
static
<FROM> ThroughClause<FROM>
pipe(java.util.Iterator<FROM> it)
          pipe clause for an Iterator.
static
<FROM> UnfoldThroughClause<FROM>
unfold( rit)
          unfold clause for an RemoteIterator.
static
<FROM> UnfoldThroughClause<FROM>
unfold(java.util.Iterator<FROM> it)
          unfold clause for an Iterator.
static  urisIn(java.net.URI locator, int timeout)
          Converts a result set into a RemoteIterator of URIs.
static
<E extends GCubeElement>
WithClause<E,java.net.URI>
urisOf( iterator)
          Converts an RemoteIterator of GCubeElements into a WithClause with which clients can generate Iterators or RemoteIterators over the elements' URIs.
static
<E extends GCubeElement>
WithClause<E,java.net.URI>
urisOf(java.util.Iterator<E> iterator)
          Converts an Iterator of GCubeElements into a WithClause with which clients can generate Iterators or RemoteIterators over the elements' URIs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IGNORE_POLICY

public static final IFaultPolicy<java.lang.RuntimeException> IGNORE_POLICY
The IFaultPolicy that ignores iteration errors.


FAILFAST_POLICY

public static final IFaultPolicy<java.lang.RuntimeException> FAILFAST_POLICY
The IFaultPolicy that fails at iteration errors.


RETHROW_POLICY

public static final IFaultPolicy<java.lang.Exception> RETHROW_POLICY
The IFaultPolicy that propagates iteration errors.


CONTINUE

public static boolean CONTINUE
An alias for true to improve legibility of fault handling policies.


STOP

public static boolean STOP
An alias for false to improve legibility of fault handling policies.


PASSTHROUGH_PARSER

public static  PASSTHROUGH_PARSER

URI_PARSER

public static  URI_PARSER
Constructor Detail

Streams

public Streams()
Method Detail

payloadsIn

public static  payloadsIn(java.net.URI locator)
                        throws java.lang.Exception
Converts a result set into a RemoteIterator.

Parameters:
locator - the result set locator.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

urisIn

public static  urisIn(java.net.URI locator,
                           int timeout)
                    throws java.lang.Exception
Converts a result set into a RemoteIterator of URIs.

Parameters:
locator - the result set locator.
timeout - the read timeout, in seconds.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

urisOf

public static <E extends GCubeElement> WithClause<E,java.net.URI> urisOf(java.util.Iterator<E> iterator)
Converts an Iterator of GCubeElements into a WithClause with which clients can generate Iterators or RemoteIterators over the elements' URIs.

Parameters:
locator - the element iterator.
Returns:
the WithClause.

urisOf

public static <E extends GCubeElement> WithClause<E,java.net.URI> urisOf( iterator)
Converts an RemoteIterator of GCubeElements into a WithClause with which clients can generate Iterators or RemoteIterators over the elements' URIs.

Parameters:
locator - the element iterator.
Returns:
the WithClause.

documentsIn

public static  documentsIn(java.net.URI locator)
                         throws java.lang.Exception
Converts a result set of into a RemoteIterator over GCubeDocuments.

Parameters:
locator - the result set locator.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

documentsIn

public static  documentsIn( it)
                         throws java.lang.Exception
Converts a RemoteIterator over strings into a RemoteIterator over GCubeDocuments.

Parameters:
locator - the iterator over strings.
Returns:
the iterator over GCubeDocuments.
Throws:
java.lang.Exception - if the conversion failed.

metadataIn

public static  metadataIn(java.net.URI locator)
                        throws java.lang.Exception
Converts a result set of into a RemoteIterator over GCubeMetadata.

Parameters:
locator - the result set locator.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

metadataIn

public static  metadataIn( docs)
                        throws java.lang.Exception
Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeMetadatas.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeMetadatas.
Throws:
java.lang.Exception - if the conversion failed.

metadataIn

public static java.util.Iterator<GCubeMetadata> metadataIn(java.util.Iterator<GCubeDocument> docs)
                                                    throws java.lang.Exception
Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeMetadatas.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeMetadatas.
Throws:
java.lang.Exception - if the conversion failed.

annotationsIn

public static  annotationsIn(java.net.URI locator)
                           throws java.lang.Exception
Converts a result set of into a RemoteIterator over GCubeAnnotation.

Parameters:
locator - the result set locator.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

annotationsIn

public static  annotationsIn( docs)
                           throws java.lang.Exception
Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeAnnotations.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeAnnotations.
Throws:
java.lang.Exception - if the conversion failed.

annotationsIn

public static java.util.Iterator<GCubeAnnotation> annotationsIn(java.util.Iterator<GCubeDocument> docs)
                                                         throws java.lang.Exception
Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeAnnotations.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeAnnotations.
Throws:
java.lang.Exception - if the conversion failed.

alternativesIn

public static  alternativesIn(java.net.URI locator)
                            throws java.lang.Exception
Converts a result set of into a RemoteIterator over GCubeAlternative.

Parameters:
locator - the result set locator.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

alternativesIn

public static  alternativesIn( docs)
                            throws java.lang.Exception
Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeAlternatives.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeAlternatives.
Throws:
java.lang.Exception - if the conversion failed.

alternativesIn

public static java.util.Iterator<GCubeAlternative> alternativesIn(java.util.Iterator<GCubeDocument> docs)
                                                           throws java.lang.Exception
Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeAlternatives.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeAlternatives.
Throws:
java.lang.Exception - if the conversion failed.

partsIn

public static  partsIn(java.net.URI locator)
                     throws java.lang.Exception
Converts a result set of into a RemoteIterator over GCubePart.

Parameters:
locator - the result set locator.
Returns:
the iterator.
Throws:
java.lang.Exception - if the conversion failed.

partsIn

public static  partsIn( docs)
                     throws java.lang.Exception
Converts a RemoteIterator over GCubeDocuments into a RemoteIterator over GCubeParts.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeParts.
Throws:
java.lang.Exception - if the conversion failed.

partsIn

public static java.util.Iterator<GCubePart> partsIn(java.util.Iterator<GCubeDocument> docs)
                                             throws java.lang.Exception
Converts a standard Iterator over GCubeDocuments into a standard Iterator over GCubeParts.

Parameters:
locator - the iterator over GCubeDocuments.
Returns:
the iterator over GCubeParts.
Throws:
java.lang.Exception - if the conversion failed.

pipe

public static <FROM> ThroughClause<FROM> pipe(java.util.Iterator<FROM> it)
pipe clause for an Iterator.

Type Parameters:
FROM - the type of the objects iterated over.
Parameters:
it - the iterator.
Returns:
the next clause.

pipe

public static <FROM> ThroughClause<FROM> pipe( rit)
pipe clause for an RemoteIterator.

Type Parameters:
FROM - the type of the objects iterated over.
Parameters:
it - the iterator.
Returns:
the next clause.

group

public static <FROM> InClause<FROM> group(java.util.Iterator<FROM> it)
group clause for an Iterator.

Type Parameters:
FROM - the type of the objects iterated over.
Parameters:
it - the iterator.
Returns:
the next clause.

group

public static <FROM> InClause<FROM> group( rit)
group clause for an RemoteIterator.

Type Parameters:
FROM - the type of the objects iterated over.
Parameters:
it - the iterator.
Returns:
the next clause.

unfold

public static <FROM> UnfoldThroughClause<FROM> unfold(java.util.Iterator<FROM> it)
unfold clause for an Iterator.

Type Parameters:
FROM - the type of the objects iterated over.
Parameters:
it - the iterator.
Returns:
the next clause.

unfold

public static <FROM> UnfoldThroughClause<FROM> unfold( rit)
unfold clause for an RemoteIterator.

Type Parameters:
FROM - the type of the objects iterated over.
Parameters:
it - the iterator.
Returns:
the next clause.

convert

public static <T> WithLocalClause<T,T> convert( rit)
Converts a RemoteIterator into an Iterator using the IGNORE_POLICY for faults.

Type Parameters:
T - the type of the iterators.
Parameters:
rit - the RemoteIterator.
Returns:
the Iterator.

convert

public static <T>  convert(java.util.Iterator<T> it)
Converts an Iterator in a RemoteIterator.

Type Parameters:
T - the type of the iterators.
Parameters:
it - the Iterator.
Returns:
the RemoteIterator.