scalax.io

ResourceContext

trait ResourceContext extends AnyRef

The context a resource uses for obtaining configuration information. This object is in large part a configuration object for a resource. It controls the size and buffer type used to read data to and from channels. It controls how errors are handled, etc...

Self Type
ResourceContext
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ResourceContext
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

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

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

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

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

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def byteBufferSize(dataSize: Option[Long], readOnly: Boolean): Int

    Returns the size of the buffer to create.

    Returns the size of the buffer to create. If the dataSize is non-null it can be used in determining the best size to use.

    The default algorithm will create a buffer that is dataSize if dataSize <= recommendedByteBufferSize and the buffer is read-only. Otherwise recommendedByteBufferSize is used

    dataSize

    optionally provide the size of the input. usually only matters when reading

    readOnly

    indicates if the buffer will be used in read only operations

  8. def charBufferSize(dataSize: Option[Int], readOnly: Boolean): Int

    Returns the size of the character buffer to create.

    Returns the size of the character buffer to create. If the dataSize is non-null it can be used in determining the best size to use.

    The default algorithm will create a buffer that is dataSize if dataSize <= recommendedCharBufferSize and the buffer is read-only. Otherwise recommendedCharBufferSize is used

    dataSize

    optionally provide the size of the input. usually only matters when reading

    readOnly

    indicates if the buffer will be used in read only operations

  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  10. def copy[U](newByteBufferSize: Option[(Option[Long], Boolean) ⇒ Int], newCharBufferSize: Option[(Option[Int], Boolean) ⇒ Int], newCreateNioBuffer: Option[(Int, Option[Channel], Boolean) ⇒ ByteBuffer], newOpenErrorHandler: Option[(Throwable) ⇒ Throwable], newErrorHandler: Option[(Either[Throwable, U], List[Throwable]) ⇒ U], newDescName: Option[ResourceDescName]): ResourceContext

    Mutate the current instance by modifying the behavior of some of the functions.

    Mutate the current instance by modifying the behavior of some of the functions.

    A typical use is as follows:

    context.copy(newErrorHandler = Some( myErrorHandler ) )

    This example will return a new copy of the context with a new error handler configured. All other methods will behave the same as the original context.

    newByteBufferSize

    A new strategy for determining the size of a byte buffer to make. The default value is None which will keep the behaviour of the current context

    newCharBufferSize

    A new strategy for determining the size of a character buffer to make The default value is None which will keep the behaviour of the current context

    newCreateNioBuffer

    A new strategy for creating an nio ByteBuffer The default value is None which will keep the behaviour of the current context

    newErrorHandler

    A new strategy for handling errors encountered by the associated resource The default value is None which will keep the behaviour of the current context

    newDescName

    A new descriptive name for the associated resources The default value is None which will keep the behaviour of the current context

  11. final def createNioBuffer(dataSize: Option[Long], channel: Option[Channel], readOnly: Boolean): ByteBuffer

    Creates the byte buffer.

    Creates the byte buffer.

    Implementation is simply:

    createNioBuffer(byteBufferSize(dataSize, readOnly), channel, readOnly)
    dataSize

    size of the buffer to make. The buffer will always be this size, unless the file is memory-mapped and the channel is smaller than bufferSize. In which case it will be the size of the channel.

    channel

    Optionally the channel that this buffer will be used with. See section above about memory mapping. The channel can be used by subclasses to determine the type of buffer to return

    readOnly

    if the use of the buffer will be read-only on the channel provided

  12. def createNioBuffer(bufferSize: Int, channel: Option[Channel], readOnly: Boolean): ByteBuffer

    Creates a buffer for channels.

    Creates a buffer for channels. This is java specific API and is not cross platform. Subclasses override this method in order to enable memory mapping of files.

    The default implementation will create a direct ByteBuffer unless

    • the channel is a filechannel
    • the channel size is smaller than bufferSize
    • It is in read-only mode

    If all these criteria are met then the file will be memory-mapped.

    bufferSize

    size of the buffer to make. The buffer will always be this size, unless the file is memory-mapped and the channel is smaller than bufferSize. In which case it will be the size of the channel.

    channel

    Optionally the channel that this buffer will be used with. See section above about memory mapping. The channel can be used by subclasses to determine the type of buffer to return

    readOnly

    if the use of the buffer will be readonly on the channel provided

  13. def descName: ResourceDescName

    A name that describes the resource.

    A name that describes the resource. This has no real functional value, it is intended to assist in debugging (for example loggin)

  14. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  16. def errorHandler[U](accessResult: Either[Throwable, U], closingExceptions: List[Throwable]): U

    Called when an exception is raised during an IO operation.

    Called when an exception is raised during an IO operation. The resource will be closed and all exceptions (including the closing exceptions) will be passed to this errorHandler.

    If no exception occurred during the access of the resource the mainException will be a Right(...) containing the result and the closingExceptions will contain the list of exceptions raised while closing the resource (and the CloseActions)

    The default behaviour is to throw a ScalaIOException irregardless of whether the exception occurred during the operation or during closing the resource.

    accessResult

    the exception that occurred during the resource access or the result.

    closingExceptions

    the exceptions raised while closing the resource.

    returns

    the value of accessResult if it has a result. If a value cannot be returned an exception should be thrown. DO NOT RETURN null!

    Note

    The error handling is very experimental and could be removed or dramatically altered. Please give feedback. An error handling API less likely to change is the Processor API error handling.

  17. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  18. final def getClass(): Class[_]

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

    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

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

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

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

    Definition Classes
    AnyRef
  24. def openErrorHandler(openException: Throwable): Throwable

    Called when opening the resource and an exception occurs.

    Called when opening the resource and an exception occurs.

    The default behaviour is to throw the openException

    openException

    the exception that was raised while opening the resource.

    returns

    if a default value can be determined by inspecting f or openException then this method can return that value. The value will be returned in lieu of the result calling f. If a value cannot be returned an exception should be thrown. DO NOT RETURN null!

    Note

    The error handling is very experimental and could be removed or dramatically altered. Please give feedback. An error handling API less likely to change is the Processor API error handling.

  25. final val recommendedByteBufferSize: Int(4096)

    The recommended size of a byte buffer for the current platform

  26. final val recommendedCharBufferSize: Int(1024)

    The recommended size of a character buffer for the current platform

  27. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  28. def toString(): String

    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from AnyRef

Inherited from Any

Ungrouped