scalax.io.processing

CharProcessor

case class CharProcessor (base: CloseableIteratorProcessor[Char]) extends SpecificApiFactory[Char, CharProcessorAPI] with Product with Serializable

ProcessorAPI for processing char input sources

Linear Supertypes
Serializable, Serializable, Product, Equals, SpecificApiFactory[Char, CharProcessorAPI], Processor[CharProcessorAPI], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. CharProcessor
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. SpecificApiFactory
  7. Processor
  8. AnyRef
  9. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CharProcessor (base: CloseableIteratorProcessor[Char])

Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def acquireAndGet [U] (f: (CharProcessorAPI) ⇒ U): Option[U]

    Execute the process workflow represented by this Processor and pass the function the result, if the Processor is nonEmpty.

    Execute the process workflow represented by this Processor and pass the function the result, if the Processor is nonEmpty.

    returns

    the result of the function within a Some if this processor is Non-empty. Otherwise the function will not be executed and None will be returned

    Definition Classes
    Processor
  7. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  8. val base : CloseableIteratorProcessor[Char]

  9. def canEqual (arg0: Any): Boolean

    Definition Classes
    CharProcessor → Equals
  10. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. def context : ResourceContext

    Definition Classes
    SpecificApiFactoryProcessor
  12. def create (iter: CloseableIterator[Char]): CharProcessorAPI

    Factory method to create the actual API object

    Factory method to create the actual API object

    Attributes
    protected
    Definition Classes
    CharProcessorSpecificApiFactory
  13. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  14. def equals (arg0: Any): Boolean

    Definition Classes
    CharProcessor → Equals → AnyRef → Any
  15. def execute (): Unit

    Execute the Processor.

    Execute the Processor. If the result is an iterator then execute() will visit each element in the iterator to ensure that any processes mapped to that iterator will be executed.

    A typical situation where execute is useful is when the Processor is a side effect processor like a Processor created by an OpenOutput or OpenSeekable object. Both typically return Processor[Unit] processors which only perform side-effecting behaviours.

    Example:

    val process = for {
      outProcessor <- output.outputProcessor
      inProcessor <- file.asInput.blocks.processor
      _ <- inProcessor.repeatUntilEmpty()
      block <- inProcessor.next
      _ <- outProcessor.write(block)
    } yield ()
    
    // the copy has not yet occurred
    
    // will look through each element in the process (and sub-elements
    if the process contains a LongTraversable)
    process.execute()
    
    Definition Classes
    Processor
  16. def filter (f: (CharProcessorAPI) ⇒ Boolean): Processor[CharProcessorAPI]

    Apply a filter to this processor.

    Apply a filter to this processor. If the filter returns false then the resulting Processor will be empty. It is not possible to know if the Processor is empty unless acquireAndGet is called because the filter is not called until acquireOrGet is executed (or the Processor is somehow processed in another way like obtaining the LongTraversable and traversing that object).

    returns

    A new Processor with the filter applied.

    Definition Classes
    Processor
  17. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. def flatMap [U] (f: (CharProcessorAPI) ⇒ Processor[U]): Processor[U]

    Definition Classes
    Processor
  19. def foreach [U] (f: (CharProcessorAPI) ⇒ U): Unit

    Execute the Processor and pass the result to the function, much like acquireAndGet but does not return a result

    Execute the Processor and pass the result to the function, much like acquireAndGet but does not return a result

    Definition Classes
    Processor
  20. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef → Any
  21. def hashCode (): Int

    Definition Classes
    CharProcessor → AnyRef → Any
  22. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  23. def map [U] (f: (CharProcessorAPI) ⇒ U): Processor[U]

    Map the contents of this Processor to a new Processor with a new value.

    Map the contents of this Processor to a new Processor with a new value.

    The main use case is so Processor work in for-comprehensions but another useful use case is to convert the value read from a ProcessorAPI to a new value. Suppose the value read was an integer you might use map to convert the contained value to a float.

    Definition Classes
    Processor
  24. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  25. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  26. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  27. def onFailure [U >: CharProcessorAPI] (handler: PartialFunction[Throwable, Option[U]]): Processor[U]

    Declare an error handler for handling an error when executing the processor.

    Declare an error handler for handling an error when executing the processor. It is important to realize that this will catch exceptions caused ONLY by the current processor, not by 'child' Processors. IE processors that are executed within a flatmap or map of this processor.

    Examples:

    for {
      mainProcessor <- input.bytes.processor
      // if the read fails 1 will be assigned to first and passed to second as the argument of flatmap
      first <- mainProcessor.read onFailure {_ => -1}
      // if this read fails an exception will be thrown that will NOT be caught by the above onFailure method
      second <- mainProcessor.read
    } yield (first,second)
    

    to handle errors of groups of processors a composite processor must be created and the error handler added to that:

    for {
      mainProcessor <- input.bytes.processor
      // define a _composite_ processor containing the sub processor
      // that need to have error handling
      groupProcessor = for {
        first <- mainProcessor.read
        second <- mainProcessor.read
      } yield (first,second)
      // attach the error handler
      tuple <- groupProcessor onFailure {case t => log(t); None}
    } yield tuple
    

    To handle all errors in one place the yielded processor can have the error handler attached:

    val process = for {
      mainProcessor <- input.bytes.processor
      first <- mainProcessor.read
      second <- mainProcessor.read
    } yield (first,second)
    
    process.onFailure{case _ => log(t); None}
    
    process.acquireAndGet(...)
    
    U

    The value that will be returned from the handler. Also the type of the returned processor

    handler

    a partial function that can handle the exceptions thrown during the execution of the process. If the handler returns a non-empty Option the that value will be used as the value of the processor, If the handler returns None then the processor will be an empty processor If the handler throws an exception... then normal semantics of an exception are exhibitted.

    returns

    A new processor that will behave the same as this except an error during execution will be handled.

    Definition Classes
    Processor
  28. def opt : Processor[Option[CharProcessorAPI]]

    Convert this Processor to a Processor containing an Option.

    Convert this Processor to a Processor containing an Option. Methods such as next return a potentially empty Processor which will, when in a for comprehension, will stop the process at that point. Converting the processor to an option allows the process handle continue and simply handle the possibility of one input source being empty while other continue to provide data.

    Consider the following example:

    for {
      idsIn <- ids.bytesAsInts.processor
      attributes <- in.lines().processor
      _ <- idsIn.repeatUntilEmpty(attributes)
      id <- ids.next.opt.orElse(NoId)
      attr <- attributes.next.opt.orElse("")
    } yield new Record(id,attr)
    

    The above example processes the streams completely even if one ends prematurely.

    Definition Classes
    Processor
  29. def processFactory : ProcessorFactory

    Attributes
    protected
    Definition Classes
    Processor
  30. def productArity : Int

    Definition Classes
    CharProcessor → Product
  31. def productElement (arg0: Int): Any

    Definition Classes
    CharProcessor → Product
  32. def productIterator : Iterator[Any]

    Definition Classes
    Product
  33. def productPrefix : String

    Definition Classes
    CharProcessor → Product
  34. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  35. def toString (): String

    Definition Classes
    CharProcessor → AnyRef → Any
  36. def traversable [B] (implicit transformer: ProcessorTransformer[B, CharProcessorAPI, LongTraversable[B]]): LongTraversable[B]

    Convert the Processor into a LongTraversable if A is a subclass of Iterator.

    Convert the Processor into a LongTraversable if A is a subclass of Iterator.

    Definition Classes
    Processor
    Annotations
    @implicitNotFound( ... )
  37. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  38. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  39. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  40. def withFilter (f: (CharProcessorAPI) ⇒ Boolean): Processor[CharProcessorAPI]

    Same behavior as for filter.

    Same behavior as for filter.

    Definition Classes
    Processor

Deprecated Value Members

  1. def productElements : Iterator[Any]

    Definition Classes
    Product
    Annotations
    @deprecated
    Deprecated

    use productIterator instead

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from SpecificApiFactory[Char, CharProcessorAPI]

Inherited from Processor[CharProcessorAPI]

Inherited from AnyRef

Inherited from Any