78
79 private static ArrayList initListOfFactories() {
80 ArrayList listOfFactories = new ArrayList();
81 getServices().listOfFactories = listOfFactories;
82 return listOfFactories;
83 }
84
85 /**
86 * Locates factories for print services that can be used with
87 * a print job to output a stream of data in the
88 * format specified by {@code outputMimeType}.
89 * <p>
90 * The {@code outputMimeType} parameter describes the document type that
91 * you want to create, whereas the {@code flavor} parameter describes the
92 * format in which the input data will be provided by the application
93 * to the {@code StreamPrintService}.
94 * <p>
95 * Although null is an acceptable value to use in the lookup of stream
96 * printing services, it's typical to search for a particular
97 * desired format, such as Postscript(TM).
98 * <p>
99 * @param flavor of the input document type - null means match all
100 * types.
101 * @param outputMimeType representing the required output format, used to
102 * identify suitable stream printer factories. A value of null means
103 * match all formats.
104 * @return - matching factories for stream print service instance,
105 * empty if no suitable factories could be located.
106 */
107 public static StreamPrintServiceFactory[]
108 lookupStreamPrintServiceFactories(DocFlavor flavor,
109 String outputMimeType) {
110
111 ArrayList list = getFactories(flavor, outputMimeType);
112 return (StreamPrintServiceFactory[])
113 (list.toArray(new StreamPrintServiceFactory[list.size()]));
114 }
115
116 /** Queries the factory for the document format that is emitted
117 * by printers obtained from this factory.
118 *
137 * created from the printer is complete. Doing so earlier may generate
138 * a <code>PrinterException</code> and an event indicating that the
139 * job failed.
140 * <p>
141 * Whereas a <code>PrintService</code> connected to a physical printer
142 * can be reused,
143 * a <code>StreamPrintService</code> connected to a stream cannot.
144 * The underlying <code>StreamPrintService</code> may be disposed by
145 * the print system with
146 * the {@link StreamPrintService#dispose() dispose} method
147 * before returning from the
148 * {@link DocPrintJob#print(Doc, javax.print.attribute.PrintRequestAttributeSet) print}
149 * method of <code>DocPrintJob</code> so that the print system knows
150 * this printer is no longer usable.
151 * This is equivalent to a physical printer going offline - permanently.
152 * Applications may supply a null print stream to create a queryable
153 * service. It is not valid to create a PrintJob for such a stream.
154 * Implementations which allocate resources on construction should examine
155 * the stream and may wish to only allocate resources if the stream is
156 * non-null.
157 * <p>
158 * @param out destination stream for generated output.
159 * @return a PrintService which will generate the format specified by the
160 * DocFlavor supported by this Factory.
161 */
162 public abstract StreamPrintService getPrintService(OutputStream out);
163
164
165 private static ArrayList getAllFactories() {
166 synchronized (StreamPrintServiceFactory.class) {
167
168 ArrayList listOfFactories = getListOfFactories();
169 if (listOfFactories != null) {
170 return listOfFactories;
171 } else {
172 listOfFactories = initListOfFactories();
173 }
174
175 try {
176 java.security.AccessController.doPrivileged(
177 new java.security.PrivilegedExceptionAction() {
|
78
79 private static ArrayList initListOfFactories() {
80 ArrayList listOfFactories = new ArrayList();
81 getServices().listOfFactories = listOfFactories;
82 return listOfFactories;
83 }
84
85 /**
86 * Locates factories for print services that can be used with
87 * a print job to output a stream of data in the
88 * format specified by {@code outputMimeType}.
89 * <p>
90 * The {@code outputMimeType} parameter describes the document type that
91 * you want to create, whereas the {@code flavor} parameter describes the
92 * format in which the input data will be provided by the application
93 * to the {@code StreamPrintService}.
94 * <p>
95 * Although null is an acceptable value to use in the lookup of stream
96 * printing services, it's typical to search for a particular
97 * desired format, such as Postscript(TM).
98 *
99 * @param flavor of the input document type - null means match all
100 * types.
101 * @param outputMimeType representing the required output format, used to
102 * identify suitable stream printer factories. A value of null means
103 * match all formats.
104 * @return - matching factories for stream print service instance,
105 * empty if no suitable factories could be located.
106 */
107 public static StreamPrintServiceFactory[]
108 lookupStreamPrintServiceFactories(DocFlavor flavor,
109 String outputMimeType) {
110
111 ArrayList list = getFactories(flavor, outputMimeType);
112 return (StreamPrintServiceFactory[])
113 (list.toArray(new StreamPrintServiceFactory[list.size()]));
114 }
115
116 /** Queries the factory for the document format that is emitted
117 * by printers obtained from this factory.
118 *
137 * created from the printer is complete. Doing so earlier may generate
138 * a <code>PrinterException</code> and an event indicating that the
139 * job failed.
140 * <p>
141 * Whereas a <code>PrintService</code> connected to a physical printer
142 * can be reused,
143 * a <code>StreamPrintService</code> connected to a stream cannot.
144 * The underlying <code>StreamPrintService</code> may be disposed by
145 * the print system with
146 * the {@link StreamPrintService#dispose() dispose} method
147 * before returning from the
148 * {@link DocPrintJob#print(Doc, javax.print.attribute.PrintRequestAttributeSet) print}
149 * method of <code>DocPrintJob</code> so that the print system knows
150 * this printer is no longer usable.
151 * This is equivalent to a physical printer going offline - permanently.
152 * Applications may supply a null print stream to create a queryable
153 * service. It is not valid to create a PrintJob for such a stream.
154 * Implementations which allocate resources on construction should examine
155 * the stream and may wish to only allocate resources if the stream is
156 * non-null.
157 *
158 * @param out destination stream for generated output.
159 * @return a PrintService which will generate the format specified by the
160 * DocFlavor supported by this Factory.
161 */
162 public abstract StreamPrintService getPrintService(OutputStream out);
163
164
165 private static ArrayList getAllFactories() {
166 synchronized (StreamPrintServiceFactory.class) {
167
168 ArrayList listOfFactories = getListOfFactories();
169 if (listOfFactories != null) {
170 return listOfFactories;
171 } else {
172 listOfFactories = initListOfFactories();
173 }
174
175 try {
176 java.security.AccessController.doPrivileged(
177 new java.security.PrivilegedExceptionAction() {
|