StreamPrintService
class is
obtained from a StreamPrintServiceFactory
instance.
Note that a StreamPrintService
is different from a
PrintService
, which supports a
Destination
attribute. A StreamPrintService
always requires an output
stream, whereas a PrintService
optionally accepts a
Destination
. A StreamPrintService
has no default destination for its formatted output.
Additionally a StreamPrintService
is expected to generate
output in
a format useful in other contexts.
StreamPrintService's are not expected to support the Destination attribute.
StreamPrintService
.
If a stream service cannot be re-used, it must be disposed
to indicate this. Typically the client will call this method.
Services which write data which cannot meaningfully be appended to
may also dispose the stream. This does not close the stream. It
just marks it as not for further use by this service.Clients should call this method to determine if two services are referring to the same underlying service.
Services must implement this method and return true only if the service objects being compared may be used interchangeably by the client. Services are free to return the same object reference to an underlying service if that, but clients must not depend on equality of reference.
getAttributes()
method call: that is, the returned
attribute set's contents will not be updated if this print
service's attribute set's contents change in the future. To detect
changes in attribute values, call getAttributes()
again
and compare the new attribute set to the previous attribute set;
alternatively, register a listener for print service events.
Some attributes may not be supported in a particular context (ie
for a particular DocFlavor
).
Use one of the methods that include a DocFlavor
to
validate the request before submitting it, such as
getSupportedAttributeValues(..)
.
Not all attributes have a default value. For example the
service will not have a defaultvalue for RequestingUser
i.e. a null return for a supported category means there is no
service default value for that category. Use the
isAttributeCategorySupported(Class)
method to
distinguish these cases.
ServiceUIFactory
for more information.Class
that implements interface
Attribute
. This method returns
just the attribute categories that are supported; it does not
return the particular attribute values that are supported.
This method returns all the printing attribute
categories this print service supports for any possible job.
Some categories may not be supported in a particular context (ie
for a particular DocFlavor
).
Use one of the methods that include a DocFlavor
to
validate the request before submitting it, such as
getSupportedAttributeValues(..)
.
If flavor
is null and attributes
is null
or is an empty set, this method returns all the printing attribute
values this Print Service supports for any possible job. If
flavor
is not null or attributes
is not
an empty set, this method returns just the printing attribute values
that are compatible with the given doc flavor and/or set of attributes.
That is, a null return value may indicate that specifying this attribute
is incompatible with the specified DocFlavor.
Also if DocFlavor is not null it must be a flavor supported by this
PrintService, else IllegalArgumentException will be thrown.
If the attributes
parameter contains an Attribute whose
category is the same as the category
parameter, the service
must ignore this attribute in the AttributeSet.
DocAttribute
s which are to be specified on the
Doc
must be included in this set to accurately
represent the context.
This method returns an Object because different printing attribute categories indicate the supported attribute values in different ways. The documentation for each printing attribute in package javax.print.attribute.standard describes how each attribute indicates its supported values. Possible ways of indicating support include:
getCategory(Class)
.
PrintService
. A print data format is
designated by a "doc
flavor" (class DocFlavor
)
consisting of a MIME type plus a print data representation class.
Note that some doc flavors may not be supported in combination
with all attributes. Use getUnsupportedAttributes(..)
to validate specific combinations.
DocAttribute
s which are to be specified on the
Doc
must be included in this set to accurately
represent the context.
If the return value is non-null, all attributes in the returned set are unsupported with this DocFlavor. The returned set does not distinguish attribute categories that are unsupported from unsupported attribute values.
A supported print request can then be created by removing all unsupported attributes from the original attribute set, except in the case that the DocFlavor is unsupported.
If any attributes are unsupported only because they are in conflict with other attributes then it is at the discretion of the service to select the attribute(s) to be identified as the cause of the conflict.
Use isDocFlavorSupported()
to verify that a DocFlavor
is supported before calling this method.
equals(Object)
.Class
that implements interface
Attribute
. This method tells whether the attribute category is
supported; it does not tell whether a particular attribute value
is supported.
Some categories may not be supported in a particular context (ie
for a particular DocFlavor
).
Use one of the methods which include a DocFlavor
to
validate the request before submitting it, such as
getSupportedAttributeValues(..)
.
This is a convenience method to determine if the category
would be a member of the result of
getSupportedAttributeCategories()
.
If flavor
is null and attributes
is null or
is an empty set, this method tells whether this Print Service supports
the given printing attribute value for some possible combination of doc
flavor and set of attributes. If flavor
is not null or
attributes
is not an empty set, this method tells whether
this Print Service supports the given printing attribute value in
combination with the given doc flavor and/or set of attributes.
Also if DocFlavor is not null it must be a flavor supported by this PrintService, else IllegalArgumentException will be thrown.
DocAttribute
s which are to be specified on the
Doc
must be included in this set to accurately
represent the context.
This is a convenience method to determine if the value
would be a member of the result of
getSupportedAttributeValues(...)
.
boolean
indicating whether or not
this StreamPrintService
has been disposed.
If this object has been disposed, will return true.
Used by services and client applications to recognize streams
to which no further data should be written.DocFlavor
. This is a convenience method to determine
if the DocFlavor
would be a member of the result of
getSupportedDocFlavors()
.
Note that some doc flavors may not be supported in combination
with all attributes. Use getUnsupportedAttributes(..)
to validate specific combinations.
wait
methods.
The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:
synchronized
statement
that synchronizes on the object.
Class,
by executing a
synchronized static method of that class.
Only one thread at a time can own an object's monitor.
wait
methods.
The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
PrintService
events.toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
The current thread must own this object's monitor. The thread
releases ownership of this monitor and waits until another thread
notifies threads waiting on this object's monitor to wake up
either through a call to the notify
method or the
notifyAll
method. The thread then waits until it can
re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.The current thread must own this object's monitor.
This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:
A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout); ... // Perform action appropriate to condition }(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).
If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.
Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.
This method should only be called by a thread that is the owner
of this object's monitor. See the notify
method for a
description of the ways in which a thread can become the owner of
a monitor.
This method is similar to the wait
method of one
argument, but it allows finer control over the amount of time to
wait for a notification before giving up. The amount of real time,
measured in nanoseconds, is given by:
1000000*timeout+nanos
In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:
notify
method
or the notifyAll
method.
timeout
milliseconds plus nanos
nanoseconds arguments, has
elapsed.
The thread then waits until it can re-obtain ownership of the monitor and resumes execution.
As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:
synchronized (obj) { while (<condition does not hold>) obj.wait(timeout, nanos); ... // Perform action appropriate to condition }This method should only be called by a thread that is the owner of this object's monitor. See the
notify
method for a
description of the ways in which a thread can become the owner of
a monitor.