Package org.jboss.staxmapper
Interface XMLMapper
-
public interface XMLMapperAn XML mapper. Allows the creation of extensible streaming XML parsers.- Author:
- David M. Lloyd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classXMLMapper.FactoryA factory for creating an instance ofXMLMapper.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description voiddeparseDocument(XMLContentWriter contentWriter, XMLStreamWriter streamWriter)Deprecated.voiddeparseDocument(XMLElementWriter<?> writer, Object rootObject, XMLStreamWriter streamWriter)Format the element writer's output on to an XML stream writer.voidparseDocument(Object rootObject, XMLStreamReader reader)Parse a document.voidregisterRootAttribute(QName name, XMLAttributeReader<?> reader)Add a known root attribute which can be read byXMLExtendedStreamReader.handleAttribute(Object, int).default <T,N extends Namespace>
voidregisterRootElement(String localName, Set<N> namespaces, Function<N,XMLElementReader<T>> readerFactory)Convenience method that registers a root element associated with a known set of namespaces, whose reader can be created from the specified factory.<T> voidregisterRootElement(QName name, Supplier<XMLElementReader<T>> supplier)Add a known root element which can be read byXMLExtendedStreamReader.handleAny(Object).<T> voidregisterRootElement(QName name, XMLElementReader<T> reader)Add a known root element which can be read byXMLExtendedStreamReader.handleAny(Object).voidunregisterRootAttribute(QName name)Removes apreviously registered root attribute.voidunregisterRootElement(QName name)Removes apreviously registered root element.
-
-
-
Method Detail
-
registerRootElement
<T> void registerRootElement(QName name, XMLElementReader<T> reader)
Add a known root element which can be read byXMLExtendedStreamReader.handleAny(Object).- Parameters:
name- the element namereader- the reader which handles the element
-
registerRootElement
<T> void registerRootElement(QName name, Supplier<XMLElementReader<T>> supplier)
Add a known root element which can be read byXMLExtendedStreamReader.handleAny(Object).- Parameters:
name- the element namesupplier- provider for the reader which handles the element It is recommended that supplier always creates new instance of theXMLElementReaderinstead of caching and returning always same instance. This way unused parsers can get GC-ed when not needed.
-
registerRootElement
default <T,N extends Namespace> void registerRootElement(String localName, Set<N> namespaces, Function<N,XMLElementReader<T>> readerFactory)
Convenience method that registers a root element associated with a known set of namespaces, whose reader can be created from the specified factory.- Type Parameters:
T- the operating type of the readerN- the namespace type- Parameters:
localName- the local name of the known root elementnamespaces- a set of known namespaces for the specified the root elementfactory- a factory for creating an element reader for the specified the root element
-
unregisterRootElement
void unregisterRootElement(QName name)
Removes apreviously registered root element.- Parameters:
name- the element name
-
registerRootAttribute
void registerRootAttribute(QName name, XMLAttributeReader<?> reader)
Add a known root attribute which can be read byXMLExtendedStreamReader.handleAttribute(Object, int).- Parameters:
name- the attribute namereader- the reader which handles the attribute
-
unregisterRootAttribute
void unregisterRootAttribute(QName name)
Removes apreviously registered root attribute.- Parameters:
name- the element name
-
parseDocument
void parseDocument(Object rootObject, XMLStreamReader reader) throws XMLStreamException
Parse a document. The document must have a known, registered root element which can accept the given root object.- Parameters:
rootObject- the root object to send inreader- the reader from which the document should be read- Throws:
XMLStreamException- if an error occurs
-
deparseDocument
void deparseDocument(XMLElementWriter<?> writer, Object rootObject, XMLStreamWriter streamWriter) throws XMLStreamException
Format the element writer's output on to an XML stream writer.- Parameters:
writer- the element writerrootObject- the root object to send instreamWriter- the stream writer- Throws:
XMLStreamException- if an exception occurs
-
deparseDocument
@Deprecated void deparseDocument(XMLContentWriter contentWriter, XMLStreamWriter streamWriter) throws XMLStreamException
Deprecated.Format the content writer's output on to an XML stream writer.- Parameters:
contentWriter- the content writerstreamWriter- the stream writer- Throws:
XMLStreamException- if an exception occurs
-
-