scalax.io.managed

InputStreamResource

class InputStreamResource[+A <: InputStream] extends InputResource[A] with ResourceOps[A, InputStreamResource[A]]

A ManagedResource for accessing and using InputStreams. Class can be created using the scalax.io.Resource object.

Self Type
InputStreamResource[A]
Linear Supertypes
InputResource[A], Input, Resource[A], ResourceOps[A, InputStreamResource[A]], ManagedResourceOperations[A], ManagedResource[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. InputStreamResource
  2. InputResource
  3. Input
  4. Resource
  5. ResourceOps
  6. ManagedResourceOperations
  7. ManagedResource
  8. AnyRef
  9. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new InputStreamResource(opener: ⇒ A, context: ResourceContext = DefaultResourceContext, closeAction: CloseAction[A] = CloseAction.Noop, sizeFunc: () ⇒ Option[Long] = (() => scala.None))

Value Members

  1. def !: A @scala.util.continuations.cpsParam[Unit,Unit]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  2. final def !=(arg0: AnyRef): Boolean

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

    Definition Classes
    Any
  4. final def ##(): Int

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

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

    Definition Classes
    Any
  7. def acquireAndGet[B](f: (A) ⇒ B): B

    Definition Classes
    ManagedResourceOperations → ManagedResource
  8. final def acquireFor[B](f: (A) ⇒ B): Either[List[Throwable], B]

    Open the resource execute the function and either return all errors as a list or the result of the function execution.

    Open the resource execute the function and either return all errors as a list or the result of the function execution.

    On open and close error handlers in ResourceContext are called. If they then raise errors the errors are captured and returned as a Right[List[Throwable]]

    Perhaps the worst method I have ever written :-(

    Definition Classes
    Resource → ManagedResource
  9. def addCloseAction(newCloseAction: CloseAction[A]): InputStreamResource[A]

    Add a CloseAction that will be executed each time the resource is closed.

    Add a CloseAction that will be executed each time the resource is closed.

    newCloseAction

    the action to add

    returns

    a new resource instance with the close action added

    Definition Classes
    InputStreamResourceResourceOps
  10. def and[B](that: ManagedResource[B]): ManagedResource[(A, B)]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  11. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  12. def blocks(blockSize: Option[Int] = None): LongTraversable[ByteBlock]

    Read the input as blocks of bytes.

    Read the input as blocks of bytes. This method should be avoided unless the maximum performance is absolutely required because bytes provides very good performance and is a better API for most applications.

    However since it better reflects how data is read with most input sources (like InputStreams and ReadableByteChannels); blocks is slightly more performance than bytes and therefore can be used when performance is the most important consideration.

    blockSize

    block size can optionally be specified but the default is normally acceptable.

    Definition Classes
    InputStreamResourceInput
  13. def byteArray: Array[Byte]

    This method aspires to be the fastest way to read a stream of known length into memory.

    This method aspires to be the fastest way to read a stream of known length into memory.

    Definition Classes
    Input
  14. def bytes: LongTraversable[Byte]

    Obtains a Traversable for conveniently processing the resource as bytes.

    Obtains a Traversable for conveniently processing the resource as bytes.

    returns

    an non-strict traversable over all the bytes

    Definition Classes
    InputStreamResourceInput
  15. def bytesAsInts: LongTraversable[Int]

    Obtains a Traversable for conveniently processing the file as Ints.

    Obtains a Traversable for conveniently processing the file as Ints.

    returns

    an non-strict traversable over all the bytes with the bytes being represented as Ints

    Definition Classes
    InputStreamResourceInput
  16. def chars(implicit codec: Codec): LongTraversable[Char]

    The characters in the object.

    The characters in the object.

    If the codec is not the same as the source codec (the codec of the underlying data) then the characters will converted to the desired codec.

    codec

    The codec representing the desired encoding of the characters

    returns

    an traversable of all the characters

    Definition Classes
    InputStreamResourceInput
  17. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. val context: ResourceContext

    Get the Resource context that configures how the underlying resource is accessed

    Get the Resource context that configures how the underlying resource is accessed

    returns

    the associated ResourceContext

    Definition Classes
    InputStreamResourceInputResourceOps
  19. def copyDataTo(output: Output): Unit

    Copy all data from this Input object to the Output object as efficiently as possible.

    Copy all data from this Input object to the Output object as efficiently as possible.

    output

    output sink to copy the data to

    Definition Classes
    InputResourceInput
  20. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  22. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. def flatMap[B](f: (A) ⇒ ManagedResource[B]): ManagedResource[B]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  24. def foreach(f: (A) ⇒ Unit): Unit

    Definition Classes
    ManagedResourceOperations → ManagedResource
  25. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  26. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  27. def inputStream: InputStreamResource[A]

    Obtain the scalax.io.managed.InputStreamResource(typically) version of this object.

    Obtain the scalax.io.managed.InputStreamResource(typically) version of this object.

    returns

    the scalax.io.managed.InputStreamResource(typically) version of this object.

    Definition Classes
    InputStreamResourceInputResource
  28. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  29. def lines(terminator: Terminator = Terminators.Auto, includeTerminator: Boolean = false)(implicit codec: Codec = Codec.default): LongTraversable[String]

    Obtain an non-strict traversable for iterating through the lines in the object

    Obtain an non-strict traversable for iterating through the lines in the object

    If the codec is not the same as the source codec (the codec of the underlying data) then the characters will converted to the desired codec.

    terminator

    The strategy for determining the end of line Default is to auto-detect the EOL

    includeTerminator

    if true then the line will end with the line terminator Default is false

    codec

    The codec representing the desired encoding of the characters

    returns

    a non-strict traversable for iterating through all the lines

    Definition Classes
    Input
  30. def map[B](f: (A) ⇒ B): ExtractableManagedResource[B]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  31. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  32. final def notify(): Unit

    Definition Classes
    AnyRef
  33. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  34. def now: A @scala.util.continuations.cpsParam[Unit,Unit]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  35. def open(): OpenedResource[A]

    Creates a new instance of the underlying resource (or opens it).

    Creates a new instance of the underlying resource (or opens it). Sometimes the code block used to create the Resource is non-reusable in which case this Resource can only be used once. This is not recommended.

    When creating a resource it is recommended to pass the code block for creating the resource to the resource so that the resource can be reused. Of course this is not always possible

    This method should only be used with care in cases when Automatic Resource Management cannot be used because the InputStream must be closed manually.

    This is public only to permit interoperability with certain Java APIs. A better pattern of use should be:

    resource.acquireFor {
    // call java API
    }

    or

    val calculatedResult = resource.acquireAndGet {
    // cal java API that returns a result
    }
    returns

    the actual resource that has been opened

    Definition Classes
    InputStreamResourceResource
    Note

    normally the error handler registered with the associated ResourceContext will handle any errors opening the resource, but when calling this method the caller must handle any possible errors that are raised.

  36. def readableByteChannel: ReadableByteChannelResource[ReadableByteChannel]

    Obtain the scalax.io.managed.ReadableByteChannelResource(typically) version of this object.

    Obtain the scalax.io.managed.ReadableByteChannelResource(typically) version of this object.

    returns

    the scalax.io.managed.ReadableByteChannelResource(typically) version of this object.

    Definition Classes
    InputStreamResourceInputResource
  37. def reader(implicit sourceCodec: Codec): ReaderResource[InputStreamReader with Adapter[A]]

    Obtain the scalax.io.ReadCharsResource version of this object.

    Obtain the scalax.io.ReadCharsResource version of this object.

    sourceCodec

    the codec used to convert from bytes to characters

    returns

    the scalax.io.ReadCharsResource version of this object.

    Definition Classes
    InputStreamResourceInputResource
  38. def reflect[B]: A @util.continuations.cps[Either[List[Throwable],B]]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  39. final def size: Option[Long]

    The number of bytes that can be read from the underlying resource.

    The number of bytes that can be read from the underlying resource.

    if length == None then it is not possible to determine the number of bytes in advance.

    Definition Classes
    InputResourceInput
  40. val sizeFunc: () ⇒ Option[Long]

    Safely calculation the size of the resource or return None in case of failure or if it is not possible to determin size of resource before accessing the resource.

    Safely calculation the size of the resource or return None in case of failure or if it is not possible to determin size of resource before accessing the resource.

    Attributes
    protected
    Definition Classes
    InputStreamResourceInputResource
  41. def string(implicit codec: Codec = Codec.default): String

    Loads all the characters into memory.

    Loads all the characters into memory. There is no protection against loading very large files/amounts of data.

    codec

    The codec representing the desired encoding of the characters

    Definition Classes
    Input
  42. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  43. def toString(): String

    Definition Classes
    InputStreamResource → AnyRef → Any
  44. def toTraversable[B](implicit ev: <:<[A, TraversableOnce[B]]): Traversable[B]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  45. def updateContext(newContext: ResourceContext): InputStreamResource[A]

    Create a Resource instance that is configured with the new ResourceContext

    Create a Resource instance that is configured with the new ResourceContext

    newContext

    A new ResourceContext

    returns

    a new instance configured with the new context

    Definition Classes
    InputStreamResourceResourceOps
  46. def updateContext(f: (ResourceContext) ⇒ ResourceContext): InputStreamResource[A]

    Update the current ResourceContext and return a new Resource instance with the updated context

    Update the current ResourceContext and return a new Resource instance with the updated context

    f

    A function for transforming the current context to a new context with new values.

    returns

    a new instance configured with the new context

    Definition Classes
    ResourceOps
  47. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from InputResource[A]

Inherited from Input

Inherited from Resource[A]

Inherited from ResourceOps[A, InputStreamResource[A]]

Inherited from ManagedResourceOperations[A]

Inherited from ManagedResource[A]

Inherited from AnyRef

Inherited from Any

Ungrouped