home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / awt / print / PrinterCapabilities.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.6 KB  |  140 lines

  1. package sun.awt.print;
  2.  
  3. public final class PrinterCapabilities implements Cloneable {
  4.    public static final int COLOR = 1;
  5.    public static final int DUPLEX = 2;
  6.    public static final int MEDIA = 4;
  7.    private final String printerName;
  8.    private long capabilities;
  9.    private int[] sizes;
  10.    private Object userData;
  11.  
  12.    public PrinterCapabilities(String var1) {
  13.       if (var1 == null) {
  14.          throw new IllegalArgumentException("printerName cannot be null");
  15.       } else {
  16.          this.printerName = var1;
  17.       }
  18.    }
  19.  
  20.    public PrinterCapabilities(String var1, long var2, int[] var4, Object var5) {
  21.       this(var1);
  22.       this.setCapabilities(var2);
  23.       this.setSizes(var4);
  24.       this.setUserData(var5);
  25.    }
  26.  
  27.    public PrinterCapabilities(PrinterCapabilities var1) {
  28.       this.printerName = var1.printerName;
  29.       this.capabilities = var1.capabilities;
  30.       this.sizes = var1.sizes;
  31.       this.userData = var1.userData;
  32.    }
  33.  
  34.    public Object clone() {
  35.       try {
  36.          return super.clone();
  37.       } catch (CloneNotSupportedException var2) {
  38.          throw new InternalError();
  39.       }
  40.    }
  41.  
  42.    public void set(PrinterCapabilities var1) {
  43.       if (!this.printerName.equals(var1.printerName)) {
  44.          throw new IllegalArgumentException("setting capabilities for different printers");
  45.       } else {
  46.          this.capabilities = var1.capabilities;
  47.          this.sizes = var1.sizes;
  48.       }
  49.    }
  50.  
  51.    public String getPrinterName() {
  52.       return this.printerName;
  53.    }
  54.  
  55.    public long getCapabilities() {
  56.       return this.capabilities;
  57.    }
  58.  
  59.    public void setCapabilities(long var1) {
  60.       if ((var1 & -8L) != 0L) {
  61.          throw new IllegalArgumentException("invalid value for capabilities");
  62.       } else {
  63.          this.capabilities = var1;
  64.          if ((var1 & 4L) == 0L) {
  65.             this.sizes = null;
  66.          }
  67.  
  68.       }
  69.    }
  70.  
  71.    public int[] getSizes() {
  72.       return this.sizes != null ? (int[])this.sizes.clone() : null;
  73.    }
  74.  
  75.    public void setSizes(int[] var1) {
  76.       if (var1 != null || (this.capabilities & 4L) != 0L) {
  77.          if ((this.capabilities & 4L) == 0L) {
  78.             throw new IllegalStateException("sizes cannot be set if printer does not enumerate media types");
  79.          } else if (var1 == null) {
  80.             throw new IllegalArgumentException("sizes cannot be null");
  81.          } else {
  82.             this.sizes = (int[])var1.clone();
  83.          }
  84.       }
  85.    }
  86.  
  87.    public Object getUserData() {
  88.       return this.userData;
  89.    }
  90.  
  91.    public void setUserData(Object var1) {
  92.       this.userData = var1;
  93.    }
  94.  
  95.    public String toString() {
  96.       String var1 = this.printerName + " (";
  97.       boolean var2 = true;
  98.       if ((this.capabilities & 1L) != 0L) {
  99.          var2 = false;
  100.          var1 = var1 + "COLOR";
  101.       }
  102.  
  103.       if ((this.capabilities & 2L) != 0L) {
  104.          if (var2) {
  105.             var2 = false;
  106.          } else {
  107.             var1 = var1 + ",";
  108.          }
  109.  
  110.          var1 = var1 + "DUPLEX";
  111.       }
  112.  
  113.       if ((this.capabilities & 4L) != 0L) {
  114.          if (var2) {
  115.             var2 = false;
  116.          } else {
  117.             var1 = var1 + ",";
  118.          }
  119.  
  120.          var1 = var1 + "MEDIA=[";
  121.          boolean var3 = true;
  122.  
  123.          for(int var4 = 0; var4 < this.sizes.length; ++var4) {
  124.             if (var3) {
  125.                var3 = false;
  126.             } else {
  127.                var1 = var1 + ",";
  128.             }
  129.  
  130.             var1 = var1 + PrintControl.SIZES[this.sizes[var4]].toString();
  131.          }
  132.  
  133.          var1 = var1 + "]";
  134.       }
  135.  
  136.       var1 = var1 + ")";
  137.       return var1;
  138.    }
  139. }
  140.