|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.xml.encoding.XmlDescriptorDetector
public class XmlDescriptorDetector
Detects the descriptor
of an XML document.
The implementation requires a parser implementing org.xml.sax.ext.Locator2
. This is provided by the Xerces from version 2.0.2 on (please refer to Xerces SAX FAQ for details).
This library does not force a special Xerces version to be used. Maven users may want to add the following dependency to their POM:
POM Dependency
<dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.10.0</version> </dependency>
Note:
Most implementations only provide the version and encoding information if a stream is passed instead of a input source.
Constructor Summary | |
---|---|
XmlDescriptorDetector() Convenience constructor with no delegate that stops parsing after document start event has been detected. |
|
XmlDescriptorDetector(XmlParsingHandler delegate) Default constructor. |
Method Summary | |
---|---|
protected XMLReader |
createParser() Creates and configures a parser instance. |
XmlParsingHandler |
getDelegate() Returns the delegate to fetch additional information from the stream. |
XmlDescriptor |
readDescriptor(InputSource input) Reads the XML descriptor of the file provided by the input source. |
XmlDescriptor |
readDescriptor(InputStream input) Reads the XML descriptor of the file provided by the input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlDescriptorDetector()
public XmlDescriptorDetector(XmlParsingHandler delegate)
Default constructor.
Please consider to throw an {@link AbortException in your content handler delegate to abort the parsing as soon as all information is collected.}
delegate
- the delegate to fetch additional information from the stream.
Method Detail |
---|
public XmlParsingHandler getDelegate()
protected XMLReader createParser() throws SAXException, SAXNotRecognizedException, SAXNotSupportedException
SAXException
- on any problem creating the parser.
SAXNotRecognizedException
- on any problem configuring the parser.
SAXNotSupportedException
- on any problem configuring the parser.
public XmlDescriptor readDescriptor(InputStream input) throws SAXException, IOException
This will only detect XML version and encoding.
Note:
Most implementations only provide the version and encoding information if a stream is passed instead of a input source.
input
- the XML document whose descriptor is to be read.
null
.
SAXException
- on any problem reading the XML document.
IOException
- on any problem reading from the input source.
public XmlDescriptor readDescriptor(InputSource input) throws SAXException, IOException
As soon as all relevant information is read, the paring is aborted.
Note:
Most implementations read the public and system ID from the input source as defaults and return them if no such information can be determined from the input
.
input
- the XML document whose descriptor is to be read.
null
.
SAXException
- on any problem reading the XML document.
IOException
- on any problem reading from the input source.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |