1 /*
   2  * Copyright (c) 2000, 2004, 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
  23  * questions.
  24  */
  25 package javax.print.attribute.standard;
  26 
  27 import javax.print.attribute.Attribute;
  28 import javax.print.attribute.EnumSyntax;
  29 import javax.print.attribute.DocAttribute;
  30 
  31 /**
  32  * Class Compression is a printing attribute class, an enumeration, that
  33  * specifies how print data is compressed. Compression is an attribute of the
  34  * print data (the doc), not of the Print Job. If a Compression attribute is not
  35  * specified for a doc, the printer assumes the doc's print data is uncompressed
  36  * (i.e., the default Compression value is always {@link #NONE
  37  * NONE}).
  38  * <P>
  39  * <B>IPP Compatibility:</B> The category name returned by
  40  * <CODE>getName()</CODE> is the IPP attribute name.  The enumeration's
  41  * integer value is the IPP enum value.  The <code>toString()</code> method
  42  * returns the IPP string representation of the attribute value.
  43  * <P>
  44  *
  45  * @author  Alan Kaminsky
  46  */
  47 public class Compression extends EnumSyntax implements DocAttribute {
  48 
  49     private static final long serialVersionUID = -5716748913324997674L;
  50 
  51     /**
  52      * No compression is used.
  53      */
  54     public static final Compression NONE = new Compression(0);
  55 
  56     /**
  57      * ZIP public domain inflate/deflate compression technology.
  58      */
  59     public static final Compression DEFLATE = new Compression(1);
  60 
  61     /**
  62      * GNU zip compression technology described in
  63      * <A HREF="http://www.ietf.org/rfc/rfc1952.txt">RFC 1952</A>.
  64      */
  65     public static final Compression GZIP = new Compression(2);
  66 
  67     /**
  68      * UNIX compression technology.
  69      */
  70     public static final Compression COMPRESS = new Compression(3);
  71 
  72     /**
  73      * Construct a new compression enumeration value with the given integer
  74      * value.
  75      *
  76      * @param  value  Integer value.
  77      */
  78     protected Compression(int value) {
  79         super(value);
  80     }
  81 
  82 
  83     private static final String[] myStringTable = {"none",
  84                                                    "deflate",
  85                                                    "gzip",
  86                                                    "compress"};
  87 
  88     private static final Compression[] myEnumValueTable = {NONE,
  89                                                            DEFLATE,
  90                                                            GZIP,
  91                                                            COMPRESS};
  92 
  93     /**
  94      * Returns the string table for class Compression.
  95      */
  96     protected String[] getStringTable() {
  97         return (String[])myStringTable.clone();
  98     }
  99 
 100     /**
 101      * Returns the enumeration value table for class Compression.
 102      */
 103     protected EnumSyntax[] getEnumValueTable() {
 104         return (EnumSyntax[])myEnumValueTable.clone();
 105     }
 106 
 107     /**
 108      * Get the printing attribute class which is to be used as the "category"
 109      * for this printing attribute value.
 110      * <P>
 111      * For class Compression and any vendor-defined subclasses, the category is
 112      * class Compression itself.
 113      *
 114      * @return  Printing attribute class (category), an instance of class
 115      *          {@link java.lang.Class java.lang.Class}.
 116      */
 117     public final Class<? extends Attribute> getCategory() {
 118         return Compression.class;
 119     }
 120 
 121     /**
 122      * Get the name of the category of which this attribute value is an
 123      * instance.
 124      * <P>
 125      * For class Compression and any vendor-defined subclasses, the category
 126      * name is <CODE>"compression"</CODE>.
 127      *
 128      * @return  Attribute category name.
 129      */
 130     public final String getName() {
 131         return "compression";
 132     }
 133 
 134 }