Path: blob/jdk8u272-b10-aarch32-20201026/jaxp/src/javax/xml/stream/util/XMLEventAllocator.java
48795 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.26*/2728package javax.xml.stream.util;2930import javax.xml.stream.events.XMLEvent;31import javax.xml.stream.XMLStreamReader;32import javax.xml.stream.XMLStreamException;3334/**35* This interface defines a class that allows a user to register36* a way to allocate events given an XMLStreamReader. An implementation37* is not required to use the XMLEventFactory implementation but this38* is recommended. The XMLEventAllocator can be set on an XMLInputFactory39* using the property "javax.xml.stream.allocator"40*41* @version 1.042* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.43* @see javax.xml.stream.XMLInputFactory44* @see javax.xml.stream.XMLEventFactory45* @since 1.646*/47public interface XMLEventAllocator {4849/**50* This method creates an instance of the XMLEventAllocator. This51* allows the XMLInputFactory to allocate a new instance per reader.52*/53public XMLEventAllocator newInstance();5455/**56* This method allocates an event given the current57* state of the XMLStreamReader. If this XMLEventAllocator58* does not have a one-to-one mapping between reader states59* and events this method will return null. This method60* must not modify the state of the XMLStreamReader.61* @param reader The XMLStreamReader to allocate from62* @return the event corresponding to the current reader state63*/64public XMLEvent allocate(XMLStreamReader reader)65throws XMLStreamException;6667/**68* This method allocates an event or set of events69* given the current70* state of the XMLStreamReader and adds the event71* or set of events to the72* consumer that was passed in. This method can be used73* to expand or contract reader states into event states.74* This method may modify the state of the XMLStreamReader.75* @param reader The XMLStreamReader to allocate from76* @param consumer The XMLEventConsumer to add to.77*/78public void allocate(XMLStreamReader reader, XMLEventConsumer consumer)79throws XMLStreamException;8081}828384