Source Code Cross Referenced for Doc.java in  » 6.0-JDK-Core » print » javax » print » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » print » javax.print 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.print;
027
028        import java.io.InputStream;
029        import java.io.IOException;
030        import java.io.Reader;
031        import java.io.UnsupportedEncodingException;
032
033        import javax.print.attribute.AttributeSet;
034        import javax.print.attribute.DocAttributeSet;
035
036        /**
037         * Interface Doc specifies the interface for an object that supplies one piece 
038         * of print data for a Print Job. "Doc" is a short, easy-to-pronounce term     
039         * that means "a piece of print data." The client passes to the Print Job an
040         * object that implements interface Doc, and the Print Job calls methods on
041         * that object to obtain the print data. The Doc interface lets a Print Job: 
042         * <UL>
043         * <LI>
044         * Determine the format, or "doc flavor" (class {@link DocFlavor DocFlavor}),
045         * in which the print data is available. A doc flavor designates the print 
046         * data format (a MIME type) and the representation class of the object
047         * from which the print data comes. 
048         * <P>
049         * <LI>
050         * Obtain the print data representation object, which is an instance of the  
051         * doc flavor's representation class. The Print Job can then obtain the actual
052         * print data from the representation object.
053         * <P>
054         * <LI>
055         * Obtain the printing attributes that specify additional characteristics of  
056         * the doc or that specify processing instructions to be applied to the doc. 
057         * Printing attributes are defined in package {@link javax.print.attribute 
058         * javax.print.attribute}. The doc returns its printing attributes stored in 
059         * an {@link javax.print.attribute.DocAttributeSet javax.print.attribute.DocAttributeSet}. 
060         * </UL>
061         * <P>
062         * Each method in an implementation of interface Doc is permitted always to 
063         * return the same object each time the method is called.
064         * This has implications 
065         * for a Print Job or other caller of a doc object whose print data 
066         * representation object "consumes" the print data as the caller obtains the 
067         * print data, such as a print data representation object which is a stream. 
068         * Once the Print Job has called {@link #getPrintData() 
069         * <CODE>getPrintData()</CODE>} and obtained the stream, any further calls to 
070         * {@link #getPrintData() <CODE>getPrintData()</CODE>} will return the same 
071         * stream object upon which reading may already be in progress, <I>not</I> a new 
072         * stream object that will re-read the print data from the beginning. Specifying 
073         * a doc object to behave this way simplifies the implementation of doc objects, 
074         * and is justified on the grounds that a particular doc is intended to convey 
075         * print data only to one Print Job, not to several different Print Jobs. (To 
076         * convey the same print data to several different Print Jobs, you have to 
077         * create several different doc objects on top of the same print data source.) 
078         * <P>
079         * Interface Doc affords considerable implementation flexibility. The print data 
080         * might already be in existence when the doc object is constructed. In this 
081         * case the objects returned by the doc's methods can be supplied to the doc's 
082         * constructor, be stored in the doc ahead of time, and simply be returned when 
083         * called for. Alternatively, the print data might not exist yet when the doc 
084         * object is constructed. In this case the doc object might provide a "lazy" 
085         * implementation that generates the print data representation object (and/or 
086         * the print data) only when the Print Job calls for it (when the Print Job 
087         * calls the {@link #getPrintData() <CODE>getPrintData()</CODE>} method). 
088         * <P>
089         * There is no restriction on the number of client threads that may be 
090         * simultaneously accessing the same doc. Therefore, all implementations of 
091         * interface Doc must be designed to be multiple thread safe. 
092         * <p>
093         * However there can only be one consumer of the print data obtained from a
094         * Doc.
095         * <p>
096         * If print data is obtained from the client as a stream, by calling Doc's
097         * <code>getReaderForText()</code> or <code>getStreamForBytes()</code>
098         * methods, or because the print data source is already an InputStream or
099         * Reader, then the print service should always close these streams for the
100         * client on all job completion conditions. With the following caveat.
101         * If the print data is itself a stream, the service will always close it.
102         * If the print data is otherwise something that can be requested as a stream,
103         * the service will only close the stream if it has obtained the stream before
104         * terminating. That is, just because a print service might request data as
105         * a stream does not mean that it will, with the implications that Doc
106         * implementors which rely on the service to close them should create such
107         * streams only in response to a request from the service.
108         * <P>
109         * <HR>
110         */
111        public interface Doc {
112
113            /**
114             * Determines the doc flavor in which this doc object will supply its
115             * piece of print data. 
116             *
117             * @return  Doc flavor.
118             */
119            public DocFlavor getDocFlavor();
120
121            /**
122             * Obtains the print data representation object that contains this doc 
123             * object's piece of print data in the format corresponding to the
124             * supported doc flavor.
125             * The <CODE>getPrintData()</CODE> method returns an instance of 
126             * the representation class whose name is given by <CODE>{@link 
127             * #getDocFlavor() getDocFlavor()}.{@link 
128             * DocFlavor#getRepresentationClassName() 
129             * getRepresentationClassName()}</CODE>, and the return value can be cast 
130             * from class Object to that representation class. 
131             *
132             * @return  Print data representation object. 
133             *
134             * @exception  IOException
135             *     Thrown if the representation class is a stream and there was an I/O 
136             *     error while constructing the stream. 
137             */
138            public Object getPrintData() throws IOException;
139
140            /**
141             * Obtains the set of printing attributes for this doc object. If the 
142             * returned attribute set includes an instance of a particular attribute 
143             * <I>X,</I> the printer must use that attribute value for this doc, 
144             * overriding any value of attribute <I>X</I> in the job's attribute set. 
145             * If the returned attribute set does not include an instance 
146             * of a particular attribute <I>X</I> or if null is returned, the printer 
147             * must consult the job's attribute set to obtain the value for 
148             * attribute <I>X,</I> and if not found there, the printer must use an 
149             * implementation-dependent default value. The returned attribute set is 
150             * unmodifiable. 
151             *
152             * @return  Unmodifiable set of printing attributes for this doc, or null
153             *          to obtain all attribute values from the job's attribute 
154             *          set. 
155             */
156            public DocAttributeSet getAttributes();
157
158            /**
159             * Obtains a reader for extracting character print data from this doc.
160             * The Doc implementation is required to support this method if the 
161             * DocFlavor has one of the following print data representation classes,
162             * and return null otherwise:
163             * <UL>
164             * <LI> char[]
165             * <LI> java.lang.String
166             * <LI> java.io.Reader
167             * </UL>
168             * The doc's print data representation object is used to construct and
169             * return a Reader for reading the print data as a stream of characters
170             * from the print data representation object.
171             * However, if the print data representation object is itself a Reader,
172             * then the print data representation object is simply returned.
173             * <P>
174             * @return  Reader for reading the print data characters from this doc.
175             *          If a reader cannot be provided because this doc does not meet
176             *          the criteria stated above, null is returned. 
177             *
178             * @exception  IOException
179             *     Thrown if there was an I/O error while creating the reader.
180             */
181            public Reader getReaderForText() throws IOException;
182
183            /**
184             * Obtains an input stream for extracting byte print data from this
185             * doc.  The Doc implementation is required to support this method if
186             * the DocFlavor has one of the following print data representation
187             * classes, and return null otherwise:
188             * <UL>
189             * <LI> byte[]
190             * <LI> java.io.InputStream
191             * </UL>
192             * This doc's print data representation object is obtained, then an input 
193             * stream for reading the print data from the print data representation 
194             * object as a stream of bytes is created and returned. However, if the 
195             * print data representation object is itself an input stream, then the 
196             * print data representation object is simply returned. 
197             * <P>
198             * @return  Input stream for reading the print data bytes from this doc. If
199             *          an input stream cannot be provided because this doc does not 
200             *          meet the criteria stated above, null is returned. 
201             *
202             * @exception  IOException
203             *     Thrown if there was an I/O error while creating the input stream.
204             */
205            public InputStream getStreamForBytes() throws IOException;
206
207        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.