org.jruby.util.io
Class CRLFStreamWrapper

java.lang.Object
  extended by org.jruby.util.io.CRLFStreamWrapper
All Implemented Interfaces:
Stream

public class CRLFStreamWrapper
extends java.lang.Object
implements Stream

Wrapper around Stream that packs and unpacks LF <=> CRLF.

Author:
nicksieger

Field Summary
 
Fields inherited from interface org.jruby.util.io.Stream
PARAGRAPH_DELIMETER, PARAGRAPH_SEPARATOR, SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
CRLFStreamWrapper(Stream stream)
           
 
Method Summary
 void clearerr()
           
 void fclose()
           
 boolean feof()
          Return true when at end of file (EOF).
 int fflush()
           
 int fgetc()
           
 long fgetpos()
          Get the current position within the file associated with this handler.
 org.jruby.util.ByteList fgets(org.jruby.util.ByteList separatorString)
           
 void fputc(int c)
           
 org.jruby.util.ByteList fread(int number)
           
 void freopen(Ruby runtime, java.lang.String path, ModeFlags modes)
           
 void ftruncate(long newLength)
           
 int fwrite(org.jruby.util.ByteList string)
           
 java.nio.channels.Channel getChannel()
           
 ChannelDescriptor getDescriptor()
           
 int getline(org.jruby.util.ByteList dst, byte terminator)
          Read all bytes up to and including a terminator byte.
 int getline(org.jruby.util.ByteList dst, byte terminator, long limit)
          Reads all bytes up to and including a terminator byte or until limit is reached.
 ModeFlags getModes()
           
 boolean isAutoclose()
           
 boolean isBlocking()
           
 boolean isSync()
           
 void lseek(long offset, int type)
          Perform a seek based on pos().
 java.io.InputStream newInputStream()
           
 java.io.OutputStream newOutputStream()
           
 org.jruby.util.ByteList read(int number)
           
 org.jruby.util.ByteList readall()
           
 boolean readDataBuffered()
           
 int ready()
          Implement IO#ready? as per io/wait in MRI.
 void setAutoclose(boolean autoclose)
           
 void setBinmode()
           
 void setBlocking(boolean blocking)
           
 void setSync(boolean sync)
           
 void sync()
          Flush and sync all writes to the filesystem.
 int ungetc(int c)
           
 void waitUntilReady()
          Implement IO#wait as per io/wait in MRI.
 boolean writeDataBuffered()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRLFStreamWrapper

public CRLFStreamWrapper(Stream stream)
Method Detail

getDescriptor

public ChannelDescriptor getDescriptor()
Specified by:
getDescriptor in interface Stream

clearerr

public void clearerr()
Specified by:
clearerr in interface Stream

getModes

public ModeFlags getModes()
Specified by:
getModes in interface Stream

isSync

public boolean isSync()
Specified by:
isSync in interface Stream

setSync

public void setSync(boolean sync)
Specified by:
setSync in interface Stream

setBinmode

public void setBinmode()
Specified by:
setBinmode in interface Stream

isAutoclose

public boolean isAutoclose()
Specified by:
isAutoclose in interface Stream

setAutoclose

public void setAutoclose(boolean autoclose)
Specified by:
setAutoclose in interface Stream

fgets

public org.jruby.util.ByteList fgets(org.jruby.util.ByteList separatorString)
                              throws java.io.IOException,
                                     BadDescriptorException,
                                     java.io.EOFException
Specified by:
fgets in interface Stream
Throws:
java.io.IOException
BadDescriptorException
java.io.EOFException

readall

public org.jruby.util.ByteList readall()
                                throws java.io.IOException,
                                       BadDescriptorException,
                                       java.io.EOFException
Specified by:
readall in interface Stream
Throws:
java.io.IOException
BadDescriptorException
java.io.EOFException

getline

public int getline(org.jruby.util.ByteList dst,
                   byte terminator)
            throws java.io.IOException,
                   BadDescriptorException
Description copied from interface: Stream
Read all bytes up to and including a terminator byte.

If the terminator byte is found, it will be the last byte in the output buffer.

Specified by:
getline in interface Stream
Parameters:
dst - The output buffer.
terminator - The byte to terminate reading.
Returns:
The number of bytes read, or -1 if EOF is reached.
Throws:
java.io.IOException
BadDescriptorException

getline

public int getline(org.jruby.util.ByteList dst,
                   byte terminator,
                   long limit)
            throws java.io.IOException,
                   BadDescriptorException
Description copied from interface: Stream
Reads all bytes up to and including a terminator byte or until limit is reached.

If the terminator byte is found, it will be the last byte in the output buffer.

Specified by:
getline in interface Stream
Parameters:
dst - The output buffer.
terminator - The byte to terminate reading.
limit - the number of bytes to read unless EOF or terminator is found
Returns:
The number of bytes read, or -1 if EOF is reached.
Throws:
java.io.IOException
BadDescriptorException

fread

public org.jruby.util.ByteList fread(int number)
                              throws java.io.IOException,
                                     BadDescriptorException,
                                     java.io.EOFException
