1. /*
  2. * @(#)DateTimeAtCreation.java 1.7 04/05/05
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.print.attribute.standard;
  8. import java.util.Date;
  9. import javax.print.attribute.Attribute;
  10. import javax.print.attribute.DateTimeSyntax;
  11. import javax.print.attribute.PrintJobAttribute;
  12. /**
  13. * Class DateTimeAtCreation is a printing attribute class, a date-time
  14. * attribute, that indicates the date and time at which the Print Job was
  15. * created.
  16. * <P>
  17. * To construct a DateTimeAtCreation attribute from separate values of the year,
  18. * month, day, hour, minute, and so on, use a {@link java.util.Calendar
  19. * Calendar} object to construct a {@link java.util.Date Date} object, then use
  20. * the {@link java.util.Date Date} object to construct the DateTimeAtCreation
  21. * attribute. To convert a DateTimeAtCreation attribute to separate values of
  22. * the year, month, day, hour, minute, and so on, create a {@link
  23. * java.util.Calendar Calendar} object and set it to the {@link java.util.Date
  24. * Date} from the DateTimeAtCreation attribute.
  25. * <P>
  26. * <B>IPP Compatibility:</B> The information needed to construct an IPP
  27. * "date-time-at-creation" attribute can be obtained as described above. The
  28. * category name returned by <CODE>getName()</CODE> gives the IPP attribute
  29. * name.
  30. * <P>
  31. *
  32. * @author Alan Kaminsky
  33. */
  34. public final class DateTimeAtCreation extends DateTimeSyntax
  35. implements PrintJobAttribute {
  36. private static final long serialVersionUID = -2923732231056647903L;
  37. /**
  38. * Construct a new date-time at creation attribute with the given {@link
  39. * java.util.Date Date} value.
  40. *
  41. * @param dateTime {@link java.util.Date Date} value.
  42. *
  43. * @exception NullPointerException
  44. * (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
  45. */
  46. public DateTimeAtCreation(Date dateTime) {
  47. super (dateTime);
  48. }
  49. /**
  50. * Returns whether this date-time at creation attribute is equivalent to
  51. * the passed in object. To be equivalent, all of the following conditions
  52. * must be true:
  53. * <OL TYPE=1>
  54. * <LI>
  55. * <CODE>object</CODE> is not null.
  56. * <LI>
  57. * <CODE>object</CODE> is an instance of class DateTimeAtCreation.
  58. * <LI>
  59. * This date-time at creation attribute's {@link java.util.Date Date} value
  60. * and <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
  61. * </OL>
  62. *
  63. * @param object Object to compare to.
  64. *
  65. * @return True if <CODE>object</CODE> is equivalent to this date-time
  66. * at creation attribute, false otherwise.
  67. */
  68. public boolean equals(Object object) {
  69. return(super.equals (object) &&
  70. object instanceof DateTimeAtCreation);
  71. }
  72. /**
  73. * Get the printing attribute class which is to be used as the "category"
  74. * for this printing attribute value.
  75. * <P>
  76. * For class DateTimeAtCreation, the category is class
  77. * DateTimeAtCreation itself.
  78. *
  79. * @return Printing attribute class (category), an instance of class
  80. * {@link java.lang.Class java.lang.Class}.
  81. */
  82. public final Class<? extends Attribute> getCategory() {
  83. return DateTimeAtCreation.class;
  84. }
  85. /**
  86. * Get the name of the category of which this attribute value is an
  87. * instance.
  88. * <P>
  89. * For class DateTimeAtCreation, the category name is
  90. * <CODE>"date-time-at-creation"</CODE>.
  91. *
  92. * @return Attribute category name.
  93. */
  94. public final String getName() {
  95. return "date-time-at-creation";
  96. }
  97. }