scalax.io.managed

OutputStreamResource

class OutputStreamResource[+A <: OutputStream] extends OutputResource[A] with ResourceOps[A, OutputStreamResource[A]]

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

Self Type
OutputStreamResource[A]
Linear Supertypes
OutputResource[A], Output, Resource[A], ResourceOps[A, OutputStreamResource[A]], ManagedResourceOperations[A], ManagedResource[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. OutputStreamResource
  2. OutputResource
  3. Output
  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 OutputStreamResource(opener: ⇒ A, context: ResourceContext = DefaultResourceContext, closeAction: CloseAction[A] = CloseAction.Noop)

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]): OutputStreamResource[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
    OutputStreamResourceResourceOps
  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 clone(): AnyRef

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

    Get the Resource context associated with this Resource instance.

    Get the Resource context associated with this Resource instance.

    returns

    the associated ResourceContext

    Definition Classes
    OutputStreamResourceResourceOps
    Note

    as Resources are immutable objects a given Resource instance will always be associated with the same ResourceContext

  14. def doCopyFrom(input: Input): Unit

    If possible efficiently copy data from input.

    If possible efficiently copy data from input. It MUST NOT forward request to input's copyTo method because that could trigger an infinate loop

    Definition Classes
    OutputResourceOutput
  15. final def eq(arg0: AnyRef): Boolean

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

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

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

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

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

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

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

    Definition Classes
    Any
  23. def map[B](f: (A) ⇒ B): ExtractableManagedResource[B]

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

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

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

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

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

  29. def outputProcessor: OutputProcessor

    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.

    returns

    the result of the function

    Definition Classes
    Output
  30. def outputStream: OutputStreamResource[A]

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

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

    returns

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

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

    Definition Classes
    ManagedResourceOperations → ManagedResource
  32. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  33. def toString(): String

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

    Definition Classes
    ManagedResourceOperations → ManagedResource
  35. def underlyingOutput: WritableByteChannelResource[WritableChannelAdapter[A]]

    Attributes
    protected
    Definition Classes
    OutputStreamResourceOutput
  36. def updateContext(newContext: ResourceContext): OutputStreamResource[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
    OutputStreamResourceResourceOps
  37. def updateContext(f: (ResourceContext) ⇒ ResourceContext): OutputStreamResource[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
  38. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  41. def writableByteChannel: WritableByteChannelResource[WritableChannelAdapter[A]]

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

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

    returns

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

    Definition Classes
    OutputStreamResourceOutputResource
  42. 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
  43. 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 scalax.io.OutputConverter can be written. See the scalax.io.OutputConverter object for the defined scalax.io.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

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

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

    Since the scalax.io.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 scalax.io.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
  46. 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
  47. def writer(implicit sourceCodec: Codec): WriterResource[Writer]

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

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

    sourceCodec

    the codec used to convert from bytes to characters

    returns

    the scalax.io.WriteCharsResource version of this object.

    Definition Classes
    OutputStreamResourceOutputResource

Inherited from OutputResource[A]

Inherited from Output

Inherited from Resource[A]

Inherited from ResourceOps[A, OutputStreamResource[A]]

Inherited from ManagedResourceOperations[A]

Inherited from ManagedResource[A]

Inherited from AnyRef

Inherited from Any

Ungrouped