| 1 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 2 | // Copyright (c) 2018 Saxonica Limited. |
| 3 | // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. |
| 4 | // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. |
| 6 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 7 | |
| 8 | package net.sf.saxon.event; |
| 9 | |
| 10 | import net.sf.saxon.trans.XPathException; |
| 11 | |
| 12 | import javax.xml.transform.Source; |
| 13 | |
| 14 | /** |
| 15 | * An implementation of the JAXP Source class that supplies a document in the form of a stream |
| 16 | * of push events sent to a Receiver |
| 17 | * |
| 18 | * @since 9.1 |
| 19 | */ |
| 20 | public abstract class EventSource implements Source { |
| 21 | |
| 22 | private String systemId; |
| 23 | |
| 24 | /** |
| 25 | * Set the system identifier for this Source. |
| 26 | * <p>The system identifier is optional if the source does not |
| 27 | * get its data from a URL, but it may still be useful to provide one. |
| 28 | * The application can use a system identifier, for example, to resolve |
| 29 | * relative URIs and to include in error messages and warnings.</p> |
| 30 | * |
| 31 | * @param systemId The system identifier as a URL string. |
| 32 | */ |
| 33 | public void setSystemId(String systemId) { |
| 34 | this.systemId = systemId; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Get the system identifier that was set with setSystemId. |
| 39 | * |
| 40 | * @return The system identifier that was set with setSystemId, or null |
| 41 | * if setSystemId was not called. |
| 42 | */ |
| 43 | public String getSystemId() { |
| 44 | return systemId; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Supply events to a Receiver. |
| 49 | * |
| 50 | * @param out the Receiver to which events will be sent. It is the caller's responsibility |
| 51 | * to initialize the receiver with a PipelineConfiguration, and to call the open() and close() |
| 52 | * methods on the receiver before and after calling this send() method. |
| 53 | * @throws net.sf.saxon.trans.XPathException |
| 54 | * if any error occurs |
| 55 | */ |
| 56 | |
| 57 | public abstract void send(Receiver out) throws XPathException; |
| 58 | } |
| 59 |