scalax.io

ByteChannelResource

class ByteChannelResource [+A <: ByteChannel] extends InputResource[A] with OutputResource[A] with ResourceOps[A, ByteChannelResource[A]]

A for accessing and using ByteChannels. Class can be created using the Resource object.

Linear Supertypes
OutputResource[A], Output, InputResource[A], Input, Resource[A], ResourceOps[A, ByteChannelResource[A]], ManagedResourceOperations[A], ManagedResource[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ByteChannelResource
  2. OutputResource
  3. Output
  4. InputResource
  5. Input
  6. Resource
  7. ResourceOps
  8. ManagedResourceOperations
  9. ManagedResource
  10. AnyRef
  11. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ByteChannelResource (opener: ⇒ A, closeAction: CloseAction[A], sizeFunc: () ⇒ Option[Long])

Value Members

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

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

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

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

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

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

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

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

    Definition Classes
    Resource → ManagedResource
  9. def and [B] (that: ManagedResource[B]): ManagedResource[(A, B)]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  10. def appendCloseAction [B >: A] (newAction: CloseAction[B]): ByteChannelResource[A]

    Add a CloseAction to the end of the CloseAction queue (the last action executed).

    Add a CloseAction to the end of the CloseAction queue (the last action executed).

    newAction

    The new action to append

    returns

    a new instance with the added CloseAction

    Definition Classes
    ByteChannelResourceResourceOps
  11. def appendCloseAction [B >: A] (newAction: (B) ⇒ Unit): ByteChannelResource[A]

    Creates a CloseAction from the function and passes it to appendCloseAction(CloseAction)

    Creates a CloseAction from the function and passes it to appendCloseAction(CloseAction)

    newAction

    The new action to append

    returns

    a new instance with the added CloseAction

    Definition Classes
    ResourceOps
  12. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  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 : LongTraversableView[Byte, 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
    ByteChannelResourceInput
  15. def bytesAsInts : LongTraversableView[Int, 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
    ByteChannelResourceInput
  16. def chars (implicit codec: Codec): ResourceView[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 @return an traversable of all the characters

    Definition Classes
    ByteChannelResourceInput
  17. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. def copyDataFrom (input: Input, finalize: Boolean): Unit

    Copy data from an input to this output.

    Copy data from an input to this output. Input will call this method from copyTo if it does not know how to efficiently copy the data. This method thus will copy as effiently as possible and if all else fails simply write the bytes

    input

    the source to read data from

    finalize

    do not forward request to input's copyTo method. Often only one end of the transaction will know how to efficiently transfer data so a common pattern is to check the input and see if the type of the Input object is a known type. If not then the input object will be sent the request. However, to prevent an infinite loop the finalize will be set to true so the request is not then forwarded back to copyFrom

    Definition Classes
    OutputResourceOutput
  19. def copyDataTo (output: Output, finalize: Boolean): 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

    finalize

    do not forward request to output's copyFrom method. Often only one end of the transaction will know how to efficiently transfer data so a common pattern is to check the output and see if the type of the Output object is a known type. If not then the output object will be sent the request. However, to prevent an infinite loop the finalize will be set to true so the request is not then forwarded back to copyTo

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

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

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

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  23. def flatMap [B, To] (f: (A) ⇒ B)(implicit translator: CanSafelyFlatMap[B, To]): To

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

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

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

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

    Obtain the InputStreamResource(typically) version of this object.

    Obtain the InputStreamResource(typically) version of this object.

    returns

    the InputStreamResource(typically) version of this object.

    Definition Classes
    ByteChannelResourceInputResource
  28. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  29. def lines (terminator: Terminator = Terminators.Auto, includeTerminator: Boolean = false)(implicit codec: Codec = Codec.default): ResourceView[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

    @return a non-strict traversable for iterating through all the lines

    codec

    The codec representing the desired encoding of the characters

    Definition Classes
    Input
  30. def map [B, To] (f: (A) ⇒ B)(implicit translator: CanSafelyMap[B, To]): To

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

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

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

    Attributes
    final
    Definition Classes
    AnyRef
  34. 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
    ByteChannelResourceResource
  35. def openOutput [U] (f: (Output) ⇒ U): U

    Execute the function 'f' passing an Output instance that performs all operations on a single opened connection to the underlying resource.

    Execute the function 'f' passing an Output instance that performs all operations on a single opened connection to the underlying resource. Typically each call to one of the Output's methods results in a new connection. For example if the underlying OutputStream truncates the file each time the connection is made then calling write two times will result in the contents of the second write overwriting the second write.

    Even if the underlying resource is an appending, using open will be more efficient since the connection only needs to be made a single time.

    f

    the function to execute on the new Output instance (which uses a single connection)

    returns

    the result of the function

    Definition Classes
    Output
  36. def outputStream : OutputStreamResource[ChannelOutputStreamAdapter[A]]

    Obtain the OutputStreamResource(typically) version of this object.

    Obtain the OutputStreamResource(typically) version of this object.

    returns

    the OutputStreamResource(typically) version of this object.

    Definition Classes
    ByteChannelResourceOutputResource
  37. def prependCloseAction [B >: A] (newAction: CloseAction[B]): ByteChannelResource[A]

    Add a CloseAction to the front of the CloseAction queue.

    Add a CloseAction to the front of the CloseAction queue.

    newAction

    The new action to prepend

    returns

    a new instance with the added CloseAction

    Definition Classes
    ByteChannelResourceResourceOps
  38. def prependCloseAction [B >: A] (newAction: (B) ⇒ Unit): ByteChannelResource[A]

    Creates a CloseAction from the function and passes it to prependCloseAction(CloseAction)

    Creates a CloseAction from the function and passes it to prependCloseAction(CloseAction)

    newAction

    The new action to prepend

    returns

    a new instance with the added CloseAction

    Definition Classes
    ResourceOps
  39. def readableByteChannel : ReadableByteChannelResource[A]

    Obtain the ReadableByteChannelResource(typically) version of this object.

    Obtain the ReadableByteChannelResource(typically) version of this object.

    returns

    the ReadableByteChannelResource(typically) version of this object.

    Definition Classes
    ByteChannelResourceInputResource
  40. def reader (implicit sourceCodec: Codec): ReaderResource[ChannelReaderAdapter[A]]

    Obtain the ReadCharsResource version of this object.

    Obtain the ReadCharsResource version of this object.

    returns

    the ReadCharsResource version of this object.

    Definition Classes
    ByteChannelResourceInputResource
  41. def reflect [B] : A @util.continuations.package.cps[Either[List[Throwable],B]]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  42. 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.

    Attributes
    final
    Definition Classes
    InputResourceInput
  43. val sizeFunc : () ⇒ Option[Long]

    Attributes
    protected
    Definition Classes
    ByteChannelResourceInputResource
  44. def slurpString (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
  45. def synchronized [T0] (arg0: ⇒ T0): T0

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

    Definition Classes
    AnyRef → Any
  47. def toTraversable [B] (f: (A) ⇒ TraversableOnce[B]): Traversable[B]

    Definition Classes
    ManagedResourceOperations → ManagedResource
  48. def underlyingOutput : OutputStreamResource[ChannelOutputStreamAdapter[A]]

    Definition Classes
    ByteChannelResourceOutput
  49. def wait (): Unit

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. def writableByteChannel : WritableByteChannelResource[A]

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

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

    returns

    the scalax.io.WritableByteChannel(typically) version of this object.

    Definition Classes
    ByteChannelResourceOutputResource
  53. def write (string: String)(implicit codec: Codec = Codec.default): Unit

    Writes a string.

    Writes a string.

    string

    the data to write

    codec

    the codec of the string to be written. The string will be converted to the encoding of sourceCodec Default is sourceCodec

    Definition Classes
    Output
  54. def write [T] (data: T)(implicit writer: OutputConverter[T]): Unit

    Write data to the underlying object.

    Write data to the underlying object. Each time write is called the resource is reopened, in the case of a file this means that the file will be opened and truncated. The

    In the case of writing ints and bytes it is often recommended to write arrays of data since normally the underlying object can write arrays of bytes or integers most efficiently.

    Since Characters require a codec to write to an OutputStream characters cannot be written with this method unless a OutputWriterFunction.CharFunction object is provided as the writer.

    data

    The data to write to underlying object. Any data that has a resolvable OutputConverter can be written. See the OutputConverter object for the defined OutputConverter implementations and classes to assist implementing more.

    writer

    The strategy used to write the data to the underlying object. Many standard data-types are implicitly resolved and do not need to be supplied

    Definition Classes
    Output
    See also

    #writeChars for more on writing characters

  55. def writeChars (characters: TraversableOnce[Char])(implicit codec: Codec = Codec.default): Unit

    Definition Classes
    Output
  56. def writeIntsAsBytes (data: Int*): Unit

    Since the OutputConverter object defined for writing Ints encodes Ints using 4 bytes this method is provided to simply write an array of Ints as if they are Bytes.

    Since the OutputConverter object defined for writing Ints encodes Ints using 4 bytes this method is provided to simply write an array of Ints as if they are Bytes. In other words just taking the first byte. This is pretty common in Java.io style IO. IE

     outputStream.write(1) 
    

    1 is written as a single byte.

    Definition Classes
    Output
  57. def writeStrings (strings: Traversable[String], separator: String = "")(implicit codec: Codec = Codec.default): Unit

    Write several strings.

    Write several strings.

    strings

    The data to write

    separator

    A string to add between each string. It is not added to the before the first string or after the last.

    codec

    The codec of the strings to be written. The strings will be converted to the encoding of sourceCodec

    Definition Classes
    Output
  58. def writer (implicit sourceCodec: Codec): WriterResource[ChannelWriterAdapter[A]]

    Obtain the WriteCharsResource version of this object.

    Obtain the WriteCharsResource version of this object.

    returns

    the WriteCharsResource version of this object.

    Definition Classes
    ByteChannelResourceOutputResource

Inherited from OutputResource[A]

Inherited from Output

Inherited from InputResource[A]

Inherited from Input

Inherited from Resource[A]

Inherited from ResourceOps[A, ByteChannelResource[A]]

Inherited from ManagedResourceOperations[A]

Inherited from ManagedResource[A]

Inherited from AnyRef

Inherited from Any