grizzled

util

package util

Miscellaneous utility functions and methods not otherwise categorized.

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

Type Members

  1. trait CanReleaseResource[-T] extends AnyRef

    withResource() needs an implicit evidence parameter of this type to know how to release what's passed to it.

Value Members

  1. object CanReleaseResource

    Companion object for CanReleaseResource, providing predefined implicit evidence parameters for withResource().

  2. def withResource[T, R](resource: T)(code: (T) ⇒ R)(implicit mgr: CanReleaseResource[T]): R

    Ensure that a closeable object is closed.

    Ensure that a closeable object is closed. Note that this function requires an implicit evidence parameter of type CanClose to determine how to close the object. You can implement your own, though common ones are provided automatically.

    Sample use:

    withResource(new java.io.FileInputStream("/path/to/file")) {
    in => ...
    }
    resource

    the object that holds a resource to be released

    code

    the code block to execute with the resource

    mgr

    the resource manager that can release the resource

    returns

    whatever the block returns

Deprecated Value Members

  1. def withCloseable[T <: AnyRef { def close(): Unit }, R](closeable: T)(code: (T) ⇒ R): R

    Used with any object that contains a close() method that returns nothing, withCloseable() executes a block of code with the closeable object, ensuring that the object is closed no matter what.

    Used with any object that contains a close() method that returns nothing, withCloseable() executes a block of code with the closeable object, ensuring that the object is closed no matter what. It allows you to replace code like this:

    val closeableObject = ...
    try {
      doSomethingWith(closeableObject)
    }
    finally {
      closeableObject.close
    }

    with:

    withCloseable(closeableObject) { closeable =>
    doSomethingWith(closeable)
    }
    closeable

    the closeable object

    code

    the block of code, which will take the closeable object and return some arbitrary type R.

    returns

    whatever the code block returns,if anything.

    Annotations
    @deprecated
    Deprecated

    (Since version 1.5.1) Use grizzled.util.withResource

Inherited from AnyRef

Inherited from Any

Ungrouped