1. /*
  2. * @(#)Destination.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.net.URI;
  9. import javax.print.attribute.Attribute;
  10. import javax.print.attribute.URISyntax;
  11. import javax.print.attribute.PrintRequestAttribute;
  12. import javax.print.attribute.PrintJobAttribute;
  13. /**
  14. * Class Destination is a printing attribute class, a URI, that is used to
  15. * indicate an alternate destination for the spooled printer formatted
  16. * data. Many PrintServices will not support the notion of a destination
  17. * other than the printer device, and so will not support this attribute.
  18. * <p>
  19. * A common use for this attribute will be applications which want
  20. * to redirect output to a local disk file : eg."file:out.prn".
  21. * Note that proper construction of "file:" scheme URI instances should
  22. * be performed using the <code>toURI()</code> method of class
  23. * {@link java.io.File File}.
  24. * See the documentation on that class for more information.
  25. * <p>
  26. * If a destination URI is specified in a PrintRequest and it is not
  27. * accessible for output by the PrintService, a PrintException will be thrown.
  28. * The PrintException may implement URIException to provide a more specific
  29. * cause.
  30. * <P>
  31. * <B>IPP Compatibility:</B> Destination is not an IPP attribute.
  32. * <P>
  33. *
  34. * @author Phil Race.
  35. */
  36. public final class Destination extends URISyntax
  37. implements PrintJobAttribute, PrintRequestAttribute {
  38. private static final long serialVersionUID = 6776739171700415321L;
  39. /**
  40. * Constructs a new destination attribute with the specified URI.
  41. *
  42. * @param uri URI.
  43. *
  44. * @exception NullPointerException
  45. * (unchecked exception) Thrown if <CODE>uri</CODE> is null.
  46. */
  47. public Destination(URI uri) {
  48. super (uri);
  49. }
  50. /**
  51. * Returns whether this destination attribute is equivalent to the
  52. * passed in object. To be equivalent, all of the following conditions
  53. * 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 Destination.
  59. * <LI>
  60. * This destination attribute's URI and <CODE>object</CODE>'s URI
  61. * are equal.
  62. * </OL>
  63. *
  64. * @param object Object to compare to.
  65. *
  66. * @return True if <CODE>object</CODE> is equivalent to this destination
  67. * attribute, false otherwise.
  68. */
  69. public boolean equals(Object object) {
  70. return (super.equals(object) &&
  71. object instanceof Destination);
  72. }
  73. /**
  74. * Get the printing attribute class which is to be used as the "category"
  75. * for this printing attribute value.
  76. * <P>
  77. * For class Destination, the category is class Destination itself.
  78. *
  79. * @return Printing attribute class (category), an instance of class
  80. * {@link java.lang.Class java.lang.Class}.
  81. */
  82. public final Class<? extends Attribute> getCategory() {
  83. return Destination.class;
  84. }
  85. /**
  86. * Get the name of the category of which this attribute value is an
  87. * instance.
  88. * <P>
  89. * For class Destination, the category name is <CODE>"spool-data-destination"</CODE>.
  90. *
  91. * @return Attribute category name.
  92. */
  93. public final String getName() {
  94. return "spool-data-destination";
  95. }
  96. }