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