001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package com.sun.xml.bind.unmarshaller;
037:
038: import javax.xml.bind.Binder;
039:
040: import com.sun.xml.bind.v2.runtime.unmarshaller.LocatorEx;
041:
042: import org.xml.sax.Attributes;
043: import org.xml.sax.ContentHandler;
044: import org.xml.sax.SAXException;
045:
046: /**
047: * Visits a DOM-ish API and generates SAX events.
048: *
049: * <p>
050: * This interface is not tied to any particular DOM API.
051: * Used by the {@link Binder}.
052: *
053: * <p>
054: * Since we are parsing a DOM-ish tree, I don't think this
055: * scanner itself will ever find an error, so this class
056: * doesn't have its own error reporting scheme.
057: *
058: * <p>
059: * This interface <b>MAY NOT</b> be implemented by the generated
060: * runtime nor the generated code. We may add new methods on
061: * this interface later. This is to be implemented by the static runtime
062: * only.
063: *
064: * @author
065: * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
066: * @since 2.0
067: */
068: public interface InfosetScanner<XmlNode> {
069: /**
070: * Parses the given DOM-ish element/document and generates
071: * SAX events.
072: *
073: * @throws ClassCastException
074: * If the type of the node is not known to this implementation.
075: *
076: * @throws SAXException
077: * If the {@link ContentHandler} throws a {@link SAXException}.
078: * Do not throw an exception just because the scanner failed
079: * (if that can happen we need to change the API.)
080: */
081: void scan(XmlNode node) throws SAXException;
082:
083: /**
084: * Sets the {@link ContentHandler}.
085: *
086: * This handler receives the SAX events.
087: */
088: void setContentHandler(ContentHandler handler);
089:
090: ContentHandler getContentHandler();
091:
092: /**
093: * Gets the current element we are parsing.
094: *
095: * <p>
096: * This method could
097: * be called from the {@link ContentHandler#startElement(String, String, String, Attributes)}
098: * or {@link ContentHandler#endElement(String, String, String)}.
099: *
100: * <p>
101: * Otherwise the behavior of this method is undefined.
102: *
103: * @return
104: * never return null.
105: */
106: XmlNode getCurrentElement();
107:
108: LocatorEx getLocator();
109: }
|