1/*
2 * Copyright (c) 2000, 2017, 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
26package javax.print.attribute.standard;
27
28import java.util.Calendar;
29import java.util.Date;
30
31import javax.print.attribute.Attribute;
32import javax.print.attribute.DateTimeSyntax;
33import javax.print.attribute.PrintJobAttribute;
34
35/**
36 * Class {@code DateTimeAtProcessing} is a printing attribute class, a date-time
37 * attribute, that indicates the date and time at which the Print Job first
38 * began processing.
39 * <p>
40 * To construct a {@code DateTimeAtProcessing} attribute from separate values of
41 * the year, month, day, hour, minute, and so on, use a
42 * {@link Calendar Calendar} object to construct a {@link Date Date} object,
43 * then use the {@link Date Date} object to construct the DateTimeAtProcessing
44 * attribute. To convert a {@code DateTimeAtProcessing} attribute to separate
45 * values of the year, month, day, hour, minute, and so on, create a
46 * {@link Calendar Calendar} object and set it to the {@link Date Date} from the
47 * {@code DateTimeAtProcessing} attribute.
48 * <p>
49 * <b>IPP Compatibility:</b> The information needed to construct an IPP
50 * "date-time-at-processing" attribute can be obtained as described above. The
51 * category name returned by {@code getName()} gives the IPP attribute name.
52 *
53 * @author Alan Kaminsky
54 */
55public final class DateTimeAtProcessing extends DateTimeSyntax
56        implements PrintJobAttribute {
57
58    /**
59     * Use serialVersionUID from JDK 1.4 for interoperability.
60     */
61    private static final long serialVersionUID = -3710068197278263244L;
62
63    /**
64     * Construct a new date-time at processing attribute with the given
65     * {@link Date Date} value.
66     *
67     * @param  dateTime {@link Date Date} value
68     * @throws NullPointerException if {@code dateTime} is {@code null}
69     */
70    public DateTimeAtProcessing(Date dateTime) {
71        super (dateTime);
72    }
73
74    /**
75     * Returns whether this date-time at processing attribute is equivalent to
76     * the passed in object. To be equivalent, all of the following conditions
77     * must be true:
78     * <ol type=1>
79     *   <li>{@code object} is not {@code null}.
80     *   <li>{@code object} is an instance of class
81     *   {@code DateTimeAtProcessing}.
82     *   <li>This date-time at processing attribute's {@link Date Date}
83     *   value and {@code object}'s {@link Date Date} value are equal.
84     * </ol>
85     *
86     * @param  object {@code Object} to compare to
87     * @return {@code true} if {@code object} is equivalent to this date-time at
88     *         processing attribute, {@code false} otherwise
89     */
90    public boolean equals(Object object) {
91        return(super.equals (object) &&
92               object instanceof DateTimeAtProcessing);
93    }
94
95    /**
96     * Get the printing attribute class which is to be used as the "category"
97     * for this printing attribute value.
98     * <p>
99     * For class {@code DateTimeAtProcessing}, the category is class
100     * {@code DateTimeAtProcessing} itself.
101     *
102     * @return printing attribute class (category), an instance of class
103     *         {@link Class java.lang.Class}
104     */
105    public final Class<? extends Attribute> getCategory() {
106        return DateTimeAtProcessing.class;
107    }
108
109    /**
110     * Get the name of the category of which this attribute value is an
111     * instance.
112     * <p>
113     * For class {@code DateTimeAtProcessing}, the category name is
114     * {@code "date-time-at-processing"}.
115     *
116     * @return attribute category name
117     */
118    public final String getName() {
119        return "date-time-at-processing";
120    }
121}
122