jaxws/src/share/jaxws_classes/javax/xml/bind/util/JAXBSource.java
changeset 19645 36f707905f2b
parent 12009 4abb694f273a
child 25840 c2002453eec3
equal deleted inserted replaced
19257:30a1d677a20c 19645:36f707905f2b
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    39 
    39 
    40 import javax.xml.bind.JAXBContext;
    40 import javax.xml.bind.JAXBContext;
    41 import javax.xml.bind.JAXBException;
    41 import javax.xml.bind.JAXBException;
    42 import javax.xml.bind.Marshaller;
    42 import javax.xml.bind.Marshaller;
    43 import javax.xml.transform.sax.SAXSource;
    43 import javax.xml.transform.sax.SAXSource;
       
    44 import org.xml.sax.XMLFilter;
    44 
    45 
    45 /**
    46 /**
    46  * JAXP {@link javax.xml.transform.Source} implementation
    47  * JAXP {@link javax.xml.transform.Source} implementation
    47  * that marshals a JAXB-generated object.
    48  * that marshals a JAXB-generated object.
    48  *
    49  *
   208         }
   209         }
   209 
   210 
   210         // SAX allows ContentHandler to be changed during the parsing,
   211         // SAX allows ContentHandler to be changed during the parsing,
   211         // but JAXB doesn't. So this repeater will sit between those
   212         // but JAXB doesn't. So this repeater will sit between those
   212         // two components.
   213         // two components.
   213         private XMLFilterImpl repeater = new XMLFilterImpl();
   214         private XMLFilter repeater = new XMLFilterImpl();
   214 
   215 
   215         public void setContentHandler(ContentHandler handler) {
   216         public void setContentHandler(ContentHandler handler) {
   216             repeater.setContentHandler(handler);
   217             repeater.setContentHandler(handler);
   217         }
   218         }
   218         public ContentHandler getContentHandler() {
   219         public ContentHandler getContentHandler() {
   238         public void parse() throws SAXException {
   239         public void parse() throws SAXException {
   239             // parses a content object by using the given marshaller
   240             // parses a content object by using the given marshaller
   240             // SAX events will be sent to the repeater, and the repeater
   241             // SAX events will be sent to the repeater, and the repeater
   241             // will further forward it to an appropriate component.
   242             // will further forward it to an appropriate component.
   242             try {
   243             try {
   243                 marshaller.marshal( contentObject, repeater );
   244                 marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
   244             } catch( JAXBException e ) {
   245             } catch( JAXBException e ) {
   245                 // wrap it to a SAXException
   246                 // wrap it to a SAXException
   246                 SAXParseException se =
   247                 SAXParseException se =
   247                     new SAXParseException( e.getMessage(),
   248                     new SAXParseException( e.getMessage(),
   248                         null, null, -1, -1, e );
   249                         null, null, -1, -1, e );