GNU Classpath (0.95) | |
Frames | No Frames |
1: /* Doc.java -- 2: Copyright (C) 2004, 2006 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package javax.print; 40: 41: import java.io.IOException; 42: import java.io.InputStream; 43: import java.io.Reader; 44: 45: import javax.print.attribute.DocAttributeSet; 46: 47: /** 48: * <code>Doc</code> specifies the interface for print services how to obtain 49: * the print data and document specific attributes for printing. 50: * <p> 51: * The print data is always passed to a {@link javax.print.DocPrintJob} object 52: * as a <code>Doc</code> object which allows the print services to: 53: * <ul> 54: * <li>Determine the actual document format of the supplied print data. This 55: * is supplied as a {@link javax.print.DocFlavor} object with the MIME type 56: * and the representation class of the print data.</li> 57: * <li>Obtain the print data either in its representation class or depending 58: * on the document format through convenience methods as a 59: * {@link java.io.Reader} or an {@link java.io.InputStream}.</li> 60: * <li>Obtain the document's attribute set specifying the attributes which 61: * apply to this document instance.</li> 62: * </ul> 63: * </p><p> 64: * Every method of a <code>Doc</code> implementation has to return always the 65: * same object on every method call. Therefore if the print job consumes the 66: * print data via a stream or a reader object it can read only once the 67: * supplied print data. Implementations of this interface have to be thread 68: * safe. 69: * </p> 70: * 71: * @author Michael Koch (konqueror@gmx.de) 72: */ 73: public interface Doc 74: { 75: /** 76: * Returns the unmodifiable view of the attributes of this doc object. 77: * <p> 78: * The attributes of this doc's attributes set overrides attributes of 79: * the same category in the print job's attribute set. If an attribute 80: * is not available in this doc's attributes set or <code>null</code> 81: * is returned the attributes of the same category of the print job are 82: * used. 83: * </p> 84: * 85: * @return The unmodifiable attributes set, or <code>null</code>. 86: */ 87: DocAttributeSet getAttributes(); 88: 89: /** 90: * Returns the flavor of this doc objects print data. 91: * 92: * @return The document flavor. 93: */ 94: DocFlavor getDocFlavor(); 95: 96: /** 97: * Returns the print data of this doc object. 98: * <p> 99: * The returned object is an instance as described by the associated 100: * document flavor ({@link DocFlavor#getRepresentationClassName()}) 101: * and can be cast to this representation class. 102: * </p> 103: * 104: * @return The print data in the representation class. 105: * @throws IOException if representation class is a stream and I/O 106: * exception occures. 107: */ 108: Object getPrintData() throws IOException; 109: 110: /** 111: * Returns a <code>Reader</code> object for extracting character print data 112: * from this document. 113: * <p> 114: * This method is supported if the document flavor is of type: 115: * <ul> 116: * <li><code>char[]</code></li> 117: * <li><code>java.lang.String</code></li> 118: * <li><code>java.io.Reader</code></li> 119: * </ul> 120: * otherwise this method returns <code>null</code>. 121: * </p> 122: * 123: * @return The <code>Reader</code> object, or <code>null</code>. 124: * 125: * @throws IOException if an error occurs. 126: */ 127: Reader getReaderForText() throws IOException; 128: 129: /** 130: * Returns an <code>InputStream</code> object for extracting byte print data 131: * from this document. 132: * <p> 133: * This method is supported if the document flavor is of type: 134: * <ul> 135: * <li><code>byte[]</code></li> 136: * <li><code>java.io.InputStream</code></li> 137: * </ul> 138: * otherwise this method returns <code>null</code>. 139: * </p> 140: * 141: * @return The <code>InputStream</code> object, or <code>null</code>. 142: * 143: * @throws IOException if an error occurs. 144: */ 145: InputStream getStreamForBytes() throws IOException;
GNU Classpath (0.95) |