com.monica.javacom.streams
Class MJCWriteableIsAIS

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--com.monica.javacom.streams.MJCWriteableIsAIS
All Implemented Interfaces:
MJCWriteable

public class MJCWriteableIsAIS
extends java.io.InputStream
implements MJCWriteable

Class for enabling to read from the MJC layer hierarchy using the conventional InputStream methods. Objects of this class act as InputStreams, the data readable from the InputStream will be generated by the MJCWriter corresponding to this MJCWriteable.


Constructor Summary
MJCWriteableIsAIS()
          Default constructor.
 
Method Summary
 int available()
          Returns the number of bytes that are currently available for reading from the stream.
 void close()
          Closes the InputStream.
 void flush()
          MJCWriteableIsAIS does not implement the flush method, because it cannot be ensured that after flush() the contents of the buffer will be read from the InputStream.
 java.lang.String getLastWriteableError()
          Returns the last error that occured during the write methods.
 java.lang.String getWriteableName()
          Returns the MJC name of the MJCWriteable.
 java.lang.String getWriteableVersion()
          Returns the MJC version of the MJCWriteable.
 boolean isWriteableConnected()
          Returns wether the InputStream is still open.
 void mark(int readlimit)
          MJCWriteableIsAIS does not support mark/reset.
 boolean markSupported()
          MJCWriteableIsAIS does not support mark/reset.
 int read()
          Reads 1 single byte from the stream.
 int read(byte[] b)
          Reads b.length bytes from the stream.
 int read(byte[] b, int off, int len)
          Reads len bytes from the stream.
 void reset()
          MJCWriteableIsAIS does not support mark/reset.
 long skip(long n)
          Skips n bytes in the stream.
 boolean write(char c)
          Writes one single char to the stream.
 boolean write(char[] c)
          Writes a char array to the stream.
 boolean write(java.lang.String s)
          Writes a String to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MJCWriteableIsAIS

public MJCWriteableIsAIS()
Default constructor.
Method Detail

getWriteableName

public java.lang.String getWriteableName()
Returns the MJC name of the MJCWriteable.
Specified by:
getWriteableName in interface MJCWriteable
Returns:
String: the MJC name of the MJCWriteable

getWriteableVersion

public java.lang.String getWriteableVersion()
Returns the MJC version of the MJCWriteable.
Specified by:
getWriteableVersion in interface MJCWriteable
Returns:
String: te MJC version of the MJCWriteable

write

public boolean write(char c)
Writes one single char to the stream. Writing is buffered.
Specified by:
write in interface MJCWriteable
Parameters:
char - c: the char to be written to the stream
Returns:
boolean: wether the writing has been successful

write

public boolean write(java.lang.String s)
Writes a String to the stream. Wrinting is buffered.
Specified by:
write in interface MJCWriteable
Parameters:
String - s: the String to be written to the stream
Returns:
boolean: wether the writing has been successful

write

public boolean write(char[] c)
Writes a char array to the stream. Writing is buffered.
Specified by:
write in interface MJCWriteable
Parameters:
char[] - c: the char array to be written to the stream
Returns:
boolean: wether the writing has been successful

flush

public void flush()
MJCWriteableIsAIS does not implement the flush method, because it cannot be ensured that after flush() the contents of the buffer will be read from the InputStream. This method does nothing.
Specified by:
flush in interface MJCWriteable

getLastWriteableError

public java.lang.String getLastWriteableError()
Returns the last error that occured during the write methods. After this method has been invoded, the errormessage will be erased.
Specified by:
getLastWriteableError in interface MJCWriteable
Returns:
String: the last error message

isWriteableConnected

public boolean isWriteableConnected()
Returns wether the InputStream is still open.
Specified by:
isWriteableConnected in interface MJCWriteable
Returns:
boolean: wether the InputStream is still open

read

public int read()
         throws java.io.IOException
Reads 1 single byte from the stream. The read blocks till data is available.
Overrides:
read in class java.io.InputStream
Returns:
int: the byte read
Throws:
IOException: - if the InputStream has been closed

read

public int read(byte[] b)
         throws java.io.IOException
Reads b.length bytes from the stream. The read blocks till data is available. Returns the number of bytes read.
Overrides:
read in class java.io.InputStream
Parameters:
byte[] - b: the byte array into the data will be read
Returns:
int: the number of bytes read
Throws:
IOException: - if the InputStream has been closed

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads len bytes from the stream. The read blocks till data is available. Returns the number of bytes read.
Overrides:
read in class java.io.InputStream
Parameters:
byte[] - b: the byte array into the data will be read
int - off: the beginning offset from which the bytes will be written into b (inclusive)
int - len: the number of bytes to be read
Returns:
int: the number of bytes read
Throws:
IOException: - if the InputStream has been closed
IndexOutOfBoundsException: - if (b.length<(off+len))

skip

public long skip(long n)
          throws java.io.IOException
Skips n bytes in the stream. Skipped data will be lost. For some reasons the stream may skip less bytes than n.
Overrides:
skip in class java.io.InputStream
Parameters:
long - n: number of bytes to be skipped
Returns:
long: number of bytes actually skipped
Throws:
IOException: - if the InputStream has been closed

available

public int available()
              throws java.io.IOException
Returns the number of bytes that are currently available for reading from the stream.
Overrides:
available in class java.io.InputStream
Returns:
int: the number of bytes available from the stream
Throws:
IOException: - if the InputStream has been closed

close

public void close()
           throws java.io.IOException
Closes the InputStream. After close(), no read, close and available methods can be called without IOException.
Overrides:
close in class java.io.InputStream
Throws:
IOException: - if the InputStream has been closed

mark

public void mark(int readlimit)
MJCWriteableIsAIS does not support mark/reset. This method does actually nothing.
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
MJCWriteableIsAIS does not support mark/reset. This method will always throw an IOException.
Overrides:
reset in class java.io.InputStream
Throws:
IOException: - MJCWriteableIsAIS does not support mark/reset

markSupported

public boolean markSupported()
MJCWriteableIsAIS does not support mark/reset.
Overrides:
markSupported in class java.io.InputStream
Returns:
boolean: false