org.apache.openjpa.lib.xml
Class DocTypeReader
java.lang.Object
java.io.Reader
org.apache.openjpa.lib.xml.DocTypeReader
- All Implemented Interfaces:
- java.io.Closeable, java.lang.Readable
public class DocTypeReader
- extends java.io.Reader
The DocTypeReader can be used to dynamically include a
DOCTYPE declaration in an XML stream. Often it is
inconvenient to specify a DOCTYPE in XML files -- you many
want the option of parsing the files without reading the DTD, the files
may move around, making placing a DOCTYPE path to the DTD in
them unattractive, and you may have many files, making an in-line include
of the DTD unattractive as well. This class makes
it possible to maintain XML files without any DOCTYPE
declaration, then dynamically include the DOCTYPE information
at runtime.
If the XML stream already contains a DOCTYPE declaration,
the reader will not add an additional one.
The DOCTYPE information given to the reader will be placed
in the XML stream it wraps just before the root element of the document.
Note that all methods other than the various forms of read
apply onto the underlying XML stream and should not be used until the
header and doc type have been read.
- Author:
- Abe White
| Fields inherited from class java.io.Reader |
lock |
|
Constructor Summary |
DocTypeReader(java.io.Reader xml,
java.io.Reader docType)
Construct the reader with an XML stream, and set the
DOCTYPE information to be included. |
| 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 |
DocTypeReader
public DocTypeReader(java.io.Reader xml,
java.io.Reader docType)
throws java.io.IOException
- Construct the reader with an XML stream, and set the
DOCTYPE information to be included. The given
reader should access an input source containing the exact declaration
to include, such as:
<DOCTYPE schedule SYSTEM "schedule.dtd">
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML ...>
<DOCTYPE stock-price [ <ELEMENT symb ... ]>
If the reader is null, no DOCTYPE information will be
included in the stream.
- Throws:
java.io.IOException
read
public int read()
throws java.io.IOException
- Overrides:
read in class java.io.Reader
- Throws:
java.io.IOException
read
public int read(char[] buf)
throws java.io.IOException
- Overrides:
read in class java.io.Reader
- Throws:
java.io.IOException
read
public int read(char[] buf,
int off,
int len)
throws java.io.IOException
- Specified by:
read in class java.io.Reader
- Throws:
java.io.IOException
skip
public long skip(long len)
throws java.io.IOException
- Overrides:
skip in class java.io.Reader
- Throws:
java.io.IOException
ready
public boolean ready()
throws java.io.IOException
- Overrides:
ready in class java.io.Reader
- Throws:
java.io.IOException
markSupported
public boolean markSupported()
- Overrides:
markSupported in class java.io.Reader
mark
public void mark(int readAheadLimit)
throws java.io.IOException
- Overrides:
mark in class java.io.Reader
- Throws:
java.io.IOException
reset
public void reset()
throws java.io.IOException
- Overrides:
reset in class java.io.Reader
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Specified by:
close in interface java.io.Closeable- Specified by:
close in class java.io.Reader
- Throws:
java.io.IOException
Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.