1. /*
  2. * @(#)JobName.java 1.9 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.Locale;
  9. import javax.print.attribute.Attribute;
  10. import javax.print.attribute.TextSyntax;
  11. import javax.print.attribute.PrintRequestAttribute;
  12. import javax.print.attribute.PrintJobAttribute;
  13. /**
  14. * Class JobName is a printing attribute class, a text attribute, that specifies
  15. * the name of a print job. A job's name is an arbitrary string defined by the
  16. * client. It does not need to be unique between different jobs. A Print Job's
  17. * JobName attribute is set to the value supplied by the client in the Print
  18. * Request's attribute set. If, however, the client does not supply a JobName
  19. * attribute in the Print Request, the printer, when it creates the Print Job,
  20. * must generate a JobName. The printer should generate the value of the Print
  21. * Job's JobName attribute from the first of the following sources that produces
  22. * a value: (1) the {@link DocumentName DocumentName} attribute of the first (or
  23. * only) doc in the job, (2) the URL of the first (or only) doc in the job, if
  24. * the doc's print data representation object is a URL, or (3) any other piece
  25. * of Print Job specific and/or document content information.
  26. * <P>
  27. * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  28. * locale gives the IPP natural language. The category name returned by
  29. * <CODE>getName()</CODE> gives the IPP attribute name.
  30. * <P>
  31. *
  32. * @author Alan Kaminsky
  33. */
  34. public final class JobName extends TextSyntax
  35. implements PrintRequestAttribute, PrintJobAttribute {
  36. private static final long serialVersionUID = 4660359192078689545L;
  37. /**
  38. * Constructs a new job name attribute with the given job name and locale.
  39. *
  40. * @param jobName Job name.
  41. * @param locale Natural language of the text string. null
  42. * is interpreted to mean the default locale as returned
  43. * by <code>Locale.getDefault()</code>
  44. *
  45. * @exception NullPointerException
  46. * (unchecked exception) Thrown if <CODE>jobName</CODE> is null.
  47. */
  48. public JobName(String jobName, Locale locale) {
  49. super (jobName, locale);
  50. }
  51. /**
  52. * Returns whether this job name attribute is equivalent to the passed in
  53. * object. To be equivalent, all of the following conditions must be true:
  54. * <OL TYPE=1>
  55. * <LI>
  56. * <CODE>object</CODE> is not null.
  57. * <LI>
  58. * <CODE>object</CODE> is an instance of class JobName.
  59. * <LI>
  60. * This job name attribute's underlying string and <CODE>object</CODE>'s
  61. * underlying string are equal.
  62. * <LI>
  63. * This job name attribute's locale and <CODE>object</CODE>'s locale are
  64. * equal.
  65. * </OL>
  66. *
  67. * @param object Object to compare to.
  68. *
  69. * @return True if <CODE>object</CODE> is equivalent to this job name
  70. * attribute, false otherwise.
  71. */
  72. public boolean equals(Object object) {
  73. return (super.equals(object) && object instanceof JobName);
  74. }
  75. /**
  76. * Get the printing attribute class which is to be used as the "category"
  77. * for this printing attribute value.
  78. * <P>
  79. * For class JobName, the category is class JobName itself.
  80. *
  81. * @return Printing attribute class (category), an instance of class
  82. * {@link java.lang.Class java.lang.Class}.
  83. */
  84. public final Class<? extends Attribute> getCategory() {
  85. return JobName.class;
  86. }
  87. /**
  88. * Get the name of the category of which this attribute value is an
  89. * instance.
  90. * <P>
  91. * For class JobName, the category name is <CODE>"job-name"</CODE>.
  92. *
  93. * @return Attribute category name.
  94. */
  95. public final String getName() {
  96. return "job-name";
  97. }
  98. }