Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/print/StreamPrintService.java
38829 views
/*1* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.print;2627import java.io.OutputStream;2829/**30* This class extends {@link PrintService} and represents a31* print service that prints data in different formats to a32* client-provided output stream.33* This is principally intended for services where34* the output format is a document type suitable for viewing35* or archiving.36* The output format must be declared as a mime type.37* This is equivalent to an output document flavor where the38* representation class is always "java.io.OutputStream"39* An instance of the <code>StreamPrintService</code> class is40* obtained from a {@link StreamPrintServiceFactory} instance.41* <p>42* Note that a <code>StreamPrintService</code> is different from a43* <code>PrintService</code>, which supports a44* {@link javax.print.attribute.standard.Destination Destination}45* attribute. A <code>StreamPrintService</code> always requires an output46* stream, whereas a <code>PrintService</code> optionally accepts a47* <code>Destination</code>. A <code>StreamPrintService</code>48* has no default destination for its formatted output.49* Additionally a <code>StreamPrintService</code> is expected to generate50output in51* a format useful in other contexts.52* StreamPrintService's are not expected to support the Destination attribute.53*/5455public abstract class StreamPrintService implements PrintService {5657private OutputStream outStream;58private boolean disposed = false;5960private StreamPrintService() {61};6263/**64* Constructs a StreamPrintService object.65*66* @param out stream to which to send formatted print data.67*/68protected StreamPrintService(OutputStream out) {69this.outStream = out;70}7172/**73* Gets the output stream.74*75* @return the stream to which this service will send formatted print data.76*/77public OutputStream getOutputStream() {78return outStream;79}8081/**82* Returns the document format emitted by this print service.83* Must be in mimetype format, compatible with the mime type84* components of DocFlavors @see DocFlavor.85* @return mime type identifying the output format.86*/87public abstract String getOutputFormat();8889/**90* Disposes this <code>StreamPrintService</code>.91* If a stream service cannot be re-used, it must be disposed92* to indicate this. Typically the client will call this method.93* Services which write data which cannot meaningfully be appended to94* may also dispose the stream. This does not close the stream. It95* just marks it as not for further use by this service.96*/97public void dispose() {98disposed = true;99}100101/**102* Returns a <code>boolean</code> indicating whether or not103* this <code>StreamPrintService</code> has been disposed.104* If this object has been disposed, will return true.105* Used by services and client applications to recognize streams106* to which no further data should be written.107* @return if this <code>StreamPrintService</code> has been disposed108*/109public boolean isDisposed() {110return disposed;111}112113}114115116