0N/A/*
2362N/A * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.print;
0N/A
0N/Aimport java.io.OutputStream;
0N/A
0N/A/**
0N/A * This class extends {@link PrintService} and represents a
0N/A * print service that prints data in different formats to a
0N/A * client-provided output stream.
0N/A * This is principally intended for services where
0N/A * the output format is a document type suitable for viewing
0N/A * or archiving.
0N/A * The output format must be declared as a mime type.
0N/A * This is equivalent to an output document flavor where the
0N/A * representation class is always "java.io.OutputStream"
0N/A * An instance of the <code>StreamPrintService</code> class is
0N/A * obtained from a {@link StreamPrintServiceFactory} instance.
0N/A * <p>
0N/A * Note that a <code>StreamPrintService</code> is different from a
0N/A * <code>PrintService</code>, which supports a
0N/A * {@link javax.print.attribute.standard.Destination Destination}
0N/A * attribute. A <code>StreamPrintService</code> always requires an output
0N/A * stream, whereas a <code>PrintService</code> optionally accepts a
0N/A * <code>Destination</code>. A <code>StreamPrintService</code>
0N/A * has no default destination for its formatted output.
0N/A * Additionally a <code>StreamPrintService</code> is expected to generate
0N/Aoutput in
0N/A * a format useful in other contexts.
0N/A * StreamPrintService's are not expected to support the Destination attribute.
0N/A */
0N/A
0N/Apublic abstract class StreamPrintService implements PrintService {
0N/A
0N/A private OutputStream outStream;
0N/A private boolean disposed = false;
0N/A
0N/A private StreamPrintService() {
0N/A };
0N/A
0N/A /**
0N/A * Constructs a StreamPrintService object.
0N/A *
0N/A * @param out stream to which to send formatted print data.
0N/A */
0N/A protected StreamPrintService(OutputStream out) {
0N/A this.outStream = out;
0N/A }
0N/A
0N/A /**
0N/A * Gets the output stream.
0N/A *
0N/A * @return the stream to which this service will send formatted print data.
0N/A */
0N/A public OutputStream getOutputStream() {
0N/A return outStream;
0N/A }
0N/A
0N/A /**
0N/A * Returns the document format emitted by this print service.
0N/A * Must be in mimetype format, compatible with the mime type
0N/A * components of DocFlavors @see DocFlavor.
0N/A * @return mime type identifying the output format.
0N/A */
0N/A public abstract String getOutputFormat();
0N/A
0N/A /**
0N/A * Disposes this <code>StreamPrintService</code>.
0N/A * If a stream service cannot be re-used, it must be disposed
0N/A * to indicate this. Typically the client will call this method.
0N/A * Services which write data which cannot meaningfully be appended to
0N/A * may also dispose the stream. This does not close the stream. It
0N/A * just marks it as not for further use by this service.
0N/A */
0N/A public void dispose() {
0N/A disposed = true;
0N/A }
0N/A
0N/A /**
0N/A * Returns a <code>boolean</code> indicating whether or not
0N/A * this <code>StreamPrintService</code> has been disposed.
0N/A * If this object has been disposed, will return true.
0N/A * Used by services and client applications to recognize streams
0N/A * to which no further data should be written.
0N/A * @return if this <code>StreamPrintService</code> has been disposed
0N/A */
0N/A public boolean isDisposed() {
0N/A return disposed;
0N/A }
0N/A
0N/A}