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