Class XMLEventUtilBase

    • Field Detail

      • logger

        protected static final Logger logger
      • NAMESPACE_AWARE_PROP

        public static final String NAMESPACE_AWARE_PROP
        XMLInputFactory key for configuring namespace awareness
        See Also:
        Constant Field Values
      • REPAIR_NAMESPACE_PROP

        public static final String REPAIR_NAMESPACE_PROP
        XMLOutputFactory key for configuring namespace repairing
        See Also:
        Constant Field Values
    • Method Detail

      • closeReader

        protected void closeReader()
      • getEventFactory

        protected XMLEventFactory getEventFactory()
        Returns a valid XMLEventFactory. Calls createEventFactory() on first invocation to actully create the XMLEventFactory, which is then cached for subsequent reuse.
      • createEventFactory

        protected XMLEventFactory createEventFactory()
        Constructs a new XMLEventFactory, called by getEventFactory the first time an XMLEventFactory is needed.
        Returns:
        a new XMLEventFactory instance
      • startObject

        protected void startObject​(XMLEvent objStartEvent)
                            throws XMLStreamException
        Called when a new object is about to be processed. Subclasses may override this to add additional per-object prologue events to the writer.

        Base class does nothing.

        Parameters:
        objStartEvent - the first event for this object, should not be written to the writer at this point, merely provided for context (will be written by first call to addObjectEvent(javax.xml.stream.events.XMLEvent))
        Throws:
        XMLStreamException
      • addObjectEvent

        protected void addObjectEvent​(XMLEvent objEvent)
                               throws XMLStreamException
        Called to add the given event to the given writer for the current object. Subclasses may override this to alter which events from the input get passed to the output (or to add additional events, manipulate data, read data, etc.).

        Base class calls XMLEventWriter.add(javax.xml.stream.events.XMLEvent) with the given event.

        Parameters:
        objEvent - the next input event to be processed
        Throws:
        XMLStreamException
      • finishObject

        protected void finishObject()
                             throws XMLStreamException
        Called when an current object is finished. Subclasses may override this to add additional per-object epilogue events to the writer.

        Base class does nothing.

        Throws:
        XMLStreamException
      • closeImpl

        protected abstract void closeImpl()
        Does the actual close work for this instance, will only be called once.
      • closeQuietly

        public static void closeQuietly​(XMLEventReader reader)
        Closes an XMLEventReader, swallowing any exceptions that are thrown.
        Parameters:
        reader - XMLEventReader to close, may be null
      • createInputFactory

        public static XMLInputFactory createInputFactory()
        Creates an XMLInputFactory which is namespace aware.
        Returns:
        a new XMLOutputFactory
      • createInputFactory

        public static XMLInputFactory createInputFactory​(boolean namespaceAware)
        Creates an XMLInputFactory which is optionally namespace aware.
        Parameters:
        namespaceAware - whether or not the factory is namespace aware
        Returns:
        a new XMLOutputFactory
      • createOutputFactory

        public static XMLOutputFactory createOutputFactory()
        Creates an XMLOutputFactory which will repair namespaces.
        Returns:
        a new XMLOutputFactory
      • createOutputFactory

        public static XMLOutputFactory createOutputFactory​(boolean repairNamespaces)
        Creates an XMLOutputFactory which will optionally repair namespaces.
        Parameters:
        repairNamespaces - whether or not the factory will repair namespaces
        Returns:
        a new XMLOutputFactory