jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
changeset 18115 dbd9791b69d2
parent 13048 82534e9c5cc7
child 18752 2a4f599c6bff
equal deleted inserted replaced
18114:8b16a9643b24 18115:dbd9791b69d2
   360      * can save several seconds if you know all you want is a particular
   360      * can save several seconds if you know all you want is a particular
   361      * printer, to ask for that printer rather than retrieving all printers.
   361      * printer, to ask for that printer rather than retrieving all printers.
   362      */
   362      */
   363     private PrintService getServiceByName(PrinterName nameAttr) {
   363     private PrintService getServiceByName(PrinterName nameAttr) {
   364         String name = nameAttr.getValue();
   364         String name = nameAttr.getValue();
   365         PrintService printer = null;
       
   366         if (name == null || name.equals("") || !checkPrinterName(name)) {
   365         if (name == null || name.equals("") || !checkPrinterName(name)) {
   367             return null;
   366             return null;
   368         }
   367         }
       
   368         /* check is all printers are already available */
       
   369         if (printServices != null) {
       
   370             for (PrintService printService : printServices) {
       
   371                 if (printService.getName().equals(name)) {
       
   372                     return printService;
       
   373                 }
       
   374             }
       
   375         }
       
   376         /* take CUPS into account first */
       
   377         if (CUPSPrinter.isCupsRunning()) {
       
   378             try {
       
   379                 return new IPPPrintService(name,
       
   380                                            new URL("http://"+
       
   381                                                    CUPSPrinter.getServer()+":"+
       
   382                                                    CUPSPrinter.getPort()+"/"+
       
   383                                                    name));
       
   384             } catch (Exception e) {
       
   385                 IPPPrintService.debug_println(debugPrefix+
       
   386                                               " getServiceByName Exception "+
       
   387                                               e);
       
   388             }
       
   389         }
       
   390         /* fallback if nothing not having a printer at this point */
       
   391         PrintService printer = null;
   369         if (isMac() || isSysV()) {
   392         if (isMac() || isSysV()) {
   370             printer = getNamedPrinterNameSysV(name);
   393             printer = getNamedPrinterNameSysV(name);
   371         } else {
   394         } else {
   372             printer = getNamedPrinterNameBSD(name);
   395             printer = getNamedPrinterNameBSD(name);
   373         }
   396         }