Class ChannelHelper

java.lang.Object
org.jruby.util.io.ChannelHelper

public abstract class ChannelHelper extends Object
Helper that attempts to improve Channels' static helpers.
Author:
kares
  • Method Details

    • readableChannel

      public static ReadableByteChannel readableChannel(InputStream inputStream)
    • writableChannel

      public static WritableByteChannel writableChannel(OutputStream outputStream)
    • unwrapBufferedStream

      public static OutputStream unwrapBufferedStream(OutputStream filteredStream)
      Unwrap all filtering streams between the given stream and its actual unfiltered stream. This is primarily to unwrap streams that have buffers that would interfere with interactivity.
      Parameters:
      filteredStream - The stream to unwrap
      Returns:
      An unwrapped stream, presumably unbuffered
    • unwrapBufferedStream

      public static InputStream unwrapBufferedStream(InputStream filteredStream)
      Unwrap all filtering streams between the given stream and its actual unfiltered stream. This is primarily to unwrap streams that have buffers that would interfere with interactivity.
      Parameters:
      filteredStream - The stream to unwrap
      Returns:
      An unwrapped stream, presumably unbuffered
    • unwrapFilterOutputStream

      public static OutputStream unwrapFilterOutputStream(OutputStream filteredStream)
      Unwrap the given stream to its first non-FilterOutputStream. If the stream is not a FilterOutputStream it is returned immediately. Note that this version is used when you are absolutely sure you want to unwrap; the unwrapBufferedStream version will perform checks for certain types of process-related streams that should not be unwrapped (Java 7+ Process, e.g.).
      Parameters:
      filteredStream - a stream to be unwrapped, if it is a FilterOutputStream
      Returns:
      the deeped non-FilterOutputStream stream, or filterOutputStream if it is not a FilterOutputStream to begin with.
    • unwrapFilterInputStream

      public static InputStream unwrapFilterInputStream(InputStream filteredStream)
      Unwrap the given stream to its first non-FilterInputStream. If the stream is not a FilterInputStream it is returned immediately. Note that this version is used when you are absolutely sure you want to unwrap; the unwrapBufferedStream version will perform checks for certain types of process-related streams that should not be unwrapped (Java 7+ Process, e.g.).
      Parameters:
      filteredStream - a stream to be unwrapped, if it is a FilterInputStream
      Returns:
      the deeped non-FilterInputStream stream, or filterInputStream if it is not a FilterInputStream to begin with.