001 /*
002 * Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025 package javax.print.attribute.standard;
026
027 import java.util.Date;
028 import javax.print.attribute.Attribute;
029 import javax.print.attribute.DateTimeSyntax;
030 import javax.print.attribute.PrintJobAttribute;
031
032 /**
033 * Class DateTimeAtCreation is a printing attribute class, a date-time
034 * attribute, that indicates the date and time at which the Print Job was
035 * created.
036 * <P>
037 * To construct a DateTimeAtCreation attribute from separate values of the year,
038 * month, day, hour, minute, and so on, use a {@link java.util.Calendar
039 * Calendar} object to construct a {@link java.util.Date Date} object, then use
040 * the {@link java.util.Date Date} object to construct the DateTimeAtCreation
041 * attribute. To convert a DateTimeAtCreation attribute to separate values of
042 * the year, month, day, hour, minute, and so on, create a {@link
043 * java.util.Calendar Calendar} object and set it to the {@link java.util.Date
044 * Date} from the DateTimeAtCreation attribute.
045 * <P>
046 * <B>IPP Compatibility:</B> The information needed to construct an IPP
047 * "date-time-at-creation" attribute can be obtained as described above. The
048 * category name returned by <CODE>getName()</CODE> gives the IPP attribute
049 * name.
050 * <P>
051 *
052 * @author Alan Kaminsky
053 */
054 public final class DateTimeAtCreation extends DateTimeSyntax implements
055 PrintJobAttribute {
056
057 private static final long serialVersionUID = -2923732231056647903L;
058
059 /**
060 * Construct a new date-time at creation attribute with the given {@link
061 * java.util.Date Date} value.
062 *
063 * @param dateTime {@link java.util.Date Date} value.
064 *
065 * @exception NullPointerException
066 * (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
067 */
068 public DateTimeAtCreation(Date dateTime) {
069 super (dateTime);
070 }
071
072 /**
073 * Returns whether this date-time at creation attribute is equivalent to
074 * the passed in object. To be equivalent, all of the following conditions
075 * must be true:
076 * <OL TYPE=1>
077 * <LI>
078 * <CODE>object</CODE> is not null.
079 * <LI>
080 * <CODE>object</CODE> is an instance of class DateTimeAtCreation.
081 * <LI>
082 * This date-time at creation attribute's {@link java.util.Date Date} value
083 * and <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
084 * </OL>
085 *
086 * @param object Object to compare to.
087 *
088 * @return True if <CODE>object</CODE> is equivalent to this date-time
089 * at creation attribute, false otherwise.
090 */
091 public boolean equals(Object object) {
092 return (super .equals(object) && object instanceof DateTimeAtCreation);
093 }
094
095 /**
096 * Get the printing attribute class which is to be used as the "category"
097 * for this printing attribute value.
098 * <P>
099 * For class DateTimeAtCreation, the category is class
100 * DateTimeAtCreation itself.
101 *
102 * @return Printing attribute class (category), an instance of class
103 * {@link java.lang.Class java.lang.Class}.
104 */
105 public final Class<? extends Attribute> getCategory() {
106 return DateTimeAtCreation.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 DateTimeAtCreation, the category name is
114 * <CODE>"date-time-at-creation"</CODE>.
115 *
116 * @return Attribute category name.
117 */
118 public final String getName() {
119 return "date-time-at-creation";
120 }
121
122 }
|