Jacson

de.spieleck.app.jacson
Class JacsonReader

java.lang.Object
  extended byjava.io.Reader
      extended byjava.io.FilterReader
          extended byde.spieleck.app.jacson.JacsonReader
Direct Known Subclasses:
JacsonAntFilter

public class JacsonReader
extends java.io.FilterReader

Wrap a Jacson into a FilterReader.

Author:
fsn

Field Summary
protected  java.lang.String configName
          The name of the configuration in filesystem
protected  Jacson jacson
          Embedded worker Jacson
static java.lang.String PIPE_BROKEN
           
protected  java.io.PipedWriter pWriter
          The piped writer Jacson writes into
protected  java.io.Reader reader
          The embedded reader
protected  JacsonState rootState
          The state used by this Jacson
static java.lang.String WRITE_END_DEAD
          XXX Message of PipedReader
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
JacsonReader(java.io.Reader reader)
          Create a new Reader with a prescribed configuration.
JacsonReader(java.io.Reader reader, java.lang.String configName)
          Create a new reader with prescribed input and configuration
 
Method Summary
 void close()
          Close the stream.
protected static boolean isIgnorableException(java.io.IOException io)
          Check for pipe exceptions which are allowed in my context.
 void mark(int readAheadLimit)
          Mark the present position in the stream.
 boolean markSupported()
          Tell whether this stream supports the mark() operation.
protected  JacsonState obtainRootState()
          Factory method for root state.
 int read()
          Read a single character.
 int read(char[] cbuf, int off, int len)
          Read characters into a portion of an array.
 boolean ready()
          Tell whether this stream is ready to be read.
 void reset()
          Reset the stream.
protected  void runJacson()
           
 void setConfig(java.lang.String configName)
          Store the name of the used Jacson configuration.
protected  void setupJacson()
          Setup the Jacson to actually proceed.
 long skip(long n)
          Skip characters.
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WRITE_END_DEAD

public static final java.lang.String WRITE_END_DEAD
XXX Message of PipedReader

See Also:
Constant Field Values

PIPE_BROKEN

public static final java.lang.String PIPE_BROKEN
See Also:
Constant Field Values

jacson

protected Jacson jacson
Embedded worker Jacson


rootState

protected JacsonState rootState
The state used by this Jacson


reader

protected java.io.Reader reader
The embedded reader


pWriter

protected java.io.PipedWriter pWriter
The piped writer Jacson writes into


configName

protected java.lang.String configName
The name of the configuration in filesystem

Constructor Detail

JacsonReader

public JacsonReader(java.io.Reader reader)
             throws JacsonConfigException,
                    java.io.IOException
Create a new Reader with a prescribed configuration.

Parameters:
reader - The reader providing Jacson input.

JacsonReader

public JacsonReader(java.io.Reader reader,
                    java.lang.String configName)
             throws JacsonConfigException,
                    java.io.IOException
Create a new reader with prescribed input and configuration

Parameters:
reader - The reader providing Jacson input.
configName - Name of Jacson configuration file
Method Detail

setConfig

public void setConfig(java.lang.String configName)
Store the name of the used Jacson configuration.

Parameters:
configName - Name of Jacson configuration file

setupJacson

protected void setupJacson()
                    throws java.io.IOException
Setup the Jacson to actually proceed. This spawns a thread in which the Jacson works to feed the PipedReader from behind with output data.

Throws:
java.io.IOException

obtainRootState

protected JacsonState obtainRootState()
Factory method for root state. Override in subclasses.


runJacson

protected void runJacson()

read

public int read()
         throws java.io.IOException
Read a single character.

Throws:
java.io.IOException - If an I/O error occurs

read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Read characters into a portion of an array.

Throws:
java.io.IOException - If an I/O error occurs

skip

public long skip(long n)
          throws java.io.IOException
Skip characters.

Throws:
java.io.IOException - If an I/O error occurs

ready

public boolean ready()
              throws java.io.IOException
Tell whether this stream is ready to be read.

Throws:
java.io.IOException - If an I/O error occurs

markSupported

public boolean markSupported()
Tell whether this stream supports the mark() operation.


mark

public void mark(int readAheadLimit)
          throws java.io.IOException
Mark the present position in the stream.

Throws:
java.io.IOException - If an I/O error occurs

reset

public void reset()
           throws java.io.IOException
Reset the stream.

Throws:
java.io.IOException - If an I/O error occurs

close

public void close()
           throws java.io.IOException
Close the stream.

Throws:
java.io.IOException - If an I/O error occurs

isIgnorableException

protected static boolean isIgnorableException(java.io.IOException io)
Check for pipe exceptions which are allowed in my context. XXX This depends on the actual message in the exception and might depend on JDK. XXX Maybe the JDK Pipe"Pair" is not what we need!

Parameters:
io - The Exception to inspect.

Spieleck

Copyleft 2002 spieleck.de.