1. /*
  2. * @(#)DocumentName.java 1.10 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.DocAttribute;
  12. /**
  13. * Class DocumentName is a printing attribute class, a text attribute, that
  14. * specifies the name of a document. DocumentName is an attribute of the print
  15. * data (the doc), not of the Print Job. A document's name is an arbitrary
  16. * string defined by the client.
  17. * However if a JobName is not specified, the DocumentName should be used
  18. * instead, which implies that supporting specification of DocumentName
  19. * requires reporting of JobName and vice versa.
  20. * See {@link JobName JobName} for more information.
  21. * <P>
  22. * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  23. * locale gives the IPP natural language. The category name returned by
  24. * <CODE>getName()</CODE> gives the IPP attribute name.
  25. * <P>
  26. *
  27. * @author Alan Kaminsky
  28. */
  29. public final class DocumentName extends TextSyntax implements DocAttribute {
  30. private static final long serialVersionUID = 7883105848533280430L;
  31. /**
  32. * Constructs a new document name attribute with the given document name
  33. * and locale.
  34. *
  35. * @param documentName Document name.
  36. * @param locale Natural language of the text string. null
  37. * is interpreted to mean the default locale as returned
  38. * by <code>Locale.getDefault()</code>
  39. *
  40. * @exception NullPointerException
  41. * (unchecked exception) Thrown if <CODE>documentName</CODE> is null.
  42. */
  43. public DocumentName(String documentName, Locale locale) {
  44. super (documentName, locale);
  45. }
  46. /**
  47. * Returns whether this document name attribute is equivalent to the
  48. * passed in object.
  49. * To be equivalent, all of the following conditions must be true:
  50. * <OL TYPE=1>
  51. * <LI>
  52. * <CODE>object</CODE> is not null.
  53. * <LI>
  54. * <CODE>object</CODE> is an instance of class DocumentName.
  55. * <LI>
  56. * This document name attribute's underlying string and
  57. * <CODE>object</CODE>'s underlying string are equal.
  58. * <LI>
  59. * This document name attribute's locale and <CODE>object</CODE>'s locale
  60. * are equal.
  61. * </OL>
  62. *
  63. * @param object Object to compare to.
  64. *
  65. * @return True if <CODE>object</CODE> is equivalent to this document
  66. * name attribute, false otherwise.
  67. */
  68. public boolean equals(Object object) {
  69. return (super.equals (object) && object instanceof DocumentName);
  70. }
  71. /**
  72. * Get the printing attribute class which is to be used as the "category"
  73. * for this printing attribute value.
  74. * <P>
  75. * For class DocumentName, the category is class DocumentName itself.
  76. *
  77. * @return Printing attribute class (category), an instance of class
  78. * {@link java.lang.Class java.lang.Class}.
  79. */
  80. public final Class<? extends Attribute> getCategory() {
  81. return DocumentName.class;
  82. }
  83. /**
  84. * Get the name of the category of which this attribute value is an
  85. * instance.
  86. * <P>
  87. * For class DocumentName, the category name is <CODE>"document-name"</CODE>.
  88. *
  89. * @return Attribute category name.
  90. */
  91. public final String getName() {
  92. return "document-name";
  93. }
  94. }