1. /*
  2. * @(#)PrinterLocation.java 1.6 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.PrintServiceAttribute;
  11. /**
  12. * Class PrinterLocation is a printing attribute class, a text attribute, that
  13. * identifies the location of the device. This could include things like:
  14. * <CODE>"in Room 123A, second floor of building XYZ"</CODE>.
  15. * <P>
  16. * <B>IPP Compatibility:</B> The string value gives the IPP name value. The
  17. * locale gives the IPP natural language. The category name returned by
  18. * <CODE>getName()</CODE> gives the IPP attribute name.
  19. * <P>
  20. *
  21. * @author Alan Kaminsky
  22. */
  23. public final class PrinterLocation extends TextSyntax
  24. implements PrintServiceAttribute {
  25. /**
  26. * Constructs a new printer location attribute with the given location and
  27. * locale.
  28. *
  29. * @param location Printer location.
  30. * @param locale Natural language of the text string. null
  31. * is interpreted to mean the default locale as returned
  32. * by <code>Locale.getDefault()</code>
  33. *
  34. * @exception NullPointerException
  35. * (unchecked exception) Thrown if <CODE>location</CODE> is null.
  36. */
  37. public PrinterLocation(String location, Locale locale) {
  38. super (location, locale);
  39. }
  40. /**
  41. * Returns whether this printer location attribute is equivalent to the
  42. * passed in object. To be equivalent, all of the following conditions
  43. * must be true:
  44. * <OL TYPE=1>
  45. * <LI>
  46. * <CODE>object</CODE> is not null.
  47. * <LI>
  48. * <CODE>object</CODE> is an instance of class PrinterLocation.
  49. * <LI>
  50. * This printer location attribute's underlying string and
  51. * <CODE>object</CODE>'s underlying string are equal.
  52. * <LI>
  53. * This printer location attribute's locale and <CODE>object</CODE>'s
  54. * locale are equal.
  55. * </OL>
  56. *
  57. * @param object Object to compare to.
  58. *
  59. * @return True if <CODE>object</CODE> is equivalent to this printer
  60. * location attribute, false otherwise.
  61. */
  62. public boolean equals(Object object) {
  63. return (super.equals(object) && object instanceof PrinterLocation);
  64. }
  65. /**
  66. * Get the printing attribute class which is to be used as the "category"
  67. * for this printing attribute value.
  68. * <P>
  69. * For class PrinterLocation, the
  70. * category is class PrinterLocation itself.
  71. *
  72. * @return Printing attribute class (category), an instance of class
  73. * {@link java.lang.Class java.lang.Class}.
  74. */
  75. public final Class getCategory() {
  76. return PrinterLocation.class;
  77. }
  78. /**
  79. * Get the name of the category of which this attribute value is an
  80. * instance.
  81. * <P>
  82. * For class PrinterLocation, the
  83. * category name is <CODE>"printer-location"</CODE>.
  84. *
  85. * @return Attribute category name.
  86. */
  87. public final String getName() {
  88. return "printer-location";
  89. }
  90. }