Specified by:
fread in interface Stream
Throws:
java.io.IOException
BadDescriptorException
java.io.EOFException

fwrite

public int fwrite(org.jruby.util.ByteList string)
           throws java.io.IOException,
                  BadDescriptorException
Specified by:
fwrite in interface Stream
Throws:
java.io.IOException
BadDescriptorException

fgetc

public int fgetc()
          throws java.io.IOException,
                 BadDescriptorException,
                 java.io.EOFException
Specified by:
fgetc in interface Stream
Throws:
java.io.IOException
BadDescriptorException
java.io.EOFException

ungetc

public int ungetc(int c)
Specified by:
ungetc in interface Stream

fputc

public void fputc(int c)
           throws java.io.IOException,
                  BadDescriptorException
Specified by:
fputc in interface Stream
Throws:
java.io.IOException
BadDescriptorException

read

public org.jruby.util.ByteList read(int number)
                             throws java.io.IOException,
                                    BadDescriptorException,
                                    java.io.EOFException
Specified by:
read in interface Stream
Throws:
java.io.IOException
BadDescriptorException
java.io.EOFException

fclose

public void fclose()
            throws java.io.IOException,
                   BadDescriptorException
Specified by:
fclose in interface Stream
Throws:
java.io.IOException
BadDescriptorException

fflush

public int fflush()
           throws java.io.IOException,
                  BadDescriptorException
Specified by:
fflush in interface Stream
Throws:
java.io.IOException
BadDescriptorException

sync

public void sync()
          throws java.io.IOException,
                 BadDescriptorException
Description copied from interface: Stream

Flush and sync all writes to the filesystem.

Specified by:
sync in interface Stream
Throws:
java.io.IOException - if the sync does not work
BadDescriptorException

feof

public boolean feof()
             throws java.io.IOException,
                    BadDescriptorException
Description copied from interface: Stream

Return true when at end of file (EOF).

Specified by:
feof in interface Stream
Returns:
true if at EOF; false otherwise
Throws:
java.io.IOException
BadDescriptorException

fgetpos

public long fgetpos()
             throws java.io.IOException,
                    PipeException,
                    BadDescriptorException,
                    InvalidValueException
Description copied from interface: Stream

Get the current position within the file associated with this handler.

Specified by:
fgetpos in interface Stream
Returns:
the current position in the file.
Throws:
java.io.IOException
PipeException - ESPIPE (illegal seek) when not a file
BadDescriptorException
InvalidValueException

lseek

public void lseek(long offset,
                  int type)
           throws java.io.IOException,
                  InvalidValueException,
                  PipeException,
                  BadDescriptorException
Description copied from interface: Stream

Perform a seek based on pos().

Specified by:
lseek in interface Stream
Throws:
java.io.IOException
InvalidValueException
PipeException
BadDescriptorException

ftruncate

public void ftruncate(long newLength)
               throws java.io.IOException,
                      PipeException,
                      InvalidValueException,
                      BadDescriptorException
Specified by:
ftruncate in interface Stream
Throws:
java.io.IOException
PipeException
InvalidValueException
BadDescriptorException

ready

public int ready()
          throws java.io.IOException
Description copied from interface: Stream
Implement IO#ready? as per io/wait in MRI. returns non-nil if input available without blocking, or nil.

Specified by:
ready in interface Stream
Throws:
java.io.IOException

waitUntilReady

public void waitUntilReady()
                    throws java.io.IOException,
                           java.lang.InterruptedException
Description copied from interface: Stream
Implement IO#wait as per io/wait in MRI. waits until input available or timed out and returns self, or nil when EOF reached. The default implementation loops while ready returns 0.

Specified by:
waitUntilReady in interface Stream
Throws:
java.io.IOException
java.lang.InterruptedException

readDataBuffered

public boolean readDataBuffered()
Specified by:
readDataBuffered in interface Stream

writeDataBuffered

public boolean writeDataBuffered()
Specified by:
writeDataBuffered in interface Stream

newInputStream

public java.io.InputStream newInputStream()
Specified by:
newInputStream in interface Stream

newOutputStream

public java.io.OutputStream newOutputStream()
Specified by:
newOutputStream in interface Stream

isBlocking

public boolean isBlocking()
Specified by:
isBlocking in interface Stream

setBlocking

public void setBlocking(boolean blocking)
                 throws java.io.IOException
Specified by:
setBlocking in interface Stream
Throws:
java.io.IOException

freopen

public void freopen(Ruby runtime,
                    java.lang.String path,
                    ModeFlags modes)
             throws DirectoryAsFileException,
                    java.io.IOException,
                    InvalidValueException,
                    PipeException,
                    BadDescriptorException
Specified by:
freopen in interface Stream
Throws:
DirectoryAsFileException
java.io.IOException
InvalidValueException
PipeException
BadDescriptorException

getChannel

public java.nio.channels.Channel getChannel()
Specified by:
getChannel in interface Stream


Copyright © 2002-2009 JRuby Team. All Rights Reserved.