Package com.commander4j.util

Source Code of com.commander4j.util.JCUPSPrinterAttributes

package com.commander4j.util;

import org.cups4j.CupsClient;
import org.cups4j.CupsPrinter;
import java.util.List;

public class JCUPSPrinterAttributes
{

  public static String getName(String printerDescription)
  {
    String result = "error";
    try
    {
      List<CupsPrinter> printers = new CupsClient().getPrinters();

      for (CupsPrinter p : printers)
      {
        String temp1 = p.getDescription().toString();
          String temp2 = p.getName();
        String temp3 = printerDescription;
        //Modified to look for match in name or description (feature of OSX Java 7)
        if ((temp1.equals(temp3)) || (temp2.equals(temp3)))
        {
          result = p.getName();
          break;
        }
      }

    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return result;
  }
 
}
TOP

Related Classes of com.commander4j.util.JCUPSPrinterAttributes

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.