< prev index next >

src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java

Print this page




   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.IntegerSyntax;
  29 import javax.print.attribute.PrintRequestAttribute;
  30 import javax.print.attribute.PrintJobAttribute;

  31 
  32 /**
  33  * Class JobKOctets is an integer valued printing attribute class that specifies
  34  * the total size of the document(s) in K octets, i.e., in units of 1024 octets
  35  * requested to be processed in the job. The value must be rounded up, so that a
  36  * job between 1 and 1024 octets must be indicated as being 1K octets, 1025 to
  37  * 2048 must be 2K octets, etc. For a multidoc print job (a job with multiple
  38  * documents), the JobKOctets value is computed by adding up the individual
  39  * documents' sizes in octets, then rounding up to the next K octets value.
  40  * <P>
  41  * The JobKOctets attribute describes the size of the job. This attribute is not
  42  * intended to be a counter; it is intended to be useful routing and scheduling
  43  * information if known. The printer may try to compute the JobKOctets
  44  * attribute's value if it is not supplied in the Print Request. Even if the
  45  * client does supply a value for the JobKOctets attribute in the Print Request,
  46  * the printer may choose to change the value if the printer is able to compute
  47  * a value which is more accurate than the client supplied value. The printer
  48  * may be able to determine the correct value for the JobKOctets attribute
  49  * either right at job submission time or at any later point in time.
  50  * <P>
  51  * The JobKOctets value must not include the multiplicative factors contributed
  52  * by the number of copies specified by the {@link Copies Copies} attribute,
  53  * independent of whether the device can process multiple copies without making
  54  * multiple passes over the job or document data and independent of whether the
  55  * output is collated or not. Thus the value is independent of the
  56  * implementation and indicates the size of the document(s) measured in K octets
  57  * independent of the number of copies.
  58  * <P>
  59  * The JobKOctets value must also not include the multiplicative factor due to a
  60  * copies instruction embedded in the document data. If the document data
  61  * actually includes replications of the document data, this value will include
  62  * such replication. In other words, this value is always the size of the source
  63  * document data, rather than a measure of the hardcopy output to be produced.
  64  * <P>



  65  * The size of a doc is computed based on the print data representation class as
  66  * specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as
  67  * shown in the table below.
  68  *
  69  * <table class="striped">
  70  * <caption>Table showing computation of doc sizes</caption>
  71  * <thead>
  72  * <TR>
  73  * <TH>Representation Class</TH>
  74  * <TH>Document Size</TH>
  75  * </TR>
  76  * </thead>
  77  * <tbody>
  78  * <TR>
  79  * <TD>byte[]</TD>
  80  * <TD>Length of the byte array</TD>
  81  * </TR>
  82  * <TR>
  83  * <TD>java.io.InputStream</TD>
  84  * <TD>Number of bytes read from the stream</TD>
  85  * </TR>
  86  * <TR>
  87  * <TD>char[]</TD>
  88  * <TD>Length of the character array x 2</TD>
  89  * </TR>
  90  * <TR>
  91  * <TD>java.lang.String</TD>
  92  * <TD>Length of the string x 2</TD>
  93  * </TR>
  94  * <TR>
  95  * <TD>java.io.Reader</TD>
  96  * <TD>Number of characters read from the stream x 2</TD>
  97  * </TR>
  98  * <TR>
  99  * <TD>java.net.URL</TD>
 100  * <TD>Number of bytes read from the file at the given URL address</TD>
 101  * </TR>
 102  * <TR>
 103  * <TD>java.awt.image.renderable.RenderableImage</TD>
 104  * <TD>Implementation dependent*</TD>
 105  * </TR>
 106  * <TR>
 107  * <TD>java.awt.print.Printable</TD>
 108  * <TD>Implementation dependent*</TD>
 109  * </TR>
 110  * <TR>
 111  * <TD>java.awt.print.Pageable</TD>
 112  * <TD>Implementation dependent*</TD>
 113  * </TR>
 114  * </tbody>
 115  * </TABLE>
 116  * <P>
 117  * * In these cases the Print Service itself generates the print data sent
 118  * to the printer. If the Print Service supports the JobKOctets attribute, for
 119  * these cases the Print Service itself must calculate the size of the print
 120  * data, replacing any JobKOctets value the client specified.
 121  * <P>
 122  * <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
 123  * category name returned by {@code getName()} gives the IPP attribute
 124  * name.
 125  *

 126  * @see JobKOctetsSupported
 127  * @see JobKOctetsProcessed
 128  * @see JobImpressions
 129  * @see JobMediaSheets
 130  *
 131  * @author  Alan Kaminsky
 132  */
 133 public final class JobKOctets   extends IntegerSyntax
 134         implements PrintRequestAttribute, PrintJobAttribute {
 135 



 136     private static final long serialVersionUID = -8959710146498202869L;
 137 
 138     /**
 139      * Construct a new job K octets attribute with the given integer value.
 140      *
 141      * @param  value  Integer value.
 142      *
 143      * @exception  IllegalArgumentException
 144      *  (Unchecked exception) Thrown if {@code value} is less than 0.
 145      */
 146     public JobKOctets(int value) {
 147         super (value, 0, Integer.MAX_VALUE);
 148     }
 149 
 150     /**
 151      * Returns whether this job K octets attribute is equivalent to the passed
 152      * in object. To be equivalent, all of the following conditions must be
 153      * true:
 154      * <OL TYPE=1>
 155      * <LI>
 156      * {@code object} is not null.
 157      * <LI>
 158      * {@code object} is an instance of class JobKOctets.
 159      * <LI>
 160      * This job K octets attribute's value and {@code object}'s value
 161      * are equal.
 162      * </OL>
 163      *
 164      * @param  object  Object to compare to.
 165      *
 166      * @return  True if {@code object} is equivalent to this job K
 167      *          octets attribute, false otherwise.
 168      */
 169     public boolean equals(Object object) {
 170         return super.equals(object) && object instanceof JobKOctets;
 171     }
 172 
 173     /**
 174      * Get the printing attribute class which is to be used as the "category"
 175      * for this printing attribute value.
 176      * <P>
 177      * For class JobKOctets, the category is class JobKOctets itself.

 178      *
 179      * @return  Printing attribute class (category), an instance of class
 180      *          {@link java.lang.Class java.lang.Class}.
 181      */
 182     public final Class<? extends Attribute> getCategory() {
 183         return JobKOctets.class;
 184     }
 185 
 186     /**
 187      * Get the name of the category of which this attribute value is an
 188      * instance.
 189      * <P>
 190      * For class JobKOctets, the category name is {@code "job-k-octets"}.

 191      *
 192      * @return  Attribute category name.
 193      */
 194     public final String getName() {
 195         return "job-k-octets";
 196     }
 197 
 198 }


   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 
  26 package javax.print.attribute.standard;
  27 
  28 import javax.print.attribute.Attribute;
  29 import javax.print.attribute.IntegerSyntax;

  30 import javax.print.attribute.PrintJobAttribute;
  31 import javax.print.attribute.PrintRequestAttribute;
  32 
  33 /**
  34  * Class {@code JobKOctets} is an integer valued printing attribute class that
  35  * specifies the total size of the document(s) in K octets, i.e., in units of
  36  * 1024 octets requested to be processed in the job. The value must be rounded
  37  * up, so that a job between 1 and 1024 octets must be indicated as being 1K
  38  * octets, 1025 to 2048 must be 2K octets, etc. For a multidoc print job (a job
  39  * with multiple documents), the {@code JobKOctets} value is computed by adding
  40  * up the individual documents' sizes in octets, then rounding up to the next K
  41  * octets value.
  42  * <p>
  43  * The {@code JobKOctets} attribute describes the size of the job. This
  44  * attribute is not intended to be a counter; it is intended to be useful
  45  * routing and scheduling information if known. The printer may try to compute
  46  * the {@code JobKOctets} attribute's value if it is not supplied in the Print
  47  * Request. Even if the client does supply a value for the {@code JobKOctets}
  48  * attribute in the Print Request, the printer may choose to change the value if
  49  * the printer is able to compute a value which is more accurate than the client
  50  * supplied value. The printer may be able to determine the correct value for
  51  * the {@code JobKOctets} attribute either right at job submission time or at
  52  * any later point in time.
  53  * <p>
  54  * The {@code JobKOctets} value must not include the multiplicative factors
  55  * contributed by the number of copies specified by the {@link Copies Copies}
  56  * attribute, independent of whether the device can process multiple copies
  57  * without making multiple passes over the job or document data and independent
  58  * of whether the output is collated or not. Thus the value is independent of
  59  * the implementation and indicates the size of the document(s) measured in K
  60  * octets independent of the number of copies.
  61  * <p>
  62  * The {@code JobKOctets} value must also not include the multiplicative factor
  63  * due to a copies instruction embedded in the document data. If the document
  64  * data actually includes replications of the document data, this value will
  65  * include such replication. In other words, this value is always the size of
  66  * the source document data, rather than a measure of the hardcopy output to be
  67  * produced.
  68  * <p>
  69  * The size of a doc is computed based on the print data representation class as
  70  * specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as shown in
  71  * the table below.

  72  * <table class="striped">
  73  * <caption>Table showing computation of doc sizes</caption>
  74  * <thead>
  75  *   <tr>
  76  *     <th>Representation Class
  77  *     <th>Document Size

  78  * </thead>
  79  * <tbody>
  80  *   <tr>
  81  *     <td>{@code byte[]}
  82  *     <td>Length of the byte array
  83  *   <tr>
  84  *     <td>{@code java.io.InputStream}
  85  *     <td>Number of bytes read from the stream
  86  *   <tr>
  87  *     <td>{@code char[]}
  88  *     <td>Length of the character array x 2
  89  *   <tr>
  90  *     <td>{@code java.lang.String}
  91  *     <td>Length of the string x 2
  92  *   <tr>
  93  *     <td>{@code java.io.Reader}
  94  *     <td>Number of characters read from the stream x 2
  95  *   <tr>
  96  *     <td>{@code java.net.URL}
  97  *     <td>Number of bytes read from the file at the given {@code URL} address
  98  *   <tr>
  99  *     <td>{@code java.awt.image.renderable.RenderableImage}
 100  *     <td>Implementation dependent*
 101  *   <tr>
 102  *     <td>{@code java.awt.print.Printable}
 103  *     <td>Implementation dependent*
 104  *   <tr>
 105  *     <td>{@code java.awt.print.Pageable}
 106  *     <td>Implementation dependent*









 107  * </tbody>
 108  * </table>
 109  * <p>
 110  * * In these cases the Print Service itself generates the print data sent
 111  * to the printer. If the Print Service supports the {@code JobKOctets}
 112  * attribute, for these cases the Print Service itself must calculate the size
 113  * of the print data, replacing any {@code JobKOctets} value the client
 114  * specified.
 115  * <p>
 116  * <b>IPP Compatibility:</b> The integer value gives the IPP integer value. The
 117  * category name returned by {@code getName()} gives the IPP attribute name.
 118  *
 119  * @author Alan Kaminsky
 120  * @see JobKOctetsSupported
 121  * @see JobKOctetsProcessed
 122  * @see JobImpressions
 123  * @see JobMediaSheets


 124  */
 125 public final class JobKOctets   extends IntegerSyntax
 126         implements PrintRequestAttribute, PrintJobAttribute {
 127 
 128     /**
 129      * Use serialVersionUID from JDK 1.4 for interoperability.
 130      */
 131     private static final long serialVersionUID = -8959710146498202869L;
 132 
 133     /**
 134      * Construct a new job K octets attribute with the given integer value.
 135      *
 136      * @param  value Integer value
 137      * @throws IllegalArgumentException if {@code value} is negative


 138      */
 139     public JobKOctets(int value) {
 140         super (value, 0, Integer.MAX_VALUE);
 141     }
 142 
 143     /**
 144      * Returns whether this job K octets attribute is equivalent to the passed
 145      * in object. To be equivalent, all of the following conditions must be
 146      * true:
 147      * <ol type=1>
 148      *   <li>{@code object} is not {@code null}.
 149      *   <li>{@code object} is an instance of class {@code JobKOctets}.
 150      *   <li>This job K octets attribute's value and {@code object}'s value are
 151      *   equal.
 152      * </ol>
 153      *
 154      * @param  object {@code Object} to compare to
 155      * @return {@code true} if {@code object} is equivalent to this job K octets
 156      *         attribute, {@code false} otherwise




 157      */
 158     public boolean equals(Object object) {
 159         return super.equals(object) && object instanceof JobKOctets;
 160     }
 161 
 162     /**
 163      * Get the printing attribute class which is to be used as the "category"
 164      * for this printing attribute value.
 165      * <p>
 166      * For class {@code JobKOctets}, the category is class
 167      * {@code JobKOctets} itself.
 168      *
 169      * @return printing attribute class (category), an instance of class
 170      *         {@link Class java.lang.Class}
 171      */
 172     public final Class<? extends Attribute> getCategory() {
 173         return JobKOctets.class;
 174     }
 175 
 176     /**
 177      * Get the name of the category of which this attribute value is an
 178      * instance.
 179      * <p>
 180      * For class {@code JobKOctets}, the category name is
 181      * {@code "job-k-octets"}.
 182      *
 183      * @return attribute category name
 184      */
 185     public final String getName() {
 186         return "job-k-octets";
 187     }

 188 }
< prev index next >