net.socialchange.doctype
Class DoctypeChangerStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by net.socialchange.doctype.DoctypeChangerStream
All Implemented Interfaces:
java.io.Closeable

public final class DoctypeChangerStream
extends java.io.FilterInputStream

This class adds, removes or otherwise modifies a DOCTYPE declaration to an incoming XML document.

For examples of how to use this, see the package overview.

Version:
$Revision: 1.6 $ $Date: 2002/04/15 01:02:03 $
Author:
Simon St.Laurent, Nigel Whitaker, Jeff Turner

Field Summary
protected  boolean docStarted
           
protected  Doctype doctype
           
protected  DoctypeGenerator generator
           
protected  boolean inComment
           
protected  java.lang.StringBuffer myBuffer
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
DoctypeChangerStream(java.io.InputStream in)
          Constructor.
 
Method Summary
protected  void addDocType()
          Add the DOCTYPE declaration to the buffer, from which it will be read in subsequent read() operations.
protected  int feedFromInternalBuffer()
           
 Doctype getDoctype()
          Get the Doctype set for the parsed stream.
 int read()
           
 int read(byte[] text, int offset, int length)
           
 void setGenerator(DoctypeGenerator generator)
          Set the Generator which will determine the policy for what to do with the DOCTYPE declaration.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doctype

protected Doctype doctype

generator

protected DoctypeGenerator generator

docStarted

protected boolean docStarted

inComment

protected boolean inComment

myBuffer

protected java.lang.StringBuffer myBuffer
Constructor Detail

DoctypeChangerStream

public DoctypeChangerStream(java.io.InputStream in)
Constructor.

Parameters:
in - The InputStream which will return XML/SGML.
Method Detail

setGenerator

public void setGenerator(DoctypeGenerator generator)
Set the Generator which will determine the policy for what to do with the DOCTYPE declaration. See the package overview for more details.


getDoctype

public Doctype getDoctype()
Get the Doctype set for the parsed stream. If no DOCTYPE declaration was set, this will be null. Likewise if you call this before doing the parse.


read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] text,
                int offset,
                int length)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

addDocType

protected void addDocType()
Add the DOCTYPE declaration to the buffer, from which it will be read in subsequent read() operations. We add some line separators here for readability.


feedFromInternalBuffer

protected int feedFromInternalBuffer()


Copyright ? 2001 Social Change Online. All Rights Reserved.