1 /*
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
298 listenedAttributeSets.remove(index);
299 if (attrListeners.isEmpty()) {
300 attrListeners = null;
301 listenedAttributeSets = null;
302 }
303 }
304 }
305 }
306
307 public void print(Doc doc, PrintRequestAttributeSet attributes)
308 throws PrintException {
309
310 synchronized (this) {
311 if (printing) {
312 throw new PrintException("already printing");
313 } else {
314 printing = true;
315 }
316 }
317
318 if ((PrinterIsAcceptingJobs)(service.getAttribute(
319 PrinterIsAcceptingJobs.class)) ==
320 PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) {
321 throw new PrintException("Printer is not accepting job.");
322 }
323
324 this.doc = doc;
325 /* check if the parameters are valid before doing much processing */
326 DocFlavor flavor = doc.getDocFlavor();
327
328 Object data;
329
330 try {
331 data = doc.getPrintData();
332 } catch (IOException e) {
333 notifyEvent(PrintJobEvent.JOB_FAILED);
334 throw new PrintException("can't get print data: " + e.toString());
335 }
336
337 if (data == null) {
338 throw new PrintException("Null print data.");
339 }
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
298 listenedAttributeSets.remove(index);
299 if (attrListeners.isEmpty()) {
300 attrListeners = null;
301 listenedAttributeSets = null;
302 }
303 }
304 }
305 }
306
307 public void print(Doc doc, PrintRequestAttributeSet attributes)
308 throws PrintException {
309
310 synchronized (this) {
311 if (printing) {
312 throw new PrintException("already printing");
313 } else {
314 printing = true;
315 }
316 }
317
318 if ((service.getAttribute(PrinterIsAcceptingJobs.class)) ==
319 PrinterIsAcceptingJobs.NOT_ACCEPTING_JOBS) {
320 throw new PrintException("Printer is not accepting job.");
321 }
322
323 this.doc = doc;
324 /* check if the parameters are valid before doing much processing */
325 DocFlavor flavor = doc.getDocFlavor();
326
327 Object data;
328
329 try {
330 data = doc.getPrintData();
331 } catch (IOException e) {
332 notifyEvent(PrintJobEvent.JOB_FAILED);
333 throw new PrintException("can't get print data: " + e.toString());
334 }
335
336 if (data == null) {
337 throw new PrintException("Null print data.");
338 }
|