org.qi4j.io

## Class Transforms

- java.lang.Object
- - org.qi4j.io.Transforms

-     public class Transforms
      extends Object

  Utility class for I/O transforms

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Transforms.ByteBuffer2String` Convert ByteBuffers to Strings using the given CharSet
    `static class` | `Transforms.Counter<T>` Count the number of items in the transfer.
    `static class` | `Transforms.Log<T>` Log the toString() representation of transferred items to the given log.
    `static class` | `Transforms.ObjectToString` Convert objects to Strings using .toString()
    `static class` | `Transforms.ProgressLog<T>` Track progress of transfer by emitting a log message in given intervals.
    `static class` | `Transforms.String2Bytes` Convert strings to bytes using the given CharSet

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Transforms()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T,Receiver2ThrowableType extends Throwable> Output<T,Receiver2ThrowableType>` | `filter(Specification<? super T> specification, Output<T,Receiver2ThrowableType> output)` Filter items in a transfer by applying the given Specification to each item.
    `static <T,Receiver2ThrowableType extends Throwable> Output<T,Receiver2ThrowableType>` | `filteredMap(Specification<? super T> specification, Function<? super T,? extends T> function, Output<T,Receiver2ThrowableType> output)` Apply the given function to items in the transfer that match the given specification.
    `static <T,SenderThrowableType extends Throwable> Input<T,SenderThrowableType>` | `lock(Lock lock, Input<T,SenderThrowableType> input)` Wrapper for Outputs that uses a lock whenever a transfer is instantiated.
    `static <T,Receiver2ThrowableType extends Throwable> Output<T,Receiver2ThrowableType>` | `lock(Lock lock, Output<T,Receiver2ThrowableType> output)` Wrapper for Outputs that uses a lock whenever a transfer is instantiated.
    `static <From,To,Receiver2ThrowableType extends Throwable> Output<From,Receiver2ThrowableType>` | `map(Function<? super From,? extends To> function, Output<To,Receiver2ThrowableType> output)` Map items in a transfer from one type to another by applying the given function.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Transforms

          public Transforms()

  - ### Method Detail

    - #### filter

          public static <T,Receiver2ThrowableType extends Throwable> Output<T,Receiver2ThrowableType> filter(Specification<? super T> specification,
                                                                                             Output<T,Receiver2ThrowableType> output)

      Filter items in a transfer by applying the given Specification to each item.
      Type Parameters:
        `T` - The item type
        `Receiver2ThrowableType` - Exception type that might be thrown by the Receiver.
      Parameters:
        `specification` - The Specification defining the items to not filter away.
        `output` - The Output instance to receive to result.
      Returns:
        And Output encapsulation the filter operation.

    - #### map

          public static <From,To,Receiver2ThrowableType extends Throwable> Output<From,Receiver2ThrowableType> map(Function<? super From,? extends To> function,
                                                                                                   Output<To,Receiver2ThrowableType> output)

      Map items in a transfer from one type to another by applying the given function.
      Type Parameters:
        `From` - The type of the incoming items.
        `To` - The type of the transformed items.
        `Receiver2ThrowableType` - The exception type that the Receiver might throw.
      Parameters:
        `function` - The transformation function to apply to the streaming items.
        `output` - The output to receive the transformed items.
      Returns:
        An Output instance that encapsulates the map transformation.

    - #### filteredMap

          public static <T,Receiver2ThrowableType extends Throwable> Output<T,Receiver2ThrowableType> filteredMap(Specification<? super T> specification,
                                                                                                  Function<? super T,? extends T> function,
                                                                                                  Output<T,Receiver2ThrowableType> output)

      Apply the given function to items in the transfer that match the given specification. Other items will pass through directly.
      Type Parameters:
        `T` - The item type. Items can not be transformed to a new type.
        `Receiver2ThrowableType` - The exception that the Receiver might throw.
      Parameters:
        `specification` - The Specification defining which items should be transformed.
        `function` - The transformation function.
        `output` - The Output that will receive the resulting items.
      Returns:
        An Output instance that encapsulates the operation.

    - #### lock

          public static <T,Receiver2ThrowableType extends Throwable> Output<T,Receiver2ThrowableType> lock(Lock lock,
                                                                                           Output<T,Receiver2ThrowableType> output)

      Wrapper for Outputs that uses a lock whenever a transfer is instantiated. Typically a read-lock would be used on the sending side and a write-lock would be used on the receiving side. Inputs can use this as well to create a wrapper on the send side when transferTo is invoked.
      Type Parameters:
        `T` - The Item type
        `Receiver2ThrowableType` - The Exception type that the Receiver might throw.
      Parameters:
        `lock` - the lock to be used for transfers
        `output` - output to be wrapped
      Returns:
        Output wrapper that uses the given lock during transfers.

    - #### lock

          public static <T,SenderThrowableType extends Throwable> Input<T,SenderThrowableType> lock(Lock lock,
                                                                                    Input<T,SenderThrowableType> input)

      Wrapper for Outputs that uses a lock whenever a transfer is instantiated. Typically a read-lock would be used on the sending side and a write-lock would be used on the receiving side.
      Type Parameters:
        `T` - The item type.
        `SenderThrowableType` - The Exception type that the Sender might throw.
      Parameters:
        `lock` - the lock to be used for transfers
        `input` - input to be wrapped
      Returns:
        Input wrapper that uses the given lock during transfers.