1. /*
  2. * @(#)RequestingUserName.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.PrintRequestAttribute;
  12. /**
  13. * Class RequestingUserName is a printing attribute class, a text attribute,
  14. * that specifies the name of the end user that submitted the print job. A
  15. * requesting user name is an arbitrary string defined by the client. The
  16. * printer does not put the client-specified RequestingUserName attribute into
  17. * the Print Job's attribute set; rather, the printer puts in a {@link
  18. * JobOriginatingUserName JobOriginatingUserName} attribute.
  19. * This means that services which support specifying a username with this
  20. * attribute should also report a JobOriginatingUserName in the job's
  21. * attribute set. Note that many print services may have a way to independently
  22. * authenticate the user name, and so may state support for a
  23. * requesting user name, but in practice will then report the user name
  24. * authenticated by the service rather than that specified via this
  25. * attribute.
  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 RequestingUserName extends TextSyntax
  35. implements PrintRequestAttribute {
  36. private static final long serialVersionUID = -2683049894310331454L;
  37. /**
  38. * Constructs a new requesting user name attribute with the given user
  39. * name and locale.
  40. *
  41. * @param userName User name.
  42. * @param locale Natural language of the text string. null
  43. * is interpreted to mean the default locale as returned
  44. * by <code>Locale.getDefault()</code>
  45. *
  46. * @exception NullPointerException
  47. * (unchecked exception) Thrown if <CODE>userName</CODE> is null.
  48. */
  49. public RequestingUserName(String userName, Locale locale) {
  50. super (userName, locale);
  51. }
  52. /**
  53. * Returns whether this requesting user name attribute is equivalent to
  54. * the passed in object. To be equivalent, all of the following
  55. * conditions must be true:
  56. * <OL TYPE=1>
  57. * <LI>
  58. * <CODE>object</CODE> is not null.
  59. * <LI>
  60. * <CODE>object</CODE> is an instance of class RequestingUserName.
  61. * <LI>
  62. * This requesting user name attribute's underlying string and
  63. * <CODE>object</CODE>'s underlying string are equal.
  64. * <LI>
  65. * This requesting user name attribute's locale and
  66. * <CODE>object</CODE>'s locale are equal.
  67. * </OL>
  68. *
  69. * @param object Object to compare to.
  70. *
  71. * @return True if <CODE>object</CODE> is equivalent to this requesting
  72. * user name attribute, false otherwise.
  73. */
  74. public boolean equals(Object object) {
  75. return (super.equals(object) &&
  76. object instanceof RequestingUserName);
  77. }
  78. /**
  79. * Get the printing attribute class which is to be used as the "category"
  80. * for this printing attribute value.
  81. * <P>
  82. * For class RequestingUserName, the
  83. * category is class RequestingUserName itself.
  84. *
  85. * @return Printing attribute class (category), an instance of class
  86. * {@link java.lang.Class java.lang.Class}.
  87. */
  88. public final Class<? extends Attribute> getCategory() {
  89. return RequestingUserName.class;
  90. }
  91. /**
  92. * Get the name of the category of which this attribute value is an
  93. * instance.
  94. * <P>
  95. * For class RequestingUserName, the
  96. * category name is <CODE>"requesting-user-name"</CODE>.
  97. *
  98. * @return Attribute category name.
  99. */
  100. public final String getName() {
  101. return "requesting-user-name";
  102. }
  103. }