Package org.jibx.runtime.impl
Class StAXReaderFactory
java.lang.Object
org.jibx.runtime.impl.StAXReaderFactory
- All Implemented Interfaces:
IXMLReaderFactory
Factory for creating XMLPull parser instances.
- Version:
- 1.0
- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final XMLInputFactory
Factory used for constructing parser instances.private boolean
Namespace processing state configured on factory.private static final StAXReaderFactory
Singleton instance of class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateReader
(InputStream is, String name, String enc, boolean nsf) Get new XML reader instance for document from input stream.createReader
(Reader rdr, String name, boolean nsf) Get new XML reader instance for document from reader.static StAXReaderFactory
Get instance of factory.recycleReader
(IXMLReader old, InputStream is, String name, String enc) Recycle XML reader instance for new document from input stream.recycleReader
(IXMLReader old, Reader rdr, String name) Recycle XML reader instance for document from reader.private void
setNamespacesState
(boolean nsf) Create new parser instance.
-
Field Details
-
s_instance
Singleton instance of class. -
m_factory
Factory used for constructing parser instances. -
m_isNamespaceEnabled
private boolean m_isNamespaceEnabledNamespace processing state configured on factory.
-
-
Constructor Details
-
StAXReaderFactory
private StAXReaderFactory()Internal constructor.
-
-
Method Details
-
getInstance
Get instance of factory.- Returns:
- factory instance
-
setNamespacesState
Create new parser instance. In order to avoid thread safety issues the caller must have a lock on the factory object.- Parameters:
nsf
- enable namespace processing on parser flag- Throws:
JiBXException
- on error creating parser
-
createReader
public IXMLReader createReader(InputStream is, String name, String enc, boolean nsf) throws JiBXException Description copied from interface:IXMLReaderFactory
Get new XML reader instance for document from input stream.- Specified by:
createReader
in interfaceIXMLReaderFactory
- Parameters:
is
- document input streamname
- document name (null
if unknown)enc
- document character encoding (null
if unknown)nsf
- namespaces enabled flag- Returns:
- new reader instance for document
- Throws:
JiBXException
- on parser configuration error
-
createReader
Description copied from interface:IXMLReaderFactory
Get new XML reader instance for document from reader.- Specified by:
createReader
in interfaceIXMLReaderFactory
- Parameters:
rdr
- document readername
- document name (null
if unknown)nsf
- namespaces enabled flag- Returns:
- new reader instance for document
- Throws:
JiBXException
- on parser configuration error
-
recycleReader
public IXMLReader recycleReader(IXMLReader old, InputStream is, String name, String enc) throws JiBXException Description copied from interface:IXMLReaderFactory
Recycle XML reader instance for new document from input stream. If the supplied reader can be reused it will be configured for the new document and returned; otherwise, a new reader will be created for the document. The namespace enabled state of the returned reader is always the same as that of the supplied reader.- Specified by:
recycleReader
in interfaceIXMLReaderFactory
- Parameters:
old
- reader instance to be recycledis
- document input streamname
- document name (null
if unknown)enc
- document character encoding (null
if unknown)- Returns:
- new reader instance for document
- Throws:
JiBXException
- on parser configuration error
-
recycleReader
Description copied from interface:IXMLReaderFactory
Recycle XML reader instance for document from reader. If the supplied reader can be reused it will be configured for the new document and returned; otherwise, a new reader will be created for the document. The namespace enabled state of the returned reader is always the same as that of the supplied reader.- Specified by:
recycleReader
in interfaceIXMLReaderFactory
- Parameters:
old
- reader instance to be recycledrdr
- document readername
- document name (null
if unknown)- Returns:
- new reader instance for document
- Throws:
JiBXException
- on parser configuration error
-