public abstract class AbstractXMLFactory extends AbstractSingleReaderWriterFactory
Constructor and Description |
---|
AbstractXMLFactory(javax.xml.namespace.QName rootTag)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkFormat(java.io.Reader reader,
ReadWriteParameterMap parameters)
Tests whether the specified reader provides an XML document and whether the local part of the start tag of it
equals to the local part of
getRootTag() . |
protected boolean |
checkRootTag(javax.xml.stream.events.StartElement startElement)
Implementations can overwrite this method in order to perform further tests on the root tag of the XML document.
|
protected javax.xml.namespace.QName |
getRootTag()
Returns the root tag that was specified in the constructor.
|
checkFormat, createFormatInfo, getFormatInfo
public AbstractXMLFactory(javax.xml.namespace.QName rootTag)
rootTag
- the root tag expected in the target format (which is used in
checkFormat(Reader, ReadWriteParameterMap)
)protected javax.xml.namespace.QName getRootTag()
protected boolean checkRootTag(javax.xml.stream.events.StartElement startElement)
checkFormat()
methods, if the document is a XML document and the local
part of the root tag was equal to the local part of getRootTag()
.
This abstract implementation always returns true
.
startElement
- the event produced by the first start tag in the documenttrue
if the start element is valid for the target format or false
otherwisepublic boolean checkFormat(java.io.Reader reader, ReadWriteParameterMap parameters)
getRootTag()
.
For additional tests, checkRootTag(StartElement)
can overwritten by inherited classes. Note that this
class does not test of the namespace of getRootTag()
matches that of the document root tag, to allow
reading files without namespace definition (e.g. generated by third parts scripts). If an inherited class is
associated with a reader that relies on finding a certain namespace, the namespace should additionally be
tested in checkRootTag(StartElement)
.
reader
- the reader to read the first bytes fromparameters
- the parameters map that would also be used to create a readertrue
if the tested reader may return content in target format or false
if the content is not
in valid target format