/* * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. */ package com.sun.xml.internal.org.jvnet.fastinfoset.sax; import java.io.IOException; import java.io.InputStream; import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetException; import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetParser; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.ext.DeclHandler; import org.xml.sax.ext.LexicalHandler; /** * Interface for reading an Fast Infoset document using callbacks. * *
FastInfosetReader is the interface that a Fast Infoset parser's * SAX2 driver must implement. This interface allows an application to * to register Fast Infoset specific event handlers for encoding algorithms.
* *The reception of encoding algorithm events is determined by * the registration of: *
The reporting of element content events for built-in algorithms * is determimed by the following: *
The reporting of element content events for application-defined algorithms * is determimed by the following: *
The reporting of attribute values for encoding algorithms is achieved using * {@link EncodingAlgorithmAttributes} that extends {@link org.xml.sax.Attributes}. * The registered ContentHandler may cast the attr paramter of the * {@link org.xml.sax.ContentHandler#startElement(String, String, String, org.xml.sax.Attributes)} * to the EncodingAlgorithmAttributes interface to access to encoding algorithm information. *
* *The reporting of attribute values for built-in algorithms * is determimed by the following: *
The reporting of attribute values for application-defined algorithms * is determimed by the following: *
byte[]
,
* using {@link EncodingAlgorithmAttributes#getAlgorithmData(int)};
* otherwiseThe application can use this method to instruct the Fast Infoset * reader to begin parsing a fast infoset document from a byte stream.
* *Applications may not invoke this method while a parse is in progress * (they should create a new XMLReader instead for each nested XML document). * Once a parse is complete, an application may reuse the same * FastInfosetReader object, possibly with a different byte stream.
* *During the parse, the FastInfosetReader will provide information about * the fast infoset document through the registered event handlers.
* *
This method is synchronous: it will not return until parsing has ended. * If a client application wants to terminate parsing early, it should throw * an exception.
* * @param s The byte stream to parse from. */ public void parse(InputStream s) throws IOException, FastInfosetException, SAXException; /** * Allow an application to register a lexical handler. * *
Applications may register a new or different handler in the * middle of a parse, and the SAX parser must begin using the new * handler immediately.
* * @param handler The lexical handler. * @see #getLexicalHandler */ public void setLexicalHandler(LexicalHandler handler); /** * Return the current lexical handler. * * @return The current lexical handler, or null if none * has been registered. * @see #setLexicalHandler */ public LexicalHandler getLexicalHandler(); /** * Allow an application to register a DTD declaration handler. * *Applications may register a new or different handler in the * middle of a parse, and the SAX parser must begin using the new * handler immediately.
* * @param handler The DTD declaration handler. * @see #getLexicalHandler */ public void setDeclHandler(DeclHandler handler); /** * Return the current DTD declaration handler. * * @return The current DTD declaration handler, or null if none * has been registered. * @see #setLexicalHandler */ public DeclHandler getDeclHandler(); /** * Allow an application to register an encoding algorithm handler. * *Applications may register a new or different handler in the * middle of a parse, and the SAX parser must begin using the new * handler immediately.
* * @param handler The encoding algorithm handler. * @see #getEncodingAlgorithmContentHandler */ public void setEncodingAlgorithmContentHandler(EncodingAlgorithmContentHandler handler); /** * Return the current encoding algorithm handler. * * @return The current encoding algorithm handler, or null if none * has been registered. * @see #setEncodingAlgorithmContentHandler */ public EncodingAlgorithmContentHandler getEncodingAlgorithmContentHandler(); /** * Allow an application to register a primitive type handler. * *Applications may register a new or different handler in the * middle of a parse, and the SAX parser must begin using the new * handler immediately.
* * @param handler The primitive type handler. * @see #getPrimitiveTypeContentHandler */ public void setPrimitiveTypeContentHandler(PrimitiveTypeContentHandler handler); /** * Return the current primitive type handler. * * @return The current primitive type handler, or null if none * has been registered. * @see #setPrimitiveTypeContentHandler */ public PrimitiveTypeContentHandler getPrimitiveTypeContentHandler(); }