org.cups4j
Class CupsClient

java.lang.Object
  extended by org.cups4j.CupsClient

public class CupsClient
extends java.lang.Object

Main Client for accessing CUPS features like

- get printers

- print documents

- get job attributes

- ...


Field Summary
static java.lang.String DEFAULT_HOST
           
static int DEFAULT_PORT
           
static java.lang.String DEFAULT_USER
           
 
Constructor Summary
CupsClient()
          Creates a CupsClient for localhost port 631 with user anonymous
CupsClient(java.lang.String host, int port)
          Creates a CupsClient for provided host and port with user anonymous
CupsClient(java.lang.String host, int port, java.lang.String userName)
          Creates a CupsClient for provided host, port and user
 
Method Summary
 boolean cancelJob(int jobID)
          Cancel the job with the provided jobID on the current host wit current user
 boolean cancelJob(java.lang.String hostname, java.lang.String userName, int jobID)
          Cancel the job with the provided jobID, hostname for provided userName
 CupsPrinter getDefaultPrinter()
          Returns default printer
 PrintJobAttributes getJobAttributes(int jobID)
          Returns job attributes for the job associated with the provided jobID
 PrintJobAttributes getJobAttributes(java.lang.String userName, int jobID)
          Returns job attributes for the job associated with the provided jobID and user name
 java.util.List<PrintJobAttributes> getJobs(CupsPrinter printer, WhichJobsEnum whichJobs, java.lang.String userName, boolean myJobs)
          Returns all jobs for given printer and user Name Currently all Jobs on the server are returned by this method.
 CupsPrinter getPrinter(java.net.URL printerURL)
          Returns the printer for the provided URL
 java.util.List<CupsPrinter> getPrinters()
          Returns all available printers
 boolean holdJob(int jobID)
          Hold the job with the provided jobID on the current host wit current set user
 boolean holdJob(java.lang.String hostname, java.lang.String userName, int jobID)
          Hold the job with the provided jobID, hostname for provided userName
 boolean moveJob(int jobID, java.lang.String userName, CupsPrinter currentPrinter, CupsPrinter targetPrinter)
          Moves the print job with job ID jobID from currentPrinter to targetPrinter
 boolean releaseJob(int jobID)
          Release the held job with the provided jobID on the current host wit current set user
 boolean releaseJob(java.lang.String hostname, java.lang.String userName, int jobID)
          Release the job with the provided jobID, hostname for provided userName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOST

public static final java.lang.String DEFAULT_HOST
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_USER

public static final java.lang.String DEFAULT_USER
See Also:
Constant Field Values
Constructor Detail

CupsClient

public CupsClient()
           throws java.lang.Exception
Creates a CupsClient for localhost port 631 with user anonymous

Throws:
java.lang.Exception

CupsClient

public CupsClient(java.lang.String host,
                  int port)
           throws java.lang.Exception
Creates a CupsClient for provided host and port with user anonymous

Parameters:
host -
port -
Throws:
java.lang.Exception

CupsClient

public CupsClient(java.lang.String host,
                  int port,
                  java.lang.String userName)
           throws java.lang.Exception
Creates a CupsClient for provided host, port and user

Parameters:
host -
port -
userName -
Throws:
java.lang.Exception
Method Detail

getPrinters

public java.util.List<CupsPrinter> getPrinters()
                                        throws java.lang.Exception
Returns all available printers

Returns:
List of Printers
Throws:
java.lang.Exception

getDefaultPrinter

public CupsPrinter getDefaultPrinter()
                              throws java.lang.Exception
Returns default printer

Returns:
default printer
Throws:
java.lang.Exception

getPrinter

public CupsPrinter getPrinter(java.net.URL printerURL)
                       throws java.lang.Exception
Returns the printer for the provided URL

Parameters:
printerURL - an URL like http://localhost:631/printers/printername
Returns:
printer
Throws:
java.lang.Exception

getJobAttributes

public PrintJobAttributes getJobAttributes(int jobID)
                                    throws java.lang.Exception
Returns job attributes for the job associated with the provided jobID

Parameters:
jobID -
Returns:
Job attributes
Throws:
java.lang.Exception

getJobAttributes

public PrintJobAttributes getJobAttributes(java.lang.String userName,
                                           int jobID)
                                    throws java.lang.Exception
Returns job attributes for the job associated with the provided jobID and user name

Parameters:
userName -
jobID -
Returns:
Job attributes
Throws:
java.lang.Exception

getJobs

public java.util.List<PrintJobAttributes> getJobs(CupsPrinter printer,
                                                  WhichJobsEnum whichJobs,
                                                  java.lang.String userName,
                                                  boolean myJobs)
                                           throws java.lang.Exception
Returns all jobs for given printer and user Name

Currently all Jobs on the server are returned by this method.

user and printer names are provided in the resulting PrintJobAttributes

Parameters:
printer -
userName -
Returns:
List of job attributes
Throws:
java.lang.Exception

cancelJob

public boolean cancelJob(int jobID)
                  throws java.lang.Exception
Cancel the job with the provided jobID on the current host wit current user

Parameters:
jobID -
Returns:
boolean success
Throws:
java.lang.Exception

cancelJob

public boolean cancelJob(java.lang.String hostname,
                         java.lang.String userName,
                         int jobID)
                  throws java.lang.Exception
Cancel the job with the provided jobID, hostname for provided userName

Parameters:
hostname -
userName -
jobID -
Returns:
boolean success
Throws:
java.lang.Exception

holdJob

public boolean holdJob(int jobID)
                throws java.lang.Exception
Hold the job with the provided jobID on the current host wit current set user

Parameters:
jobID -
Returns:
boolean success
Throws:
java.lang.Exception

holdJob

public boolean holdJob(java.lang.String hostname,
                       java.lang.String userName,
                       int jobID)
                throws java.lang.Exception
Hold the job with the provided jobID, hostname for provided userName

Parameters:
hostname -
userName -
jobID -
Returns:
boolean success
Throws:
java.lang.Exception

releaseJob

public boolean releaseJob(int jobID)
                   throws java.lang.Exception
Release the held job with the provided jobID on the current host wit current set user

Parameters:
jobID -
Returns:
boolean success
Throws:
java.lang.Exception

releaseJob

public boolean releaseJob(java.lang.String hostname,
                          java.lang.String userName,
                          int jobID)
                   throws java.lang.Exception
Release the job with the provided jobID, hostname for provided userName

Parameters:
hostname -
userName -
jobID -
Returns:
boolean success
Throws:
java.lang.Exception

moveJob

public boolean moveJob(int jobID,
                       java.lang.String userName,
                       CupsPrinter currentPrinter,
                       CupsPrinter targetPrinter)
                throws java.lang.Exception
Moves the print job with job ID jobID from currentPrinter to targetPrinter

Parameters:
jobID -
userName -
currentPrinter -
targetPrinter -
Returns:
boolean successs
Throws:
java.lang.Exception


Copyright © 2009 Harald Weyhing. All Rights Reserved.