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