325N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 325N/A * This code is free software; you can redistribute it and/or modify it 325N/A * under the terms of the GNU General Public License version 2 only, as 325N/A * published by the Free Software Foundation. Oracle designates this 325N/A * particular file as subject to the "Classpath" exception as provided 325N/A * by Oracle in the LICENSE file that accompanied this code. 325N/A * This code is distributed in the hope that it will be useful, but WITHOUT 325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 325N/A * version 2 for more details (a copy is included in the LICENSE file that 325N/A * accompanied this code). 325N/A * You should have received a copy of the GNU General Public License version 325N/A * 2 along with this work; if not, write to the Free Software Foundation, 325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 325N/A * or visit www.oracle.com if you need additional information or have any 325N/A * that marshals a JAXB-generated object. 325N/A * This utility class is useful to combine JAXB with 325N/A * The following example shows how to use JAXB to marshal a document 325N/A * for transformation by XSLT. 325N/A * MyObject o = // get JAXB content tree 325N/A * // jaxbContext is a JAXBContext object from which 'o' is created. 325N/A * JAXBSource source = new JAXBSource( jaxbContext, o ); 325N/A * // set up XSLT transformation 325N/A * TransformerFactory tf = TransformerFactory.newInstance(); 325N/A * Transformer t = tf.newTransformer(new StreamSource("test.xsl")); 325N/A * // run transformation 325N/A * t.transform(source,new StreamResult(System.out)); 325N/A * The fact that JAXBSource derives from SAXSource is an implementation 325N/A * detail. Thus in general applications are strongly discouraged from 325N/A * accessing methods defined on SAXSource. In particular, 325N/A * the setXMLReader and setInputSource methods shall never be called. 325N/A * The XMLReader object obtained by the getXMLReader method shall 325N/A * be used only for parsing the InputSource object returned by 325N/A * the getInputSource method. 325N/A * Similarly the InputSource object obtained by the getInputSource 325N/A * method shall be used only for being parsed by the XMLReader object 325N/A * returned by the getXMLReader. 325N/A * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 325N/A * Creates a new {@link javax.xml.transform.Source} for the given content object. 325N/A * JAXBContext that was used to create 325N/A * <code>contentObject</code>. This context is used 325N/A * to create a new instance of marshaller and must not be null. 325N/A * An instance of a JAXB-generated class, which will be 325N/A * used as a {@link javax.xml.transform.Source} (by marshalling it into XML). It must 325N/A * @throws JAXBException if an error is encountered while creating the 325N/A * JAXBSource or if either of the parameters are null. 325N/A * Creates a new {@link javax.xml.transform.Source} for the given content object. 325N/A * A marshaller instance that will be used to marshal 325N/A * <code>contentObject</code> into XML. This must be 325N/A * created from a JAXBContext that was used to build 325N/A * <code>contentObject</code> and must not be null. 325N/A * An instance of a JAXB-generated class, which will be 325N/A * used as a {@link javax.xml.transform.Source} (by marshalling it into XML). It must 325N/A * @throws JAXBException if an error is encountered while creating the 325N/A * JAXBSource or if either of the parameters are null. 325N/A // pass a dummy InputSource. We don't care 325N/A // this object will pretend as an XMLReader. 325N/A // no matter what parameter is specified to the parse method, 325N/A // it just parse the contentObject. 325N/A // we will store this value but never use it by ourselves. 325N/A // SAX allows ContentHandler to be changed during the parsing, 325N/A // but JAXB doesn't. So this repeater will sit between those 325N/A // parses a content object by using the given marshaller 325N/A // SAX events will be sent to the repeater, and the repeater 325N/A // will further forward it to an appropriate component. 325N/A // wrap it to a SAXException 325N/A // if the consumer sets an error handler, it is our responsibility 325N/A // this is a fatal error. Even if the error handler 325N/A // returns, we will abort anyway. 325N/A * Hook to throw exception from the middle of a contructor chained call