aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.bind.unmarshaller; aoqi@0: aoqi@0: import javax.xml.bind.Binder; aoqi@0: aoqi@0: import com.sun.xml.internal.bind.v2.runtime.unmarshaller.LocatorEx; aoqi@0: aoqi@0: import org.xml.sax.Attributes; aoqi@0: import org.xml.sax.ContentHandler; aoqi@0: import org.xml.sax.SAXException; aoqi@0: aoqi@0: /** aoqi@0: * Visits a DOM-ish API and generates SAX events. aoqi@0: * aoqi@0: *

aoqi@0: * This interface is not tied to any particular DOM API. aoqi@0: * Used by the {@link Binder}. aoqi@0: * aoqi@0: *

aoqi@0: * Since we are parsing a DOM-ish tree, I don't think this aoqi@0: * scanner itself will ever find an error, so this class aoqi@0: * doesn't have its own error reporting scheme. aoqi@0: * aoqi@0: *

aoqi@0: * This interface MAY NOT be implemented by the generated aoqi@0: * runtime nor the generated code. We may add new methods on aoqi@0: * this interface later. This is to be implemented by the static runtime aoqi@0: * only. aoqi@0: * aoqi@0: * @author aoqi@0: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) aoqi@0: * @since 2.0 aoqi@0: */ aoqi@0: public interface InfosetScanner { aoqi@0: /** aoqi@0: * Parses the given DOM-ish element/document and generates aoqi@0: * SAX events. aoqi@0: * aoqi@0: * @throws ClassCastException aoqi@0: * If the type of the node is not known to this implementation. aoqi@0: * aoqi@0: * @throws SAXException aoqi@0: * If the {@link ContentHandler} throws a {@link SAXException}. aoqi@0: * Do not throw an exception just because the scanner failed aoqi@0: * (if that can happen we need to change the API.) aoqi@0: */ aoqi@0: void scan( XmlNode node ) throws SAXException; aoqi@0: aoqi@0: /** aoqi@0: * Sets the {@link ContentHandler}. aoqi@0: * aoqi@0: * This handler receives the SAX events. aoqi@0: */ aoqi@0: void setContentHandler( ContentHandler handler ); aoqi@0: ContentHandler getContentHandler(); aoqi@0: aoqi@0: /** aoqi@0: * Gets the current element we are parsing. aoqi@0: * aoqi@0: *

aoqi@0: * This method could aoqi@0: * be called from the {@link ContentHandler#startElement(String, String, String, Attributes)} aoqi@0: * or {@link ContentHandler#endElement(String, String, String)}. aoqi@0: * aoqi@0: *

aoqi@0: * Otherwise the behavior of this method is undefined. aoqi@0: * aoqi@0: * @return aoqi@0: * never return null. aoqi@0: */ aoqi@0: XmlNode getCurrentElement(); aoqi@0: aoqi@0: LocatorEx getLocator(); aoqi@0: }