feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
66
jdkSrc/jdk8/javax/print/AttributeException.java
Normal file
66
jdkSrc/jdk8/javax/print/AttributeException.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
|
||||
/**
|
||||
* Interface AttributeException is a mixin interface which a subclass of
|
||||
* {@link
|
||||
* PrintException PrintException} can implement to report an error condition
|
||||
* involving one or more printing attributes that a particular Print
|
||||
* Service instance does not support. Either the attribute is not supported at
|
||||
* all, or the attribute is supported but the particular specified value is not
|
||||
* supported. The Print Service API does not define any print exception
|
||||
* classes that implement interface AttributeException, that being left to the
|
||||
* Print Service implementor's discretion.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface AttributeException {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the array of printing attribute classes for which the Print
|
||||
* Service instance does not support the attribute at all, or null if
|
||||
* there are no such attributes. The objects in the returned array are
|
||||
* classes that extend the base interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}.
|
||||
*
|
||||
* @return unsupported attribute classes
|
||||
*/
|
||||
public Class[] getUnsupportedAttributes();
|
||||
|
||||
/**
|
||||
* Returns the array of printing attributes for which the Print Service
|
||||
* instance supports the attribute but does not support that particular
|
||||
* value of the attribute, or null if there are no such attribute values.
|
||||
*
|
||||
* @return unsupported attribute values
|
||||
*/
|
||||
public Attribute[] getUnsupportedValues();
|
||||
|
||||
}
|
||||
77
jdkSrc/jdk8/javax/print/CancelablePrintJob.java
Normal file
77
jdkSrc/jdk8/javax/print/CancelablePrintJob.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
/**
|
||||
* This interface is used by a printing application to cancel a
|
||||
* print job. This interface extends {@link DocPrintJob}. A
|
||||
* <code>DocPrintJob</code> implementation returned from a print
|
||||
* service implements this interface if the print job can be
|
||||
* cancelled. Before trying to cancel
|
||||
* a print job, the client needs to test if the
|
||||
* <code>DocPrintJob</code> object returned from the print service
|
||||
* actually implements this interface. Clients should never assume
|
||||
* that a <code>DocPrintJob</code> implements this interface. A
|
||||
* print service might support cancellation only for certain types
|
||||
* of print data and representation class names. This means that
|
||||
* only some of the <code>DocPrintJob</code> objects returned from
|
||||
* a service will implement this interface.
|
||||
* <p>
|
||||
* Service implementors are encouraged to implement this optional interface
|
||||
* and to deliver a javax.print.event.PrintJobEvent.JOB_CANCELLED event
|
||||
* to any listeners if a job is successfully cancelled with an
|
||||
* implementation of this interface. Services should also note that an
|
||||
* implementation of this method may be made from a separate client thread
|
||||
* than that which made the print request. Thus the implementation of
|
||||
* this interface must be made thread safe.
|
||||
*/
|
||||
|
||||
public interface CancelablePrintJob extends DocPrintJob {
|
||||
|
||||
/**
|
||||
* Stops further processing of a print job.
|
||||
* <p>
|
||||
* If a service supports this method it cannot be concluded that
|
||||
* job cancellation will always succeed. A job may not be able to be
|
||||
* cancelled once it has reached and passed some point in its processing.
|
||||
* A successful cancellation means only that the entire job was not
|
||||
* printed, some portion may already have printed when cancel returns.
|
||||
* <p>
|
||||
* The service will throw a PrintException if the cancellation did not
|
||||
* succeed. A job which has not yet been submitted for printing should
|
||||
* throw this exception.
|
||||
* Cancelling an already successfully cancelled Print Job is not
|
||||
* considered an error and will always succeed.
|
||||
* <p>
|
||||
* Cancellation in some services may be a lengthy process, involving
|
||||
* requests to a server and processing of its print queue. Clients
|
||||
* may wish to execute cancel in a thread which does not affect
|
||||
* application execution.
|
||||
* @throws PrintException if the job could not be successfully cancelled.
|
||||
*/
|
||||
public void cancel() throws PrintException;
|
||||
|
||||
}
|
||||
206
jdkSrc/jdk8/javax/print/Doc.java
Normal file
206
jdkSrc/jdk8/javax/print/Doc.java
Normal file
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import javax.print.attribute.DocAttributeSet;
|
||||
|
||||
|
||||
/**
|
||||
* Interface Doc specifies the interface for an object that supplies one piece
|
||||
* of print data for a Print Job. "Doc" is a short, easy-to-pronounce term
|
||||
* that means "a piece of print data." The client passes to the Print Job an
|
||||
* object that implements interface Doc, and the Print Job calls methods on
|
||||
* that object to obtain the print data. The Doc interface lets a Print Job:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* Determine the format, or "doc flavor" (class {@link DocFlavor DocFlavor}),
|
||||
* in which the print data is available. A doc flavor designates the print
|
||||
* data format (a MIME type) and the representation class of the object
|
||||
* from which the print data comes.
|
||||
* <P>
|
||||
* <LI>
|
||||
* Obtain the print data representation object, which is an instance of the
|
||||
* doc flavor's representation class. The Print Job can then obtain the actual
|
||||
* print data from the representation object.
|
||||
* <P>
|
||||
* <LI>
|
||||
* Obtain the printing attributes that specify additional characteristics of
|
||||
* the doc or that specify processing instructions to be applied to the doc.
|
||||
* Printing attributes are defined in package {@link javax.print.attribute
|
||||
* javax.print.attribute}. The doc returns its printing attributes stored in
|
||||
* an {@link javax.print.attribute.DocAttributeSet javax.print.attribute.DocAttributeSet}.
|
||||
* </UL>
|
||||
* <P>
|
||||
* Each method in an implementation of interface Doc is permitted always to
|
||||
* return the same object each time the method is called.
|
||||
* This has implications
|
||||
* for a Print Job or other caller of a doc object whose print data
|
||||
* representation object "consumes" the print data as the caller obtains the
|
||||
* print data, such as a print data representation object which is a stream.
|
||||
* Once the Print Job has called {@link #getPrintData()
|
||||
* getPrintData()} and obtained the stream, any further calls to
|
||||
* {@link #getPrintData() getPrintData()} will return the same
|
||||
* stream object upon which reading may already be in progress, <I>not</I> a new
|
||||
* stream object that will re-read the print data from the beginning. Specifying
|
||||
* a doc object to behave this way simplifies the implementation of doc objects,
|
||||
* and is justified on the grounds that a particular doc is intended to convey
|
||||
* print data only to one Print Job, not to several different Print Jobs. (To
|
||||
* convey the same print data to several different Print Jobs, you have to
|
||||
* create several different doc objects on top of the same print data source.)
|
||||
* <P>
|
||||
* Interface Doc affords considerable implementation flexibility. The print data
|
||||
* might already be in existence when the doc object is constructed. In this
|
||||
* case the objects returned by the doc's methods can be supplied to the doc's
|
||||
* constructor, be stored in the doc ahead of time, and simply be returned when
|
||||
* called for. Alternatively, the print data might not exist yet when the doc
|
||||
* object is constructed. In this case the doc object might provide a "lazy"
|
||||
* implementation that generates the print data representation object (and/or
|
||||
* the print data) only when the Print Job calls for it (when the Print Job
|
||||
* calls the {@link #getPrintData() getPrintData()} method).
|
||||
* <P>
|
||||
* There is no restriction on the number of client threads that may be
|
||||
* simultaneously accessing the same doc. Therefore, all implementations of
|
||||
* interface Doc must be designed to be multiple thread safe.
|
||||
* <p>
|
||||
* However there can only be one consumer of the print data obtained from a
|
||||
* Doc.
|
||||
* <p>
|
||||
* If print data is obtained from the client as a stream, by calling Doc's
|
||||
* <code>getReaderForText()</code> or <code>getStreamForBytes()</code>
|
||||
* methods, or because the print data source is already an InputStream or
|
||||
* Reader, then the print service should always close these streams for the
|
||||
* client on all job completion conditions. With the following caveat.
|
||||
* If the print data is itself a stream, the service will always close it.
|
||||
* If the print data is otherwise something that can be requested as a stream,
|
||||
* the service will only close the stream if it has obtained the stream before
|
||||
* terminating. That is, just because a print service might request data as
|
||||
* a stream does not mean that it will, with the implications that Doc
|
||||
* implementors which rely on the service to close them should create such
|
||||
* streams only in response to a request from the service.
|
||||
* <P>
|
||||
* <HR>
|
||||
*/
|
||||
public interface Doc {
|
||||
|
||||
/**
|
||||
* Determines the doc flavor in which this doc object will supply its
|
||||
* piece of print data.
|
||||
*
|
||||
* @return Doc flavor.
|
||||
*/
|
||||
public DocFlavor getDocFlavor();
|
||||
|
||||
/**
|
||||
* Obtains the print data representation object that contains this doc
|
||||
* object's piece of print data in the format corresponding to the
|
||||
* supported doc flavor.
|
||||
* The <CODE>getPrintData()</CODE> method returns an instance of
|
||||
* the representation class whose name is given by <CODE>{@link
|
||||
* #getDocFlavor() getDocFlavor()}.{@link
|
||||
* DocFlavor#getRepresentationClassName()
|
||||
* getRepresentationClassName()}</CODE>, and the return value can be cast
|
||||
* from class Object to that representation class.
|
||||
*
|
||||
* @return Print data representation object.
|
||||
*
|
||||
* @exception IOException
|
||||
* Thrown if the representation class is a stream and there was an I/O
|
||||
* error while constructing the stream.
|
||||
*/
|
||||
public Object getPrintData() throws IOException;
|
||||
|
||||
/**
|
||||
* Obtains the set of printing attributes for this doc object. If the
|
||||
* returned attribute set includes an instance of a particular attribute
|
||||
* <I>X,</I> the printer must use that attribute value for this doc,
|
||||
* overriding any value of attribute <I>X</I> in the job's attribute set.
|
||||
* If the returned attribute set does not include an instance
|
||||
* of a particular attribute <I>X</I> or if null is returned, the printer
|
||||
* must consult the job's attribute set to obtain the value for
|
||||
* attribute <I>X,</I> and if not found there, the printer must use an
|
||||
* implementation-dependent default value. The returned attribute set is
|
||||
* unmodifiable.
|
||||
*
|
||||
* @return Unmodifiable set of printing attributes for this doc, or null
|
||||
* to obtain all attribute values from the job's attribute
|
||||
* set.
|
||||
*/
|
||||
public DocAttributeSet getAttributes();
|
||||
|
||||
/**
|
||||
* Obtains a reader for extracting character print data from this doc.
|
||||
* The Doc implementation is required to support this method if the
|
||||
* DocFlavor has one of the following print data representation classes,
|
||||
* and return null otherwise:
|
||||
* <UL>
|
||||
* <LI> char[]
|
||||
* <LI> java.lang.String
|
||||
* <LI> java.io.Reader
|
||||
* </UL>
|
||||
* The doc's print data representation object is used to construct and
|
||||
* return a Reader for reading the print data as a stream of characters
|
||||
* from the print data representation object.
|
||||
* However, if the print data representation object is itself a Reader,
|
||||
* then the print data representation object is simply returned.
|
||||
* <P>
|
||||
* @return Reader for reading the print data characters from this doc.
|
||||
* If a reader cannot be provided because this doc does not meet
|
||||
* the criteria stated above, null is returned.
|
||||
*
|
||||
* @exception IOException
|
||||
* Thrown if there was an I/O error while creating the reader.
|
||||
*/
|
||||
public Reader getReaderForText() throws IOException;
|
||||
|
||||
/**
|
||||
* Obtains an input stream for extracting byte print data from this
|
||||
* doc. The Doc implementation is required to support this method if
|
||||
* the DocFlavor has one of the following print data representation
|
||||
* classes, and return null otherwise:
|
||||
* <UL>
|
||||
* <LI> byte[]
|
||||
* <LI> java.io.InputStream
|
||||
* </UL>
|
||||
* This doc's print data representation object is obtained, then an input
|
||||
* stream for reading the print data from the print data representation
|
||||
* object as a stream of bytes is created and returned. However, if the
|
||||
* print data representation object is itself an input stream, then the
|
||||
* print data representation object is simply returned.
|
||||
* <P>
|
||||
* @return Input stream for reading the print data bytes from this doc. If
|
||||
* an input stream cannot be provided because this doc does not
|
||||
* meet the criteria stated above, null is returned.
|
||||
*
|
||||
* @exception IOException
|
||||
* Thrown if there was an I/O error while creating the input stream.
|
||||
*/
|
||||
public InputStream getStreamForBytes() throws IOException;
|
||||
|
||||
}
|
||||
1433
jdkSrc/jdk8/javax/print/DocFlavor.java
Normal file
1433
jdkSrc/jdk8/javax/print/DocFlavor.java
Normal file
File diff suppressed because it is too large
Load Diff
176
jdkSrc/jdk8/javax/print/DocPrintJob.java
Normal file
176
jdkSrc/jdk8/javax/print/DocPrintJob.java
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import javax.print.attribute.PrintJobAttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.event.PrintJobAttributeListener;
|
||||
import javax.print.event.PrintJobListener;
|
||||
import javax.print.PrintException;
|
||||
|
||||
/**
|
||||
*
|
||||
* This interface represents a print job that can print a specified
|
||||
* document with a set of job attributes. An object implementing
|
||||
* this interface is obtained from a print service.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface DocPrintJob {
|
||||
|
||||
/**
|
||||
* Determines the {@link PrintService} object to which this print job
|
||||
* object is bound.
|
||||
*
|
||||
* @return <code>PrintService</code> object.
|
||||
*
|
||||
*/
|
||||
public PrintService getPrintService();
|
||||
|
||||
/**
|
||||
* Obtains this Print Job's set of printing attributes.
|
||||
* The returned attribute set object is unmodifiable.
|
||||
* The returned attribute set object is a "snapshot" of this Print Job's
|
||||
* attribute set at the time of the {@link #getAttributes()} method
|
||||
* call; that is, the returned attribute set's object's contents will
|
||||
* not be updated if this Print Job's attribute set's contents change
|
||||
* in the future. To detect changes in attribute values, call
|
||||
* <code>getAttributes()</code> again and compare the new attribute
|
||||
* set to the previous attribute set; alternatively, register a
|
||||
* listener for print job events.
|
||||
* The returned value may be an empty set but should not be null.
|
||||
* @return the print job attributes
|
||||
*/
|
||||
public PrintJobAttributeSet getAttributes();
|
||||
|
||||
/**
|
||||
* Registers a listener for event occurring during this print job.
|
||||
* If listener is null, no exception is thrown and no action is
|
||||
* performed.
|
||||
* If listener is already registered, it will be registered again.
|
||||
* @see #removePrintJobListener
|
||||
*
|
||||
* @param listener The object implementing the listener interface
|
||||
*
|
||||
*/
|
||||
public void addPrintJobListener(PrintJobListener listener);
|
||||
|
||||
/**
|
||||
* Removes a listener from this print job.
|
||||
* This method performs no function, nor does it throw an exception,
|
||||
* if the listener specified by the argument was not previously added
|
||||
* to this component. If listener is null, no exception is thrown and
|
||||
* no action is performed. If a listener was registered more than once
|
||||
* only one of the registrations will be removed.
|
||||
* @see #addPrintJobListener
|
||||
*
|
||||
* @param listener The object implementing the listener interface
|
||||
*/
|
||||
public void removePrintJobListener(PrintJobListener listener);
|
||||
|
||||
/**
|
||||
* Registers a listener for changes in the specified attributes.
|
||||
* If listener is null, no exception is thrown and no action is
|
||||
* performed.
|
||||
* To determine the attribute updates that may be reported by this job,
|
||||
* a client can call <code>getAttributes()</code> and identify the
|
||||
* subset that are interesting and likely to be reported to the
|
||||
* listener. Clients expecting to be updated about changes in a
|
||||
* specific job attribute should verify it is in that set, but
|
||||
* updates about an attribute will be made only if it changes and this
|
||||
* is detected by the job. Also updates may be subject to batching
|
||||
* by the job. To minimize overhead in print job processing it is
|
||||
* recommended to listen on only that subset of attributes which
|
||||
* are likely to change.
|
||||
* If the specified set is empty no attribute updates will be reported
|
||||
* to the listener.
|
||||
* If the attribute set is null, then this means to listen on all
|
||||
* dynamic attributes that the job supports. This may result in no
|
||||
* update notifications if a job can not report any attribute updates.
|
||||
*
|
||||
* If listener is already registered, it will be registered again.
|
||||
* @see #removePrintJobAttributeListener
|
||||
*
|
||||
* @param listener The object implementing the listener interface
|
||||
* @param attributes The attributes to listen on, or null to mean
|
||||
* all attributes that can change, as determined by the job.
|
||||
*/
|
||||
public void addPrintJobAttributeListener(
|
||||
PrintJobAttributeListener listener,
|
||||
PrintJobAttributeSet attributes);
|
||||
|
||||
/**
|
||||
* Removes an attribute listener from this print job.
|
||||
* This method performs no function, nor does it throw an exception,
|
||||
* if the listener specified by the argument was not previously added
|
||||
* to this component. If the listener is null, no exception is thrown
|
||||
* and no action is performed.
|
||||
* If a listener is registered more than once, even for a different
|
||||
* set of attributes, no guarantee is made which listener is removed.
|
||||
* @see #addPrintJobAttributeListener
|
||||
*
|
||||
* @param listener The object implementing the listener interface
|
||||
*
|
||||
*/
|
||||
public void removePrintJobAttributeListener(
|
||||
PrintJobAttributeListener listener);
|
||||
|
||||
/**
|
||||
* Prints a document with the specified job attributes.
|
||||
* This method should only be called once for a given print job.
|
||||
* Calling it again will not result in a new job being spooled to
|
||||
* the printer. The service implementation will define policy
|
||||
* for service interruption and recovery.
|
||||
* When the print method returns, printing may not yet have completed as
|
||||
* printing may happen asynchronously, perhaps in a different thread.
|
||||
* Application clients which want to monitor the success or failure
|
||||
* should register a PrintJobListener.
|
||||
* <p>
|
||||
* Print service implementors should close any print data streams (ie
|
||||
* Reader or InputStream implementations) that they obtain
|
||||
* from the client doc. Robust clients may still wish to verify this.
|
||||
* An exception is always generated if a <code>DocFlavor</code> cannot
|
||||
* be printed.
|
||||
*
|
||||
* @param doc The document to be printed. If must be a flavor
|
||||
* supported by this PrintJob.
|
||||
*
|
||||
* @param attributes The job attributes to be applied to this print job.
|
||||
* If this parameter is null then the default attributes are used.
|
||||
* @throws PrintException The exception additionally may implement
|
||||
* an interface that more precisely describes the cause of the
|
||||
* exception
|
||||
* <ul>
|
||||
* <li>FlavorException.
|
||||
* If the document has a flavor not supported by this print job.
|
||||
* <li>AttributeException.
|
||||
* If one or more of the attributes are not valid for this print job.
|
||||
* </ul>
|
||||
*/
|
||||
public void print(Doc doc, PrintRequestAttributeSet attributes)
|
||||
throws PrintException;
|
||||
|
||||
}
|
||||
47
jdkSrc/jdk8/javax/print/FlavorException.java
Normal file
47
jdkSrc/jdk8/javax/print/FlavorException.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import javax.print.DocFlavor;
|
||||
|
||||
/**
|
||||
* Interface FlavorException is a mixin interface which a subclass of {@link
|
||||
* PrintException PrintException} can implement to report an error condition
|
||||
* involving a doc flavor or flavors (class {@link javax.print.DocFlavor
|
||||
* DocFlavor}). The Print Service API does not define any print exception
|
||||
* classes that implement interface FlavorException, that being left to the
|
||||
* Print Service implementor's discretion.
|
||||
*
|
||||
*/
|
||||
public interface FlavorException {
|
||||
|
||||
/**
|
||||
* Returns the unsupported flavors.
|
||||
* @return the unsupported doc flavors.
|
||||
*/
|
||||
public DocFlavor[] getUnsupportedFlavors();
|
||||
|
||||
}
|
||||
647
jdkSrc/jdk8/javax/print/MimeType.java
Normal file
647
jdkSrc/jdk8/javax/print/MimeType.java
Normal file
@@ -0,0 +1,647 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Class MimeType encapsulates a Multipurpose Internet Mail Extensions (MIME)
|
||||
* media type as defined in <A HREF="http://www.ietf.org/rfc/rfc2045.txt">RFC
|
||||
* 2045</A> and <A HREF="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</A>. A
|
||||
* MIME type object is part of a {@link DocFlavor DocFlavor} object and
|
||||
* specifies the format of the print data.
|
||||
* <P>
|
||||
* Class MimeType is similar to the like-named
|
||||
* class in package {@link java.awt.datatransfer java.awt.datatransfer}. Class
|
||||
* java.awt.datatransfer.MimeType is not used in the Jini Print Service API
|
||||
* for two reasons:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* Since not all Java profiles include the AWT, the Jini Print Service should
|
||||
* not depend on an AWT class.
|
||||
* <P>
|
||||
* <LI>
|
||||
* The implementation of class java.awt.datatransfer.MimeType does not
|
||||
* guarantee
|
||||
* that equivalent MIME types will have the same serialized representation.
|
||||
* Thus, since the Jini Lookup Service (JLUS) matches service attributes based
|
||||
* on equality of serialized representations, JLUS searches involving MIME
|
||||
* types encapsulated in class java.awt.datatransfer.MimeType may incorrectly
|
||||
* fail to match.
|
||||
* </OL>
|
||||
* <P>
|
||||
* Class MimeType's serialized representation is based on the following
|
||||
* canonical form of a MIME type string. Thus, two MIME types that are not
|
||||
* identical but that are equivalent (that have the same canonical form) will
|
||||
* be considered equal by the JLUS's matching algorithm.
|
||||
* <UL>
|
||||
* <LI> The media type, media subtype, and parameters are retained, but all
|
||||
* comments and whitespace characters are discarded.
|
||||
* <LI> The media type, media subtype, and parameter names are converted to
|
||||
* lowercase.
|
||||
* <LI> The parameter values retain their original case, except a charset
|
||||
* parameter value for a text media type is converted to lowercase.
|
||||
* <LI> Quote characters surrounding parameter values are removed.
|
||||
* <LI> Quoting backslash characters inside parameter values are removed.
|
||||
* <LI> The parameters are arranged in ascending order of parameter name.
|
||||
* </UL>
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
class MimeType implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -2785720609362367683L;
|
||||
|
||||
/**
|
||||
* Array of strings that hold pieces of this MIME type's canonical form.
|
||||
* If the MIME type has <I>n</I> parameters, <I>n</I> >= 0, then the
|
||||
* strings in the array are:
|
||||
* <BR>Index 0 -- Media type.
|
||||
* <BR>Index 1 -- Media subtype.
|
||||
* <BR>Index 2<I>i</I>+2 -- Name of parameter <I>i</I>,
|
||||
* <I>i</I>=0,1,...,<I>n</I>-1.
|
||||
* <BR>Index 2<I>i</I>+3 -- Value of parameter <I>i</I>,
|
||||
* <I>i</I>=0,1,...,<I>n</I>-1.
|
||||
* <BR>Parameters are arranged in ascending order of parameter name.
|
||||
* @serial
|
||||
*/
|
||||
private String[] myPieces;
|
||||
|
||||
/**
|
||||
* String value for this MIME type. Computed when needed and cached.
|
||||
*/
|
||||
private transient String myStringValue = null;
|
||||
|
||||
/**
|
||||
* Parameter map entry set. Computed when needed and cached.
|
||||
*/
|
||||
private transient ParameterMapEntrySet myEntrySet = null;
|
||||
|
||||
/**
|
||||
* Parameter map. Computed when needed and cached.
|
||||
*/
|
||||
private transient ParameterMap myParameterMap = null;
|
||||
|
||||
/**
|
||||
* Parameter map entry.
|
||||
*/
|
||||
private class ParameterMapEntry implements Map.Entry {
|
||||
private int myIndex;
|
||||
public ParameterMapEntry(int theIndex) {
|
||||
myIndex = theIndex;
|
||||
}
|
||||
public Object getKey(){
|
||||
return myPieces[myIndex];
|
||||
}
|
||||
public Object getValue(){
|
||||
return myPieces[myIndex+1];
|
||||
}
|
||||
public Object setValue (Object value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public boolean equals(Object o) {
|
||||
return (o != null &&
|
||||
o instanceof Map.Entry &&
|
||||
getKey().equals (((Map.Entry) o).getKey()) &&
|
||||
getValue().equals(((Map.Entry) o).getValue()));
|
||||
}
|
||||
public int hashCode() {
|
||||
return getKey().hashCode() ^ getValue().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter map entry set iterator.
|
||||
*/
|
||||
private class ParameterMapEntrySetIterator implements Iterator {
|
||||
private int myIndex = 2;
|
||||
public boolean hasNext() {
|
||||
return myIndex < myPieces.length;
|
||||
}
|
||||
public Object next() {
|
||||
if (hasNext()) {
|
||||
ParameterMapEntry result = new ParameterMapEntry (myIndex);
|
||||
myIndex += 2;
|
||||
return result;
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter map entry set.
|
||||
*/
|
||||
private class ParameterMapEntrySet extends AbstractSet {
|
||||
public Iterator iterator() {
|
||||
return new ParameterMapEntrySetIterator();
|
||||
}
|
||||
public int size() {
|
||||
return (myPieces.length - 2) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter map.
|
||||
*/
|
||||
private class ParameterMap extends AbstractMap {
|
||||
public Set entrySet() {
|
||||
if (myEntrySet == null) {
|
||||
myEntrySet = new ParameterMapEntrySet();
|
||||
}
|
||||
return myEntrySet;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new MIME type object from the given string. The given
|
||||
* string is converted into canonical form and stored internally.
|
||||
*
|
||||
* @param s MIME media type string.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>s</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>s</CODE> does not obey the
|
||||
* syntax for a MIME media type string.
|
||||
*/
|
||||
public MimeType(String s) {
|
||||
parse (s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this MIME type object's MIME type string based on the canonical
|
||||
* form. Each parameter value is enclosed in quotes.
|
||||
*/
|
||||
public String getMimeType() {
|
||||
return getStringValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this MIME type object's media type.
|
||||
*/
|
||||
public String getMediaType() {
|
||||
return myPieces[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this MIME type object's media subtype.
|
||||
*/
|
||||
public String getMediaSubtype() {
|
||||
return myPieces[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable map view of the parameters in this MIME type
|
||||
* object. Each entry in the parameter map view consists of a parameter
|
||||
* name String (key) mapping to a parameter value String. If this MIME
|
||||
* type object has no parameters, an empty map is returned.
|
||||
*
|
||||
* @return Parameter map for this MIME type object.
|
||||
*/
|
||||
public Map getParameterMap() {
|
||||
if (myParameterMap == null) {
|
||||
myParameterMap = new ParameterMap();
|
||||
}
|
||||
return myParameterMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this MIME type object to a string.
|
||||
*
|
||||
* @return MIME type string based on the canonical form. Each parameter
|
||||
* value is enclosed in quotes.
|
||||
*/
|
||||
public String toString() {
|
||||
return getStringValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this MIME type object.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getStringValue().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this MIME type object is equal to the given object. The two
|
||||
* are equal if the given object is not null, is an instance of class
|
||||
* net.jini.print.data.MimeType, and has the same canonical form as this
|
||||
* MIME type object (that is, has the same type, subtype, and parameters).
|
||||
* Thus, if two MIME type objects are the same except for comments, they are
|
||||
* considered equal. However, "text/plain" and "text/plain;
|
||||
* charset=us-ascii" are not considered equal, even though they represent
|
||||
* the same media type (because the default character set for plain text is
|
||||
* US-ASCII).
|
||||
*
|
||||
* @param obj Object to test.
|
||||
*
|
||||
* @return True if this MIME type object equals <CODE>obj</CODE>, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean equals (Object obj) {
|
||||
return(obj != null &&
|
||||
obj instanceof MimeType &&
|
||||
getStringValue().equals(((MimeType) obj).getStringValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this MIME type's string value in canonical form.
|
||||
*/
|
||||
private String getStringValue() {
|
||||
if (myStringValue == null) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append (myPieces[0]);
|
||||
result.append ('/');
|
||||
result.append (myPieces[1]);
|
||||
int n = myPieces.length;
|
||||
for (int i = 2; i < n; i += 2) {
|
||||
result.append(';');
|
||||
result.append(' ');
|
||||
result.append(myPieces[i]);
|
||||
result.append('=');
|
||||
result.append(addQuotes (myPieces[i+1]));
|
||||
}
|
||||
myStringValue = result.toString();
|
||||
}
|
||||
return myStringValue;
|
||||
}
|
||||
|
||||
// Hidden classes, constants, and operations for parsing a MIME media type
|
||||
// string.
|
||||
|
||||
// Lexeme types.
|
||||
private static final int TOKEN_LEXEME = 0;
|
||||
private static final int QUOTED_STRING_LEXEME = 1;
|
||||
private static final int TSPECIAL_LEXEME = 2;
|
||||
private static final int EOF_LEXEME = 3;
|
||||
private static final int ILLEGAL_LEXEME = 4;
|
||||
|
||||
// Class for a lexical analyzer.
|
||||
private static class LexicalAnalyzer {
|
||||
protected String mySource;
|
||||
protected int mySourceLength;
|
||||
protected int myCurrentIndex;
|
||||
protected int myLexemeType;
|
||||
protected int myLexemeBeginIndex;
|
||||
protected int myLexemeEndIndex;
|
||||
|
||||
public LexicalAnalyzer(String theSource) {
|
||||
mySource = theSource;
|
||||
mySourceLength = theSource.length();
|
||||
myCurrentIndex = 0;
|
||||
nextLexeme();
|
||||
}
|
||||
|
||||
public int getLexemeType() {
|
||||
return myLexemeType;
|
||||
}
|
||||
|
||||
public String getLexeme() {
|
||||
return(myLexemeBeginIndex >= mySourceLength ?
|
||||
null :
|
||||
mySource.substring(myLexemeBeginIndex, myLexemeEndIndex));
|
||||
}
|
||||
|
||||
public char getLexemeFirstCharacter() {
|
||||
return(myLexemeBeginIndex >= mySourceLength ?
|
||||
'\u0000' :
|
||||
mySource.charAt(myLexemeBeginIndex));
|
||||
}
|
||||
|
||||
public void nextLexeme() {
|
||||
int state = 0;
|
||||
int commentLevel = 0;
|
||||
char c;
|
||||
while (state >= 0) {
|
||||
switch (state) {
|
||||
// Looking for a token, quoted string, or tspecial
|
||||
case 0:
|
||||
if (myCurrentIndex >= mySourceLength) {
|
||||
myLexemeType = EOF_LEXEME;
|
||||
myLexemeBeginIndex = mySourceLength;
|
||||
myLexemeEndIndex = mySourceLength;
|
||||
state = -1;
|
||||
} else if (Character.isWhitespace
|
||||
(c = mySource.charAt (myCurrentIndex ++))) {
|
||||
state = 0;
|
||||
} else if (c == '\"') {
|
||||
myLexemeType = QUOTED_STRING_LEXEME;
|
||||
myLexemeBeginIndex = myCurrentIndex;
|
||||
state = 1;
|
||||
} else if (c == '(') {
|
||||
++ commentLevel;
|
||||
state = 3;
|
||||
} else if (c == '/' || c == ';' || c == '=' ||
|
||||
c == ')' || c == '<' || c == '>' ||
|
||||
c == '@' || c == ',' || c == ':' ||
|
||||
c == '\\' || c == '[' || c == ']' ||
|
||||
c == '?') {
|
||||
myLexemeType = TSPECIAL_LEXEME;
|
||||
myLexemeBeginIndex = myCurrentIndex - 1;
|
||||
myLexemeEndIndex = myCurrentIndex;
|
||||
state = -1;
|
||||
} else {
|
||||
myLexemeType = TOKEN_LEXEME;
|
||||
myLexemeBeginIndex = myCurrentIndex - 1;
|
||||
state = 5;
|
||||
}
|
||||
break;
|
||||
// In a quoted string
|
||||
case 1:
|
||||
if (myCurrentIndex >= mySourceLength) {
|
||||
myLexemeType = ILLEGAL_LEXEME;
|
||||
myLexemeBeginIndex = mySourceLength;
|
||||
myLexemeEndIndex = mySourceLength;
|
||||
state = -1;
|
||||
} else if ((c = mySource.charAt (myCurrentIndex ++)) == '\"') {
|
||||
myLexemeEndIndex = myCurrentIndex - 1;
|
||||
state = -1;
|
||||
} else if (c == '\\') {
|
||||
state = 2;
|
||||
} else {
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
// In a quoted string, backslash seen
|
||||
case 2:
|
||||
if (myCurrentIndex >= mySourceLength) {
|
||||
myLexemeType = ILLEGAL_LEXEME;
|
||||
myLexemeBeginIndex = mySourceLength;
|
||||
myLexemeEndIndex = mySourceLength;
|
||||
state = -1;
|
||||
} else {
|
||||
++ myCurrentIndex;
|
||||
state = 1;
|
||||
} break;
|
||||
// In a comment
|
||||
case 3: if (myCurrentIndex >= mySourceLength) {
|
||||
myLexemeType = ILLEGAL_LEXEME;
|
||||
myLexemeBeginIndex = mySourceLength;
|
||||
myLexemeEndIndex = mySourceLength;
|
||||
state = -1;
|
||||
} else if ((c = mySource.charAt (myCurrentIndex ++)) == '(') {
|
||||
++ commentLevel;
|
||||
state = 3;
|
||||
} else if (c == ')') {
|
||||
-- commentLevel;
|
||||
state = commentLevel == 0 ? 0 : 3;
|
||||
} else if (c == '\\') {
|
||||
state = 4;
|
||||
} else { state = 3;
|
||||
}
|
||||
break;
|
||||
// In a comment, backslash seen
|
||||
case 4:
|
||||
if (myCurrentIndex >= mySourceLength) {
|
||||
myLexemeType = ILLEGAL_LEXEME;
|
||||
myLexemeBeginIndex = mySourceLength;
|
||||
myLexemeEndIndex = mySourceLength;
|
||||
state = -1;
|
||||
} else {
|
||||
++ myCurrentIndex;
|
||||
state = 3;
|
||||
}
|
||||
break;
|
||||
// In a token
|
||||
case 5:
|
||||
if (myCurrentIndex >= mySourceLength) {
|
||||
myLexemeEndIndex = myCurrentIndex;
|
||||
state = -1;
|
||||
} else if (Character.isWhitespace
|
||||
(c = mySource.charAt (myCurrentIndex ++))) {
|
||||
myLexemeEndIndex = myCurrentIndex - 1;
|
||||
state = -1;
|
||||
} else if (c == '\"' || c == '(' || c == '/' ||
|
||||
c == ';' || c == '=' || c == ')' ||
|
||||
c == '<' || c == '>' || c == '@' ||
|
||||
c == ',' || c == ':' || c == '\\' ||
|
||||
c == '[' || c == ']' || c == '?') {
|
||||
-- myCurrentIndex;
|
||||
myLexemeEndIndex = myCurrentIndex;
|
||||
state = -1;
|
||||
} else {
|
||||
state = 5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a lowercase version of the given string. The lowercase version
|
||||
* is constructed by applying Character.toLowerCase() to each character of
|
||||
* the given string, which maps characters to lowercase using the rules of
|
||||
* Unicode. This mapping is the same regardless of locale, whereas the
|
||||
* mapping of String.toLowerCase() may be different depending on the
|
||||
* default locale.
|
||||
*/
|
||||
private static String toUnicodeLowerCase(String s) {
|
||||
int n = s.length();
|
||||
char[] result = new char [n];
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
result[i] = Character.toLowerCase (s.charAt (i));
|
||||
}
|
||||
return new String (result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version of the given string with backslashes removed.
|
||||
*/
|
||||
private static String removeBackslashes(String s) {
|
||||
int n = s.length();
|
||||
char[] result = new char [n];
|
||||
int i;
|
||||
int j = 0;
|
||||
char c;
|
||||
for (i = 0; i < n; ++ i) {
|
||||
c = s.charAt (i);
|
||||
if (c == '\\') {
|
||||
c = s.charAt (++ i);
|
||||
}
|
||||
result[j++] = c;
|
||||
}
|
||||
return new String (result, 0, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version of the string surrounded by quotes and with interior
|
||||
* quotes preceded by a backslash.
|
||||
*/
|
||||
private static String addQuotes(String s) {
|
||||
int n = s.length();
|
||||
int i;
|
||||
char c;
|
||||
StringBuffer result = new StringBuffer (n+2);
|
||||
result.append ('\"');
|
||||
for (i = 0; i < n; ++ i) {
|
||||
c = s.charAt (i);
|
||||
if (c == '\"') {
|
||||
result.append ('\\');
|
||||
}
|
||||
result.append (c);
|
||||
}
|
||||
result.append ('\"');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string into canonical pieces and stores the pieces in
|
||||
* {@link #myPieces <CODE>myPieces</CODE>}.
|
||||
* <P>
|
||||
* Special rules applied:
|
||||
* <UL>
|
||||
* <LI> If the media type is text, the value of a charset parameter is
|
||||
* converted to lowercase.
|
||||
* </UL>
|
||||
*
|
||||
* @param s MIME media type string.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>s</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>s</CODE> does not obey the
|
||||
* syntax for a MIME media type string.
|
||||
*/
|
||||
private void parse(String s) {
|
||||
// Initialize.
|
||||
if (s == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
LexicalAnalyzer theLexer = new LexicalAnalyzer (s);
|
||||
int theLexemeType;
|
||||
Vector thePieces = new Vector();
|
||||
boolean mediaTypeIsText = false;
|
||||
boolean parameterNameIsCharset = false;
|
||||
|
||||
// Parse media type.
|
||||
if (theLexer.getLexemeType() == TOKEN_LEXEME) {
|
||||
String mt = toUnicodeLowerCase (theLexer.getLexeme());
|
||||
thePieces.add (mt);
|
||||
theLexer.nextLexeme();
|
||||
mediaTypeIsText = mt.equals ("text");
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// Parse slash.
|
||||
if (theLexer.getLexemeType() == TSPECIAL_LEXEME &&
|
||||
theLexer.getLexemeFirstCharacter() == '/') {
|
||||
theLexer.nextLexeme();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (theLexer.getLexemeType() == TOKEN_LEXEME) {
|
||||
thePieces.add (toUnicodeLowerCase (theLexer.getLexeme()));
|
||||
theLexer.nextLexeme();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// Parse zero or more parameters.
|
||||
while (theLexer.getLexemeType() == TSPECIAL_LEXEME &&
|
||||
theLexer.getLexemeFirstCharacter() == ';') {
|
||||
// Parse semicolon.
|
||||
theLexer.nextLexeme();
|
||||
|
||||
// Parse parameter name.
|
||||
if (theLexer.getLexemeType() == TOKEN_LEXEME) {
|
||||
String pn = toUnicodeLowerCase (theLexer.getLexeme());
|
||||
thePieces.add (pn);
|
||||
theLexer.nextLexeme();
|
||||
parameterNameIsCharset = pn.equals ("charset");
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
// Parse equals.
|
||||
if (theLexer.getLexemeType() == TSPECIAL_LEXEME &&
|
||||
theLexer.getLexemeFirstCharacter() == '=') {
|
||||
theLexer.nextLexeme();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
// Parse parameter value.
|
||||
if (theLexer.getLexemeType() == TOKEN_LEXEME) {
|
||||
String pv = theLexer.getLexeme();
|
||||
thePieces.add(mediaTypeIsText && parameterNameIsCharset ?
|
||||
toUnicodeLowerCase (pv) :
|
||||
pv);
|
||||
theLexer.nextLexeme();
|
||||
} else if (theLexer.getLexemeType() == QUOTED_STRING_LEXEME) {
|
||||
String pv = removeBackslashes (theLexer.getLexeme());
|
||||
thePieces.add(mediaTypeIsText && parameterNameIsCharset ?
|
||||
toUnicodeLowerCase (pv) :
|
||||
pv);
|
||||
theLexer.nextLexeme();
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we've consumed everything.
|
||||
if (theLexer.getLexemeType() != EOF_LEXEME) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
// Save the pieces. Parameters are not in ascending order yet.
|
||||
int n = thePieces.size();
|
||||
myPieces = (String[]) thePieces.toArray (new String [n]);
|
||||
|
||||
// Sort the parameters into ascending order using an insertion sort.
|
||||
int i, j;
|
||||
String temp;
|
||||
for (i = 4; i < n; i += 2) {
|
||||
j = 2;
|
||||
while (j < i && myPieces[j].compareTo (myPieces[i]) <= 0) {
|
||||
j += 2;
|
||||
}
|
||||
while (j < i) {
|
||||
temp = myPieces[j];
|
||||
myPieces[j] = myPieces[i];
|
||||
myPieces[i] = temp;
|
||||
temp = myPieces[j+1];
|
||||
myPieces[j+1] = myPieces[i+1];
|
||||
myPieces[i+1] = temp;
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
136
jdkSrc/jdk8/javax/print/MultiDoc.java
Normal file
136
jdkSrc/jdk8/javax/print/MultiDoc.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Interface MultiDoc specifies the interface for an object that supplies more
|
||||
* than one piece of print data for a Print Job. "Doc" is a short,
|
||||
* easy-to-pronounce term that means "a piece of print data," and a "multidoc"
|
||||
* is a group of several docs. The client passes to the Print Job an object
|
||||
* that implements interface MultiDoc, and the Print Job calls methods on
|
||||
* that object to obtain the print data.
|
||||
* <P>
|
||||
* Interface MultiDoc provides an abstraction similar to a "linked list" of
|
||||
* docs. A multidoc object is like a node in the linked list, containing the
|
||||
* current doc in the list and a pointer to the next node (multidoc) in the
|
||||
* list. The Print Job can call the multidoc's {@link #getDoc()
|
||||
* getDoc()} method to get the current doc. When it's ready to go
|
||||
* on to the next doc, the Print Job can call the multidoc's {@link #next()
|
||||
* next()} method to get the next multidoc, which contains the
|
||||
* next doc. So Print Job code for accessing a multidoc might look like this:
|
||||
* <PRE>
|
||||
* void processMultiDoc(MultiDoc theMultiDoc) {
|
||||
*
|
||||
* MultiDoc current = theMultiDoc;
|
||||
|
||||
* while (current != null) {
|
||||
* processDoc (current.getDoc());
|
||||
* current = current.next();
|
||||
* }
|
||||
* }
|
||||
* </PRE>
|
||||
* <P>
|
||||
* Of course, interface MultiDoc can be implemented in any way that fulfills
|
||||
* the contract; it doesn't have to use a linked list in the implementation.
|
||||
* <P>
|
||||
* To get all the print data for a multidoc print job, a Print Service
|
||||
* proxy could use either of two patterns:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* The <B>interleaved</B> pattern: Get the doc from the current multidoc. Get
|
||||
* the print data representation object from the current doc. Get all the print
|
||||
* data from the print data representation object. Get the next multidoc from
|
||||
* the current multidoc, and repeat until there are no more. (The code example
|
||||
* above uses the interleaved pattern.)
|
||||
* <P>
|
||||
* <LI>
|
||||
* The <B>all-at-once</B> pattern: Get the doc from the current multidoc, and
|
||||
* save the doc in a list. Get the next multidoc from the current multidoc, and
|
||||
* repeat until there are no more. Then iterate over the list of saved docs. Get
|
||||
* the print data representation object from the current doc. Get all the print
|
||||
* data from the print data representation object. Go to the next doc in the
|
||||
* list, and repeat until there are no more.
|
||||
* </OL>
|
||||
* Now, consider a printing client that is generating print data on the fly and
|
||||
* does not have the resources to store more than one piece of print data at a
|
||||
* time. If the print service proxy used the all-at-once pattern to get the
|
||||
* print data, it would pose a problem for such a client; the client would have
|
||||
* to keep all the docs' print data around until the print service proxy comes
|
||||
* back and asks for them, which the client is not able to do. To work with such
|
||||
* a client, the print service proxy must use the interleaved pattern.
|
||||
* <P>
|
||||
* To address this problem, and to simplify the design of clients providing
|
||||
* multiple docs to a Print Job, every Print Service proxy that supports
|
||||
* multidoc print jobs is required to access a MultiDoc object using the
|
||||
* interleaved pattern. That is, given a MultiDoc object, the print service
|
||||
* proxy will call {@link #getDoc() getDoc()} one or more times
|
||||
* until it successfully obtains the current Doc object. The print service proxy
|
||||
* will then obtain the current doc's print data, not proceeding until all the
|
||||
* print data is obtained or an unrecoverable error occurs. If it is able to
|
||||
* continue, the print service proxy will then call {@link #next()
|
||||
* next()} one or more times until it successfully obtains either
|
||||
* the next MultiDoc object or an indication that there are no more. An
|
||||
* implementation of interface MultiDoc can assume the print service proxy will
|
||||
* follow this interleaved pattern; for any other pattern of usage, the MultiDoc
|
||||
* implementation's behavior is unspecified.
|
||||
* <P>
|
||||
* There is no restriction on the number of client threads that may be
|
||||
* simultaneously accessing the same multidoc. Therefore, all implementations of
|
||||
* interface MultiDoc must be designed to be multiple thread safe. In fact, a
|
||||
* client thread could be adding docs to the end of the (conceptual) list while
|
||||
* a Print Job thread is simultaneously obtaining docs from the beginning of the
|
||||
* list; provided the multidoc object synchronizes the threads properly, the two
|
||||
* threads will not interfere with each other
|
||||
*/
|
||||
|
||||
public interface MultiDoc {
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the current doc object.
|
||||
*
|
||||
* @return Current doc object.
|
||||
*
|
||||
* @exception IOException
|
||||
* Thrown if a error occurred reading the document.
|
||||
*/
|
||||
public Doc getDoc() throws IOException;
|
||||
|
||||
/**
|
||||
* Go to the multidoc object that contains the next doc object in the
|
||||
* sequence of doc objects.
|
||||
*
|
||||
* @return Multidoc object containing the next doc object, or null if
|
||||
* there are no further doc objects.
|
||||
*
|
||||
* @exception IOException
|
||||
* Thrown if an error occurred locating the next document
|
||||
*/
|
||||
public MultiDoc next() throws IOException;
|
||||
|
||||
}
|
||||
67
jdkSrc/jdk8/javax/print/MultiDocPrintJob.java
Normal file
67
jdkSrc/jdk8/javax/print/MultiDocPrintJob.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
|
||||
/**
|
||||
*
|
||||
* Obtained from a MultiDocPrintService, a MultiDocPrintJob can print a
|
||||
* specified collection of documents as a single print job with a set of
|
||||
* job attributes.
|
||||
* <P>
|
||||
*/
|
||||
|
||||
public interface MultiDocPrintJob extends DocPrintJob {
|
||||
|
||||
/**
|
||||
* Print a MultiDoc with the specified job attributes.
|
||||
* This method should only be called once for a given print job.
|
||||
* Calling it again will not result in a new job being spooled to
|
||||
* the printer. The service implementation will define policy
|
||||
* for service interruption and recovery. Application clients which
|
||||
* want to monitor the success or failure should register a
|
||||
* PrintJobListener.
|
||||
*
|
||||
* @param multiDoc The documents to be printed. ALL must be a flavor
|
||||
* supported by the PrintJob {@literal &} PrintService.
|
||||
*
|
||||
* @param attributes The job attributes to be applied to this print job.
|
||||
* If this parameter is null then the default attributes are used.
|
||||
*
|
||||
* @throws PrintException The exception additionally may implement
|
||||
* an interfaces which more precisely describes the cause of the exception
|
||||
* <ul>
|
||||
* <li>FlavorException.
|
||||
* If the document has a flavor not supported by this print job.
|
||||
* <li>AttributeException.
|
||||
* If one or more of the attributes are not valid for this print job.
|
||||
* </ul>
|
||||
*/
|
||||
public void print(MultiDoc multiDoc, PrintRequestAttributeSet attributes)
|
||||
throws PrintException;
|
||||
|
||||
}
|
||||
42
jdkSrc/jdk8/javax/print/MultiDocPrintService.java
Normal file
42
jdkSrc/jdk8/javax/print/MultiDocPrintService.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
|
||||
/** Interface MultiPrintService is the factory for a MultiDocPrintJob.
|
||||
* A MultiPrintService
|
||||
* describes the capabilities of a Printer and can be queried regarding
|
||||
* a printer's supported attributes.
|
||||
*/
|
||||
public interface MultiDocPrintService extends PrintService {
|
||||
|
||||
/**
|
||||
* Create a job which can print a multiDoc.
|
||||
* @return a MultiDocPrintJob
|
||||
*/
|
||||
public MultiDocPrintJob createMultiDocPrintJob();
|
||||
|
||||
}
|
||||
73
jdkSrc/jdk8/javax/print/PrintException.java
Normal file
73
jdkSrc/jdk8/javax/print/PrintException.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
/**
|
||||
* Class PrintException encapsulates a printing-related error condition that
|
||||
* occurred while using a Print Service instance. This base class
|
||||
* furnishes only a string description of the error. Subclasses furnish more
|
||||
* detailed information if applicable.
|
||||
*
|
||||
*/
|
||||
public class PrintException extends Exception {
|
||||
|
||||
|
||||
/**
|
||||
* Construct a print exception with no detail message.
|
||||
*/
|
||||
public PrintException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a print exception with the given detail message.
|
||||
*
|
||||
* @param s Detail message, or null if no detail message.
|
||||
*/
|
||||
public PrintException (String s) {
|
||||
super (s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a print exception chaining the supplied exception.
|
||||
*
|
||||
* @param e Chained exception.
|
||||
*/
|
||||
public PrintException (Exception e) {
|
||||
super ( e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a print exception with the given detail message
|
||||
* and chained exception.
|
||||
* @param s Detail message, or null if no detail message.
|
||||
* @param e Chained exception.
|
||||
*/
|
||||
public PrintException (String s, Exception e) {
|
||||
super (s, e);
|
||||
}
|
||||
|
||||
}
|
||||
488
jdkSrc/jdk8/javax/print/PrintService.java
Normal file
488
jdkSrc/jdk8/javax/print/PrintService.java
Normal file
@@ -0,0 +1,488 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.AttributeSet;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
import javax.print.attribute.PrintServiceAttributeSet;
|
||||
import javax.print.event.PrintServiceAttributeListener;
|
||||
|
||||
|
||||
/**
|
||||
* Interface PrintService is the factory for a DocPrintJob. A PrintService
|
||||
* describes the capabilities of a Printer and can be queried regarding
|
||||
* a printer's supported attributes.
|
||||
* <P>
|
||||
* Example:
|
||||
* <PRE>{@code
|
||||
* DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
|
||||
* PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
|
||||
* aset.add(MediaSizeName.ISO_A4);
|
||||
* PrintService[] pservices =
|
||||
* PrintServiceLookup.lookupPrintServices(flavor, aset);
|
||||
* if (pservices.length > 0) {
|
||||
* DocPrintJob pj = pservices[0].createPrintJob();
|
||||
* try {
|
||||
* FileInputStream fis = new FileInputStream("test.ps");
|
||||
* Doc doc = new SimpleDoc(fis, flavor, null);
|
||||
* pj.print(doc, aset);
|
||||
* } catch (FileNotFoundException fe) {
|
||||
* } catch (PrintException e) {
|
||||
* }
|
||||
* }
|
||||
* }</PRE>
|
||||
*/
|
||||
public interface PrintService {
|
||||
|
||||
/** Returns a String name for this print service which may be used
|
||||
* by applications to request a particular print service.
|
||||
* In a suitable context, such as a name service, this name must be
|
||||
* unique.
|
||||
* In some environments this unique name may be the same as the user
|
||||
* friendly printer name defined as the
|
||||
* {@link javax.print.attribute.standard.PrinterName PrinterName}
|
||||
* attribute.
|
||||
* @return name of the service.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Creates and returns a PrintJob capable of handling data from
|
||||
* any of the supported document flavors.
|
||||
* @return a DocPrintJob object
|
||||
*/
|
||||
public DocPrintJob createPrintJob();
|
||||
|
||||
/**
|
||||
* Registers a listener for events on this PrintService.
|
||||
* @param listener a PrintServiceAttributeListener, which
|
||||
* monitors the status of a print service
|
||||
* @see #removePrintServiceAttributeListener
|
||||
*/
|
||||
public void addPrintServiceAttributeListener(
|
||||
PrintServiceAttributeListener listener);
|
||||
|
||||
/**
|
||||
* Removes the print-service listener from this print service.
|
||||
* This means the listener is no longer interested in
|
||||
* <code>PrintService</code> events.
|
||||
* @param listener a PrintServiceAttributeListener object
|
||||
* @see #addPrintServiceAttributeListener
|
||||
*/
|
||||
public void removePrintServiceAttributeListener(
|
||||
PrintServiceAttributeListener listener);
|
||||
|
||||
/**
|
||||
* Obtains this print service's set of printer description attributes
|
||||
* giving this Print Service's status. The returned attribute set object
|
||||
* is unmodifiable. The returned attribute set object is a "snapshot" of
|
||||
* this Print Service's attribute set at the time of the
|
||||
* <CODE>getAttributes()</CODE> method call: that is, the returned
|
||||
* attribute set's contents will <I>not</I> be updated if this print
|
||||
* service's attribute set's contents change in the future. To detect
|
||||
* changes in attribute values, call <CODE>getAttributes()</CODE> again
|
||||
* and compare the new attribute set to the previous attribute set;
|
||||
* alternatively, register a listener for print service events.
|
||||
*
|
||||
* @return Unmodifiable snapshot of this Print Service's attribute set.
|
||||
* May be empty, but not null.
|
||||
*/
|
||||
public PrintServiceAttributeSet getAttributes();
|
||||
|
||||
/**
|
||||
* Gets the value of the single specified service attribute.
|
||||
* This may be useful to clients which only need the value of one
|
||||
* attribute and want to minimize overhead.
|
||||
* @param category the category of a PrintServiceAttribute supported
|
||||
* by this service - may not be null.
|
||||
* @return the value of the supported attribute or null if the
|
||||
* attribute is not supported by this service.
|
||||
* @exception NullPointerException if the category is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) if <CODE>category</CODE> is not a
|
||||
* <code>Class</code> that implements interface
|
||||
*{@link javax.print.attribute.PrintServiceAttribute PrintServiceAttribute}.
|
||||
*/
|
||||
public <T extends PrintServiceAttribute>
|
||||
T getAttribute(Class<T> category);
|
||||
|
||||
/**
|
||||
* Determines the print data formats a client can specify when setting
|
||||
* up a job for this <code>PrintService</code>. A print data format is
|
||||
* designated by a "doc
|
||||
* flavor" (class {@link javax.print.DocFlavor DocFlavor})
|
||||
* consisting of a MIME type plus a print data representation class.
|
||||
* <P>
|
||||
* Note that some doc flavors may not be supported in combination
|
||||
* with all attributes. Use <code>getUnsupportedAttributes(..)</code>
|
||||
* to validate specific combinations.
|
||||
*
|
||||
* @return Array of supported doc flavors, should have at least
|
||||
* one element.
|
||||
*
|
||||
*/
|
||||
public DocFlavor[] getSupportedDocFlavors();
|
||||
|
||||
/**
|
||||
* Determines if this print service supports a specific
|
||||
* <code>DocFlavor</code>. This is a convenience method to determine
|
||||
* if the <code>DocFlavor</code> would be a member of the result of
|
||||
* <code>getSupportedDocFlavors()</code>.
|
||||
* <p>
|
||||
* Note that some doc flavors may not be supported in combination
|
||||
* with all attributes. Use <code>getUnsupportedAttributes(..)</code>
|
||||
* to validate specific combinations.
|
||||
*
|
||||
* @param flavor the <code>DocFlavor</code>to query for support.
|
||||
* @return <code>true</code> if this print service supports the
|
||||
* specified <code>DocFlavor</code>; <code>false</code> otherwise.
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>flavor</CODE> is null.
|
||||
*/
|
||||
public boolean isDocFlavorSupported(DocFlavor flavor);
|
||||
|
||||
|
||||
/**
|
||||
* Determines the printing attribute categories a client can specify
|
||||
* when setting up a job for this print service.
|
||||
* A printing attribute category is
|
||||
* designated by a <code>Class</code> that implements interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}. This method returns
|
||||
* just the attribute <I>categories</I> that are supported; it does not
|
||||
* return the particular attribute <I>values</I> that are supported.
|
||||
* <P>
|
||||
* 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 <code>DocFlavor</code>).
|
||||
* Use one of the methods that include a <code>DocFlavor</code> to
|
||||
* validate the request before submitting it, such as
|
||||
* <code>getSupportedAttributeValues(..)</code>.
|
||||
*
|
||||
* @return Array of printing attribute categories that the client can
|
||||
* specify as a doc-level or job-level attribute in a Print
|
||||
* Request. Each element in the array is a {@link java.lang.Class
|
||||
* Class} that implements interface {@link
|
||||
* javax.print.attribute.Attribute Attribute}.
|
||||
* The array is empty if no categories are supported.
|
||||
*/
|
||||
public Class<?>[] getSupportedAttributeCategories();
|
||||
|
||||
/**
|
||||
* Determines whether a client can specify the given printing
|
||||
* attribute category when setting up a job for this print service. A
|
||||
* printing attribute category is designated by a <code>Class</code>
|
||||
* that implements interface {@link javax.print.attribute.Attribute
|
||||
* Attribute}. This method tells whether the attribute <I>category</I> is
|
||||
* supported; it does not tell whether a particular attribute <I>value</I>
|
||||
* is supported.
|
||||
* <p>
|
||||
* Some categories may not be supported in a particular context (ie
|
||||
* for a particular <code>DocFlavor</code>).
|
||||
* Use one of the methods which include a <code>DocFlavor</code> to
|
||||
* validate the request before submitting it, such as
|
||||
* <code>getSupportedAttributeValues(..)</code>.
|
||||
* <P>
|
||||
* This is a convenience method to determine if the category
|
||||
* would be a member of the result of
|
||||
* <code>getSupportedAttributeCategories()</code>.
|
||||
*
|
||||
* @param category Printing attribute category to test. It must be a
|
||||
* <code>Class</code> that implements
|
||||
* interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}.
|
||||
*
|
||||
* @return <code>true</code> if this print service supports
|
||||
* specifying a doc-level or
|
||||
* job-level attribute in <CODE>category</CODE> in a Print
|
||||
* Request; <code>false</code> if it doesn't.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>category</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>category</CODE> is not a
|
||||
* <code>Class</code> that implements interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}.
|
||||
*/
|
||||
public boolean
|
||||
isAttributeCategorySupported(Class<? extends Attribute> category);
|
||||
|
||||
/**
|
||||
* Determines this print service's default printing attribute value in
|
||||
* the given category. A printing attribute value is an instance of
|
||||
* a class that implements interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}. If a client sets
|
||||
* up a print job and does not specify any attribute value in the
|
||||
* given category, this Print Service will use the
|
||||
* default attribute value instead.
|
||||
* <p>
|
||||
* Some attributes may not be supported in a particular context (ie
|
||||
* for a particular <code>DocFlavor</code>).
|
||||
* Use one of the methods that include a <code>DocFlavor</code> to
|
||||
* validate the request before submitting it, such as
|
||||
* <code>getSupportedAttributeValues(..)</code>.
|
||||
* <P>
|
||||
* Not all attributes have a default value. For example the
|
||||
* service will not have a defaultvalue for <code>RequestingUser</code>
|
||||
* i.e. a null return for a supported category means there is no
|
||||
* service default value for that category. Use the
|
||||
* <code>isAttributeCategorySupported(Class)</code> method to
|
||||
* distinguish these cases.
|
||||
*
|
||||
* @param category Printing attribute category for which the default
|
||||
* attribute value is requested. It must be a {@link
|
||||
* java.lang.Class Class} that implements interface
|
||||
* {@link javax.print.attribute.Attribute
|
||||
* Attribute}.
|
||||
*
|
||||
* @return Default attribute value for <CODE>category</CODE>, or null
|
||||
* if this Print Service does not support specifying a doc-level or
|
||||
* job-level attribute in <CODE>category</CODE> in a Print
|
||||
* Request, or the service does not have a default value
|
||||
* for this attribute.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>category</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>category</CODE> is not a
|
||||
* {@link java.lang.Class Class} that implements interface {@link
|
||||
* javax.print.attribute.Attribute Attribute}.
|
||||
*/
|
||||
public Object
|
||||
getDefaultAttributeValue(Class<? extends Attribute> category);
|
||||
|
||||
/**
|
||||
* Determines the printing attribute values a client can specify in
|
||||
* the given category when setting up a job for this print service. A
|
||||
* printing
|
||||
* attribute value is an instance of a class that implements interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}.
|
||||
* <P>
|
||||
* If <CODE>flavor</CODE> is null and <CODE>attributes</CODE> is null
|
||||
* or is an empty set, this method returns all the printing attribute
|
||||
* values this Print Service supports for any possible job. If
|
||||
* <CODE>flavor</CODE> is not null or <CODE>attributes</CODE> 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.
|
||||
* <P>
|
||||
* If the <code>attributes</code> parameter contains an Attribute whose
|
||||
* category is the same as the <code>category</code> parameter, the service
|
||||
* must ignore this attribute in the AttributeSet.
|
||||
* <p>
|
||||
* <code>DocAttribute</code>s which are to be specified on the
|
||||
* <code>Doc</code> must be included in this set to accurately
|
||||
* represent the context.
|
||||
* <p>
|
||||
* 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 {@link
|
||||
* javax.print.attribute.standard javax.print.attribute.standard}
|
||||
* describes how each attribute indicates its supported values. Possible
|
||||
* ways of indicating support include:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* Return a single instance of the attribute category to indicate that any
|
||||
* value is legal -- used, for example, by an attribute whose value is an
|
||||
* arbitrary text string. (The value of the returned attribute object is
|
||||
* irrelevant.)
|
||||
* <LI>
|
||||
* Return an array of one or more instances of the attribute category,
|
||||
* containing the legal values -- used, for example, by an attribute with
|
||||
* a list of enumerated values. The type of the array is an array of the
|
||||
* specified attribute category type as returned by its
|
||||
* <code>getCategory(Class)</code>.
|
||||
* <LI>
|
||||
* Return a single object (of some class other than the attribute category)
|
||||
* that indicates bounds on the legal values -- used, for example, by an
|
||||
* integer-valued attribute that must lie within a certain range.
|
||||
* </UL>
|
||||
* <P>
|
||||
*
|
||||
* @param category Printing attribute category to test. It must be a
|
||||
* {@link java.lang.Class Class} that implements
|
||||
* interface {@link
|
||||
* javax.print.attribute.Attribute Attribute}.
|
||||
* @param flavor Doc flavor for a supposed job, or null.
|
||||
* @param attributes Set of printing attributes for a supposed job
|
||||
* (both job-level attributes and document-level
|
||||
* attributes), or null.
|
||||
*
|
||||
* @return Object indicating supported values for <CODE>category</CODE>,
|
||||
* or null if this Print Service does not support specifying a
|
||||
* doc-level or job-level attribute in <CODE>category</CODE> in
|
||||
* a Print Request.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>category</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>category</CODE> is not a
|
||||
* {@link java.lang.Class Class} that implements interface {@link
|
||||
* javax.print.attribute.Attribute Attribute}, or
|
||||
* <code>DocFlavor</code> is not supported by this service.
|
||||
*/
|
||||
public Object
|
||||
getSupportedAttributeValues(Class<? extends Attribute> category,
|
||||
DocFlavor flavor,
|
||||
AttributeSet attributes);
|
||||
|
||||
/**
|
||||
* Determines whether a client can specify the given printing
|
||||
* attribute
|
||||
* value when setting up a job for this Print Service. A printing
|
||||
* attribute value is an instance of a class that implements interface
|
||||
* {@link javax.print.attribute.Attribute Attribute}.
|
||||
* <P>
|
||||
* If <CODE>flavor</CODE> is null and <CODE>attributes</CODE> 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 <CODE>flavor</CODE> is not null or
|
||||
* <CODE>attributes</CODE> 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.
|
||||
* <p>
|
||||
* Also if DocFlavor is not null it must be a flavor supported by this
|
||||
* PrintService, else IllegalArgumentException will be thrown.
|
||||
* <p>
|
||||
* <code>DocAttribute</code>s which are to be specified on the
|
||||
* <code>Doc</code> must be included in this set to accurately
|
||||
* represent the context.
|
||||
* <p>
|
||||
* This is a convenience method to determine if the value
|
||||
* would be a member of the result of
|
||||
* <code>getSupportedAttributeValues(...)</code>.
|
||||
*
|
||||
* @param attrval Printing attribute value to test.
|
||||
* @param flavor Doc flavor for a supposed job, or null.
|
||||
* @param attributes Set of printing attributes for a supposed job
|
||||
* (both job-level attributes and document-level
|
||||
* attributes), or null.
|
||||
*
|
||||
* @return True if this Print Service supports specifying
|
||||
* <CODE>attrval</CODE> as a doc-level or job-level attribute in a
|
||||
* Print Request, false if it doesn't.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) if <CODE>attrval</CODE> is null.
|
||||
* @exception IllegalArgumentException if flavor is not supported by
|
||||
* this PrintService.
|
||||
*/
|
||||
public boolean isAttributeValueSupported(Attribute attrval,
|
||||
DocFlavor flavor,
|
||||
AttributeSet attributes);
|
||||
|
||||
|
||||
/**
|
||||
* Identifies the attributes that are unsupported for a print request
|
||||
* in the context of a particular DocFlavor.
|
||||
* This method is useful for validating a potential print job and
|
||||
* identifying the specific attributes which cannot be supported.
|
||||
* It is important to supply only a supported DocFlavor or an
|
||||
* IllegalArgumentException will be thrown. If the
|
||||
* return value from this method is null, all attributes are supported.
|
||||
* <p>
|
||||
* <code>DocAttribute</code>s which are to be specified on the
|
||||
* <code>Doc</code> must be included in this set to accurately
|
||||
* represent the context.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <p>
|
||||
* Use <code>isDocFlavorSupported()</code> to verify that a DocFlavor
|
||||
* is supported before calling this method.
|
||||
*
|
||||
* @param flavor Doc flavor to test, or null
|
||||
* @param attributes Set of printing attributes for a supposed job
|
||||
* (both job-level attributes and document-level
|
||||
* attributes), or null.
|
||||
*
|
||||
* @return null if this Print Service supports the print request
|
||||
* specification, else the unsupported attributes.
|
||||
*
|
||||
* @exception IllegalArgumentException if<CODE>flavor</CODE> is
|
||||
* not supported by this PrintService.
|
||||
*/
|
||||
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
|
||||
AttributeSet attributes);
|
||||
|
||||
/**
|
||||
* Returns a factory for UI components which allow users to interact
|
||||
* with the service in various roles.
|
||||
* Services which do not provide any UI should return null.
|
||||
* Print Services which do provide UI but want to be supported in
|
||||
* an environment with no UI support should ensure that the factory
|
||||
* is not initialised unless the application calls this method to
|
||||
* obtain the factory.
|
||||
* See <code>ServiceUIFactory</code> for more information.
|
||||
* @return null or a factory for UI components.
|
||||
*/
|
||||
public ServiceUIFactory getServiceUIFactory();
|
||||
|
||||
/**
|
||||
* Determines if two services are referring to the same underlying
|
||||
* service. Objects encapsulating a print service may not exhibit
|
||||
* equality of reference even though they refer to the same underlying
|
||||
* service.
|
||||
* <p>
|
||||
* Clients should call this method to determine if two services are
|
||||
* referring to the same underlying service.
|
||||
* <p>
|
||||
* 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.
|
||||
* @param obj the reference object with which to compare.
|
||||
* @return true if this service is the same as the obj argument,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean equals(Object obj);
|
||||
|
||||
/**
|
||||
* This method should be implemented consistently with
|
||||
* <code>equals(Object)</code>.
|
||||
* @return hash code of this object.
|
||||
*/
|
||||
public int hashCode();
|
||||
|
||||
}
|
||||
488
jdkSrc/jdk8/javax/print/PrintServiceLookup.java
Normal file
488
jdkSrc/jdk8/javax/print/PrintServiceLookup.java
Normal file
@@ -0,0 +1,488 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import javax.print.attribute.AttributeSet;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.ServiceConfigurationError;
|
||||
|
||||
/** Implementations of this class provide lookup services for
|
||||
* print services (typically equivalent to printers) of a particular type.
|
||||
* <p>
|
||||
* Multiple implementations may be installed concurrently.
|
||||
* All implementations must be able to describe the located printers
|
||||
* as instances of a PrintService.
|
||||
* Typically implementations of this service class are located
|
||||
* automatically in JAR files (see the SPI JAR file specification).
|
||||
* These classes must be instantiable using a default constructor.
|
||||
* Alternatively applications may explicitly register instances
|
||||
* at runtime.
|
||||
* <p>
|
||||
* Applications use only the static methods of this abstract class.
|
||||
* The instance methods are implemented by a service provider in a subclass
|
||||
* and the unification of the results from all installed lookup classes
|
||||
* are reported by the static methods of this class when called by
|
||||
* the application.
|
||||
* <p>
|
||||
* A PrintServiceLookup implementor is recommended to check for the
|
||||
* SecurityManager.checkPrintJobAccess() to deny access to untrusted code.
|
||||
* Following this recommended policy means that untrusted code may not
|
||||
* be able to locate any print services. Downloaded applets are the most
|
||||
* common example of untrusted code.
|
||||
* <p>
|
||||
* This check is made on a per lookup service basis to allow flexibility in
|
||||
* the policy to reflect the needs of different lookup services.
|
||||
* <p>
|
||||
* Services which are registered by registerService(PrintService)
|
||||
* will not be included in lookup results if a security manager is
|
||||
* installed and its checkPrintJobAccess() method denies access.
|
||||
*/
|
||||
|
||||
public abstract class PrintServiceLookup {
|
||||
|
||||
static class Services {
|
||||
private ArrayList listOfLookupServices = null;
|
||||
private ArrayList registeredServices = null;
|
||||
}
|
||||
|
||||
private static Services getServicesForContext() {
|
||||
Services services =
|
||||
(Services)AppContext.getAppContext().get(Services.class);
|
||||
if (services == null) {
|
||||
services = new Services();
|
||||
AppContext.getAppContext().put(Services.class, services);
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
private static ArrayList getListOfLookupServices() {
|
||||
return getServicesForContext().listOfLookupServices;
|
||||
}
|
||||
|
||||
private static ArrayList initListOfLookupServices() {
|
||||
ArrayList listOfLookupServices = new ArrayList();
|
||||
getServicesForContext().listOfLookupServices = listOfLookupServices;
|
||||
return listOfLookupServices;
|
||||
}
|
||||
|
||||
|
||||
private static ArrayList getRegisteredServices() {
|
||||
return getServicesForContext().registeredServices;
|
||||
}
|
||||
|
||||
private static ArrayList initRegisteredServices() {
|
||||
ArrayList registeredServices = new ArrayList();
|
||||
getServicesForContext().registeredServices = registeredServices;
|
||||
return registeredServices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates print services capable of printing the specified
|
||||
* {@link DocFlavor}.
|
||||
*
|
||||
* @param flavor the flavor to print. If null, this constraint is not
|
||||
* used.
|
||||
* @param attributes attributes that the print service must support.
|
||||
* If null this constraint is not used.
|
||||
*
|
||||
* @return array of matching <code>PrintService</code> objects
|
||||
* representing print services that support the specified flavor
|
||||
* attributes. If no services match, the array is zero-length.
|
||||
*/
|
||||
public static final PrintService[]
|
||||
lookupPrintServices(DocFlavor flavor,
|
||||
AttributeSet attributes) {
|
||||
ArrayList list = getServices(flavor, attributes);
|
||||
return (PrintService[])(list.toArray(new PrintService[list.size()]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates MultiDoc print Services capable of printing MultiDocs
|
||||
* containing all the specified doc flavors.
|
||||
* <P> This method is useful to help locate a service that can print
|
||||
* a <code>MultiDoc</code> in which the elements may be different
|
||||
* flavors. An application could perform this itself by multiple lookups
|
||||
* on each <code>DocFlavor</code> in turn and collating the results,
|
||||
* but the lookup service may be able to do this more efficiently.
|
||||
*
|
||||
* @param flavors the flavors to print. If null or empty this
|
||||
* constraint is not used.
|
||||
* Otherwise return only multidoc print services that can print all
|
||||
* specified doc flavors.
|
||||
* @param attributes attributes that the print service must
|
||||
* support. If null this constraint is not used.
|
||||
*
|
||||
* @return array of matching {@link MultiDocPrintService} objects.
|
||||
* If no services match, the array is zero-length.
|
||||
*
|
||||
*/
|
||||
public static final MultiDocPrintService[]
|
||||
lookupMultiDocPrintServices(DocFlavor[] flavors,
|
||||
AttributeSet attributes) {
|
||||
ArrayList list = getMultiDocServices(flavors, attributes);
|
||||
return (MultiDocPrintService[])
|
||||
list.toArray(new MultiDocPrintService[list.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates the default print service for this environment.
|
||||
* This may return null.
|
||||
* If multiple lookup services each specify a default, the
|
||||
* chosen service is not precisely defined, but a
|
||||
* platform native service, rather than an installed service,
|
||||
* is usually returned as the default. If there is no clearly
|
||||
* identifiable
|
||||
* platform native default print service, the default is the first
|
||||
* to be located in an implementation-dependent manner.
|
||||
* <p>
|
||||
* This may include making use of any preferences API that is available
|
||||
* as part of the Java or native platform.
|
||||
* This algorithm may be overridden by a user setting the property
|
||||
* javax.print.defaultPrinter.
|
||||
* A service specified must be discovered to be valid and currently
|
||||
* available to be returned as the default.
|
||||
*
|
||||
* @return the default PrintService.
|
||||
*/
|
||||
|
||||
public static final PrintService lookupDefaultPrintService() {
|
||||
|
||||
Iterator psIterator = getAllLookupServices().iterator();
|
||||
while (psIterator.hasNext()) {
|
||||
try {
|
||||
PrintServiceLookup lus = (PrintServiceLookup)psIterator.next();
|
||||
PrintService service = lus.getDefaultPrintService();
|
||||
if (service != null) {
|
||||
return service;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allows an application to explicitly register a class that
|
||||
* implements lookup services. The registration will not persist
|
||||
* across VM invocations.
|
||||
* This is useful if an application needs to make a new service
|
||||
* available that is not part of the installation.
|
||||
* If the lookup service is already registered, or cannot be registered,
|
||||
* the method returns false.
|
||||
* <p>
|
||||
*
|
||||
* @param sp an implementation of a lookup service.
|
||||
* @return <code>true</code> if the new lookup service is newly
|
||||
* registered; <code>false</code> otherwise.
|
||||
*/
|
||||
public static boolean registerServiceProvider(PrintServiceLookup sp) {
|
||||
synchronized (PrintServiceLookup.class) {
|
||||
Iterator psIterator = getAllLookupServices().iterator();
|
||||
while (psIterator.hasNext()) {
|
||||
try {
|
||||
Object lus = psIterator.next();
|
||||
if (lus.getClass() == sp.getClass()) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
getListOfLookupServices().add(sp);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allows an application to directly register an instance of a
|
||||
* class which implements a print service.
|
||||
* The lookup operations for this service will be
|
||||
* performed by the PrintServiceLookup class using the attribute
|
||||
* values and classes reported by the service.
|
||||
* This may be less efficient than a lookup
|
||||
* service tuned for that service.
|
||||
* Therefore registering a <code>PrintServiceLookup</code> instance
|
||||
* instead is recommended.
|
||||
* The method returns true if this service is not previously
|
||||
* registered and is now successfully registered.
|
||||
* This method should not be called with StreamPrintService instances.
|
||||
* They will always fail to register and the method will return false.
|
||||
* @param service an implementation of a print service.
|
||||
* @return <code>true</code> if the service is newly
|
||||
* registered; <code>false</code> otherwise.
|
||||
*/
|
||||
|
||||
public static boolean registerService(PrintService service) {
|
||||
synchronized (PrintServiceLookup.class) {
|
||||
if (service instanceof StreamPrintService) {
|
||||
return false;
|
||||
}
|
||||
ArrayList registeredServices = getRegisteredServices();
|
||||
if (registeredServices == null) {
|
||||
registeredServices = initRegisteredServices();
|
||||
}
|
||||
else {
|
||||
if (registeredServices.contains(service)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
registeredServices.add(service);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locates services that can be positively confirmed to support
|
||||
* the combination of attributes and DocFlavors specified.
|
||||
* This method is not called directly by applications.
|
||||
* <p>
|
||||
* Implemented by a service provider, used by the static methods
|
||||
* of this class.
|
||||
* <p>
|
||||
* The results should be the same as obtaining all the PrintServices
|
||||
* and querying each one individually on its support for the
|
||||
* specified attributes and flavors, but the process can be more
|
||||
* efficient by taking advantage of the capabilities of lookup services
|
||||
* for the print services.
|
||||
*
|
||||
* @param flavor of document required. If null it is ignored.
|
||||
* @param attributes required to be supported. If null this
|
||||
* constraint is not used.
|
||||
* @return array of matching PrintServices. If no services match, the
|
||||
* array is zero-length.
|
||||
*/
|
||||
public abstract PrintService[] getPrintServices(DocFlavor flavor,
|
||||
AttributeSet attributes);
|
||||
|
||||
/**
|
||||
* Not called directly by applications.
|
||||
* Implemented by a service provider, used by the static methods
|
||||
* of this class.
|
||||
* @return array of all PrintServices known to this lookup service
|
||||
* class. If none are found, the array is zero-length.
|
||||
*/
|
||||
public abstract PrintService[] getPrintServices() ;
|
||||
|
||||
|
||||
/**
|
||||
* Not called directly by applications.
|
||||
* <p>
|
||||
* Implemented by a service provider, used by the static methods
|
||||
* of this class.
|
||||
* <p>
|
||||
* Locates MultiDoc print services which can be positively confirmed
|
||||
* to support the combination of attributes and DocFlavors specified.
|
||||
* <p>
|
||||
*
|
||||
* @param flavors of documents required. If null or empty it is ignored.
|
||||
* @param attributes required to be supported. If null this
|
||||
* constraint is not used.
|
||||
* @return array of matching PrintServices. If no services match, the
|
||||
* array is zero-length.
|
||||
*/
|
||||
public abstract MultiDocPrintService[]
|
||||
getMultiDocPrintServices(DocFlavor[] flavors,
|
||||
AttributeSet attributes);
|
||||
|
||||
/**
|
||||
* Not called directly by applications.
|
||||
* Implemented by a service provider, and called by the print lookup
|
||||
* service
|
||||
* @return the default PrintService for this lookup service.
|
||||
* If there is no default, returns null.
|
||||
*/
|
||||
public abstract PrintService getDefaultPrintService();
|
||||
|
||||
private static ArrayList getAllLookupServices() {
|
||||
synchronized (PrintServiceLookup.class) {
|
||||
ArrayList listOfLookupServices = getListOfLookupServices();
|
||||
if (listOfLookupServices != null) {
|
||||
return listOfLookupServices;
|
||||
} else {
|
||||
listOfLookupServices = initListOfLookupServices();
|
||||
}
|
||||
try {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction() {
|
||||
public Object run() {
|
||||
Iterator<PrintServiceLookup> iterator =
|
||||
ServiceLoader.load(PrintServiceLookup.class).
|
||||
iterator();
|
||||
ArrayList los = getListOfLookupServices();
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
los.add(iterator.next());
|
||||
} catch (ServiceConfigurationError err) {
|
||||
/* In the applet case, we continue */
|
||||
if (System.getSecurityManager() != null) {
|
||||
err.printStackTrace();
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (java.security.PrivilegedActionException e) {
|
||||
}
|
||||
|
||||
return listOfLookupServices;
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList getServices(DocFlavor flavor,
|
||||
AttributeSet attributes) {
|
||||
|
||||
ArrayList listOfServices = new ArrayList();
|
||||
Iterator psIterator = getAllLookupServices().iterator();
|
||||
while (psIterator.hasNext()) {
|
||||
try {
|
||||
PrintServiceLookup lus = (PrintServiceLookup)psIterator.next();
|
||||
PrintService[] services=null;
|
||||
if (flavor == null && attributes == null) {
|
||||
try {
|
||||
services = lus.getPrintServices();
|
||||
} catch (Throwable tr) {
|
||||
}
|
||||
} else {
|
||||
services = lus.getPrintServices(flavor, attributes);
|
||||
}
|
||||
if (services == null) {
|
||||
continue;
|
||||
}
|
||||
for (int i=0; i<services.length; i++) {
|
||||
listOfServices.add(services[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
/* add any directly registered services */
|
||||
ArrayList registeredServices = null;
|
||||
try {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPrintJobAccess();
|
||||
}
|
||||
registeredServices = getRegisteredServices();
|
||||
} catch (SecurityException se) {
|
||||
}
|
||||
if (registeredServices != null) {
|
||||
PrintService[] services = (PrintService[])
|
||||
registeredServices.toArray(
|
||||
new PrintService[registeredServices.size()]);
|
||||
for (int i=0; i<services.length; i++) {
|
||||
if (!listOfServices.contains(services[i])) {
|
||||
if (flavor == null && attributes == null) {
|
||||
listOfServices.add(services[i]);
|
||||
} else if (((flavor != null &&
|
||||
services[i].isDocFlavorSupported(flavor)) ||
|
||||
flavor == null) &&
|
||||
null == services[i].getUnsupportedAttributes(
|
||||
flavor, attributes)) {
|
||||
listOfServices.add(services[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return listOfServices;
|
||||
}
|
||||
|
||||
private static ArrayList getMultiDocServices(DocFlavor[] flavors,
|
||||
AttributeSet attributes) {
|
||||
|
||||
|
||||
ArrayList listOfServices = new ArrayList();
|
||||
Iterator psIterator = getAllLookupServices().iterator();
|
||||
while (psIterator.hasNext()) {
|
||||
try {
|
||||
PrintServiceLookup lus = (PrintServiceLookup)psIterator.next();
|
||||
MultiDocPrintService[] services =
|
||||
lus.getMultiDocPrintServices(flavors, attributes);
|
||||
if (services == null) {
|
||||
continue;
|
||||
}
|
||||
for (int i=0; i<services.length; i++) {
|
||||
listOfServices.add(services[i]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
/* add any directly registered services */
|
||||
ArrayList registeredServices = null;
|
||||
try {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkPrintJobAccess();
|
||||
}
|
||||
registeredServices = getRegisteredServices();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (registeredServices != null) {
|
||||
PrintService[] services = (PrintService[])
|
||||
registeredServices.toArray(
|
||||
new PrintService[registeredServices.size()]);
|
||||
for (int i=0; i<services.length; i++) {
|
||||
if (services[i] instanceof MultiDocPrintService &&
|
||||
!listOfServices.contains(services[i])) {
|
||||
if (flavors == null || flavors.length == 0) {
|
||||
listOfServices.add(services[i]);
|
||||
} else {
|
||||
boolean supported = true;
|
||||
for (int f=0; f<flavors.length; f++) {
|
||||
if (services[i].isDocFlavorSupported(flavors[f])) {
|
||||
|
||||
if (services[i].getUnsupportedAttributes(
|
||||
flavors[f], attributes) != null) {
|
||||
supported = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
supported = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (supported) {
|
||||
listOfServices.add(services[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return listOfServices;
|
||||
}
|
||||
|
||||
}
|
||||
336
jdkSrc/jdk8/javax/print/ServiceUI.java
Normal file
336
jdkSrc/jdk8/javax/print/ServiceUI.java
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.AttributeSet;
|
||||
import javax.print.attribute.PrintRequestAttributeSet;
|
||||
import javax.print.attribute.standard.Destination;
|
||||
import javax.print.attribute.standard.Fidelity;
|
||||
|
||||
import sun.print.ServiceDialog;
|
||||
import sun.print.SunAlternateMedia;
|
||||
|
||||
/** This class is a collection of UI convenience methods which provide a
|
||||
* graphical user dialog for browsing print services looked up through the Java
|
||||
* Print Service API.
|
||||
* <p>
|
||||
* The dialogs follow a standard pattern of acting as a continue/cancel option
|
||||
*for a user as well as allowing the user to select the print service to use
|
||||
*and specify choices such as paper size and number of copies.
|
||||
* <p>
|
||||
* <p>
|
||||
* The dialogs are designed to work with pluggable print services though the
|
||||
* public APIs of those print services.
|
||||
* <p>
|
||||
* If a print service provides any vendor extensions these may be made
|
||||
* accessible to the user through a vendor supplied tab panel Component.
|
||||
* Such a vendor extension is encouraged to use Swing! and to support its
|
||||
* accessibility APIs.
|
||||
* The vendor extensions should return the settings as part of the
|
||||
* AttributeSet.
|
||||
* Applications which want to preserve the user settings should use those
|
||||
* settings to specify the print job.
|
||||
* Note that this class is not referenced by any other part of the Java
|
||||
* Print Service and may not be included in profiles which cannot depend
|
||||
* on the presence of the AWT packages.
|
||||
*/
|
||||
|
||||
public class ServiceUI {
|
||||
|
||||
|
||||
/**
|
||||
* Presents a dialog to the user for selecting a print service (printer).
|
||||
* It is displayed at the location specified by the application and
|
||||
* is modal.
|
||||
* If the specification is invalid or would make the dialog not visible it
|
||||
* will be displayed at a location determined by the implementation.
|
||||
* The dialog blocks its calling thread and is application modal.
|
||||
* <p>
|
||||
* The dialog may include a tab panel with custom UI lazily obtained from
|
||||
* the PrintService's ServiceUIFactory when the PrintService is browsed.
|
||||
* The dialog will attempt to locate a MAIN_UIROLE first as a JComponent,
|
||||
* then as a Panel. If there is no ServiceUIFactory or no matching role
|
||||
* the custom tab will be empty or not visible.
|
||||
* <p>
|
||||
* The dialog returns the print service selected by the user if the user
|
||||
* OK's the dialog and null if the user cancels the dialog.
|
||||
* <p>
|
||||
* An application must pass in an array of print services to browse.
|
||||
* The array must be non-null and non-empty.
|
||||
* Typically an application will pass in only PrintServices capable
|
||||
* of printing a particular document flavor.
|
||||
* <p>
|
||||
* An application may pass in a PrintService to be initially displayed.
|
||||
* A non-null parameter must be included in the array of browsable
|
||||
* services.
|
||||
* If this parameter is null a service is chosen by the implementation.
|
||||
* <p>
|
||||
* An application may optionally pass in the flavor to be printed.
|
||||
* If this is non-null choices presented to the user can be better
|
||||
* validated against those supported by the services.
|
||||
* An application must pass in a PrintRequestAttributeSet for returning
|
||||
* user choices.
|
||||
* On calling the PrintRequestAttributeSet may be empty, or may contain
|
||||
* application-specified values.
|
||||
* <p>
|
||||
* These are used to set the initial settings for the initially
|
||||
* displayed print service. Values which are not supported by the print
|
||||
* service are ignored. As the user browses print services, attributes
|
||||
* and values are copied to the new display. If a user browses a
|
||||
* print service which does not support a particular attribute-value, the
|
||||
* default for that service is used as the new value to be copied.
|
||||
* <p>
|
||||
* If the user cancels the dialog, the returned attributes will not reflect
|
||||
* any changes made by the user.
|
||||
*
|
||||
* A typical basic usage of this method may be :
|
||||
* <pre>{@code
|
||||
* PrintService[] services = PrintServiceLookup.lookupPrintServices(
|
||||
* DocFlavor.INPUT_STREAM.JPEG, null);
|
||||
* PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
|
||||
* if (services.length > 0) {
|
||||
* PrintService service = ServiceUI.printDialog(null, 50, 50,
|
||||
* services, services[0],
|
||||
* null,
|
||||
* attributes);
|
||||
* if (service != null) {
|
||||
* ... print ...
|
||||
* }
|
||||
* }
|
||||
* }</pre>
|
||||
* <p>
|
||||
|
||||
* @param gc used to select screen. null means primary or default screen.
|
||||
* @param x location of dialog including border in screen coordinates
|
||||
* @param y location of dialog including border in screen coordinates
|
||||
* @param services to be browsable, must be non-null.
|
||||
* @param defaultService - initial PrintService to display.
|
||||
* @param flavor - the flavor to be printed, or null.
|
||||
* @param attributes on input is the initial application supplied
|
||||
* preferences. This cannot be null but may be empty.
|
||||
* On output the attributes reflect changes made by the user.
|
||||
* @return print service selected by the user, or null if the user
|
||||
* cancelled the dialog.
|
||||
* @throws HeadlessException if GraphicsEnvironment.isHeadless()
|
||||
* returns true.
|
||||
* @throws IllegalArgumentException if services is null or empty,
|
||||
* or attributes is null, or the initial PrintService is not in the
|
||||
* list of browsable services.
|
||||
*/
|
||||
public static PrintService printDialog(GraphicsConfiguration gc,
|
||||
int x, int y,
|
||||
PrintService[] services,
|
||||
PrintService defaultService,
|
||||
DocFlavor flavor,
|
||||
PrintRequestAttributeSet attributes)
|
||||
throws HeadlessException
|
||||
{
|
||||
int defaultIndex = -1;
|
||||
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException();
|
||||
} else if ((services == null) || (services.length == 0)) {
|
||||
throw new IllegalArgumentException("services must be non-null " +
|
||||
"and non-empty");
|
||||
} else if (attributes == null) {
|
||||
throw new IllegalArgumentException("attributes must be non-null");
|
||||
}
|
||||
|
||||
if (defaultService != null) {
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
if (services[i].equals(defaultService)) {
|
||||
defaultIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultIndex < 0) {
|
||||
throw new IllegalArgumentException("services must contain " +
|
||||
"defaultService");
|
||||
}
|
||||
} else {
|
||||
defaultIndex = 0;
|
||||
}
|
||||
|
||||
// For now we set owner to null. In the future, it may be passed
|
||||
// as an argument.
|
||||
Window owner = null;
|
||||
|
||||
Rectangle gcBounds = (gc == null) ? GraphicsEnvironment.
|
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice().
|
||||
getDefaultConfiguration().getBounds() : gc.getBounds();
|
||||
|
||||
ServiceDialog dialog;
|
||||
if (owner instanceof Frame) {
|
||||
dialog = new ServiceDialog(gc,
|
||||
x + gcBounds.x,
|
||||
y + gcBounds.y,
|
||||
services, defaultIndex,
|
||||
flavor, attributes,
|
||||
(Frame)owner);
|
||||
} else {
|
||||
dialog = new ServiceDialog(gc,
|
||||
x + gcBounds.x,
|
||||
y + gcBounds.y,
|
||||
services, defaultIndex,
|
||||
flavor, attributes,
|
||||
(Dialog)owner);
|
||||
}
|
||||
Rectangle dlgBounds = dialog.getBounds();
|
||||
|
||||
// get union of all GC bounds
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] gs = ge.getScreenDevices();
|
||||
for (int j=0; j<gs.length; j++) {
|
||||
gcBounds =
|
||||
gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
|
||||
}
|
||||
|
||||
// if portion of dialog is not within the gc boundary
|
||||
if (!gcBounds.contains(dlgBounds)) {
|
||||
// put in the center relative to parent frame/dialog
|
||||
dialog.setLocationRelativeTo(owner);
|
||||
}
|
||||
dialog.show();
|
||||
|
||||
if (dialog.getStatus() == ServiceDialog.APPROVE) {
|
||||
PrintRequestAttributeSet newas = dialog.getAttributes();
|
||||
Class dstCategory = Destination.class;
|
||||
Class amCategory = SunAlternateMedia.class;
|
||||
Class fdCategory = Fidelity.class;
|
||||
|
||||
if (attributes.containsKey(dstCategory) &&
|
||||
!newas.containsKey(dstCategory))
|
||||
{
|
||||
attributes.remove(dstCategory);
|
||||
}
|
||||
|
||||
if (attributes.containsKey(amCategory) &&
|
||||
!newas.containsKey(amCategory))
|
||||
{
|
||||
attributes.remove(amCategory);
|
||||
}
|
||||
|
||||
attributes.addAll(newas);
|
||||
|
||||
Fidelity fd = (Fidelity)attributes.get(fdCategory);
|
||||
if (fd != null) {
|
||||
if (fd == Fidelity.FIDELITY_TRUE) {
|
||||
removeUnsupportedAttributes(dialog.getPrintService(),
|
||||
flavor, attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dialog.getPrintService();
|
||||
}
|
||||
|
||||
/**
|
||||
* POSSIBLE FUTURE API: This method may be used down the road if we
|
||||
* decide to allow developers to explicitly display a "page setup" dialog.
|
||||
* Currently we use that functionality internally for the AWT print model.
|
||||
*/
|
||||
/*
|
||||
public static void pageDialog(GraphicsConfiguration gc,
|
||||
int x, int y,
|
||||
PrintService service,
|
||||
DocFlavor flavor,
|
||||
PrintRequestAttributeSet attributes)
|
||||
throws HeadlessException
|
||||
{
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException();
|
||||
} else if (service == null) {
|
||||
throw new IllegalArgumentException("service must be non-null");
|
||||
} else if (attributes == null) {
|
||||
throw new IllegalArgumentException("attributes must be non-null");
|
||||
}
|
||||
|
||||
ServiceDialog dialog = new ServiceDialog(gc, x, y, service,
|
||||
flavor, attributes);
|
||||
dialog.show();
|
||||
|
||||
if (dialog.getStatus() == ServiceDialog.APPROVE) {
|
||||
PrintRequestAttributeSet newas = dialog.getAttributes();
|
||||
Class amCategory = SunAlternateMedia.class;
|
||||
|
||||
if (attributes.containsKey(amCategory) &&
|
||||
!newas.containsKey(amCategory))
|
||||
{
|
||||
attributes.remove(amCategory);
|
||||
}
|
||||
|
||||
attributes.addAll(newas.values());
|
||||
}
|
||||
|
||||
dialog.getOwner().dispose();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Removes any attributes from the given AttributeSet that are
|
||||
* unsupported by the given PrintService/DocFlavor combination.
|
||||
*/
|
||||
private static void removeUnsupportedAttributes(PrintService ps,
|
||||
DocFlavor flavor,
|
||||
AttributeSet aset)
|
||||
{
|
||||
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
|
||||
aset);
|
||||
|
||||
if (asUnsupported != null) {
|
||||
Attribute[] usAttrs = asUnsupported.toArray();
|
||||
|
||||
for (int i=0; i<usAttrs.length; i++) {
|
||||
Class category = usAttrs[i].getCategory();
|
||||
|
||||
if (ps.isAttributeCategorySupported(category)) {
|
||||
Attribute attr =
|
||||
(Attribute)ps.getDefaultAttributeValue(category);
|
||||
|
||||
if (attr != null) {
|
||||
aset.add(attr);
|
||||
} else {
|
||||
aset.remove(category);
|
||||
}
|
||||
} else {
|
||||
aset.remove(category);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
142
jdkSrc/jdk8/javax/print/ServiceUIFactory.java
Normal file
142
jdkSrc/jdk8/javax/print/ServiceUIFactory.java
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
/**
|
||||
* Services may optionally provide UIs which allow different styles
|
||||
* of interaction in different roles.
|
||||
* One role may be end-user browsing and setting of print options.
|
||||
* Another role may be administering the print service.
|
||||
* <p>
|
||||
* Although the Print Service API does not presently provide standardised
|
||||
* support for administering a print service, monitoring of the print
|
||||
* service is possible and a UI may provide for private update mechanisms.
|
||||
* <p>
|
||||
* The basic design intent is to allow applications to lazily locate and
|
||||
* initialize services only when needed without any API dependencies
|
||||
* except in an environment in which they are used.
|
||||
* <p>
|
||||
* Swing UIs are preferred as they provide a more consistent {@literal L&F}
|
||||
* and can support accessibility APIs.
|
||||
* <p>
|
||||
* Example usage:
|
||||
* <pre>
|
||||
* ServiceUIFactory factory = printService.getServiceUIFactory();
|
||||
* if (factory != null) {
|
||||
* JComponent swingui = (JComponent)factory.getUI(
|
||||
* ServiceUIFactory.MAIN_UIROLE,
|
||||
* ServiceUIFactory.JCOMPONENT_UI);
|
||||
* if (swingui != null) {
|
||||
* tabbedpane.add("Custom UI", swingui);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
public abstract class ServiceUIFactory {
|
||||
|
||||
/**
|
||||
* Denotes a UI implemented as a Swing component.
|
||||
* The value of the String is the fully qualified classname :
|
||||
* "javax.swing.JComponent".
|
||||
*/
|
||||
public static final String JCOMPONENT_UI = "javax.swing.JComponent";
|
||||
|
||||
/**
|
||||
* Denotes a UI implemented as an AWT panel.
|
||||
* The value of the String is the fully qualified classname :
|
||||
* "java.awt.Panel"
|
||||
*/
|
||||
public static final String PANEL_UI = "java.awt.Panel";
|
||||
|
||||
/**
|
||||
* Denotes a UI implemented as an AWT dialog.
|
||||
* The value of the String is the fully qualified classname :
|
||||
* "java.awt.Dialog"
|
||||
*/
|
||||
public static final String DIALOG_UI = "java.awt.Dialog";
|
||||
|
||||
/**
|
||||
* Denotes a UI implemented as a Swing dialog.
|
||||
* The value of the String is the fully qualified classname :
|
||||
* "javax.swing.JDialog"
|
||||
*/
|
||||
public static final String JDIALOG_UI = "javax.swing.JDialog";
|
||||
|
||||
/**
|
||||
* Denotes a UI which performs an informative "About" role.
|
||||
*/
|
||||
public static final int ABOUT_UIROLE = 1;
|
||||
|
||||
/**
|
||||
* Denotes a UI which performs an administrative role.
|
||||
*/
|
||||
public static final int ADMIN_UIROLE = 2;
|
||||
|
||||
/**
|
||||
* Denotes a UI which performs the normal end user role.
|
||||
*/
|
||||
public static final int MAIN_UIROLE = 3;
|
||||
|
||||
/**
|
||||
* Not a valid role but role id's greater than this may be used
|
||||
* for private roles supported by a service. Knowledge of the
|
||||
* function performed by this role is required to make proper use
|
||||
* of it.
|
||||
*/
|
||||
public static final int RESERVED_UIROLE = 99;
|
||||
/**
|
||||
* Get a UI object which may be cast to the requested UI type
|
||||
* by the application and used in its user interface.
|
||||
* <P>
|
||||
* @param role requested. Must be one of the standard roles or
|
||||
* a private role supported by this factory.
|
||||
* @param ui type in which the role is requested.
|
||||
* @return the UI role or null if the requested UI role is not available
|
||||
* from this factory
|
||||
* @throws IllegalArgumentException if the role or ui is neither
|
||||
* one of the standard ones, nor a private one
|
||||
* supported by the factory.
|
||||
*/
|
||||
public abstract Object getUI(int role, String ui) ;
|
||||
|
||||
/**
|
||||
* Given a UI role obtained from this factory obtain the UI
|
||||
* types available from this factory which implement this role.
|
||||
* The returned Strings should refer to the static variables defined
|
||||
* in this class so that applications can use equality of reference
|
||||
* ("==").
|
||||
* @param role to be looked up.
|
||||
* @return the UI types supported by this class for the specified role,
|
||||
* null if no UIs are available for the role.
|
||||
* @throws IllegalArgumentException is the role is a non-standard
|
||||
* role not supported by this factory.
|
||||
*/
|
||||
public abstract String[] getUIClassNamesForRole(int role) ;
|
||||
|
||||
|
||||
|
||||
}
|
||||
254
jdkSrc/jdk8/javax/print/SimpleDoc.java
Normal file
254
jdkSrc/jdk8/javax/print/SimpleDoc.java
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.CharArrayReader;
|
||||
import java.io.StringReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import javax.print.attribute.AttributeSetUtilities;
|
||||
import javax.print.attribute.DocAttributeSet;
|
||||
|
||||
/**
|
||||
* This class is an implementation of interface <code>Doc</code> that can
|
||||
* be used in many common printing requests.
|
||||
* It can handle all of the presently defined "pre-defined" doc flavors
|
||||
* defined as static variables in the DocFlavor class.
|
||||
* <p>
|
||||
* In particular this class implements certain required semantics of the
|
||||
* Doc specification as follows:
|
||||
* <ul>
|
||||
* <li>constructs a stream for the service if requested and appropriate.
|
||||
* <li>ensures the same object is returned for each call on a method.
|
||||
* <li>ensures multiple threads can access the Doc
|
||||
* <li>performs some validation of that the data matches the doc flavor.
|
||||
* </ul>
|
||||
* Clients who want to re-use the doc object in other jobs,
|
||||
* or need a MultiDoc will not want to use this class.
|
||||
* <p>
|
||||
* If the print data is a stream, or a print job requests data as a
|
||||
* stream, then <code>SimpleDoc</code> does not monitor if the service
|
||||
* properly closes the stream after data transfer completion or job
|
||||
* termination.
|
||||
* Clients may prefer to use provide their own implementation of doc that
|
||||
* adds a listener to monitor job completion and to validate that
|
||||
* resources such as streams are freed (ie closed).
|
||||
*/
|
||||
|
||||
public final class SimpleDoc implements Doc {
|
||||
|
||||
private DocFlavor flavor;
|
||||
private DocAttributeSet attributes;
|
||||
private Object printData;
|
||||
private Reader reader;
|
||||
private InputStream inStream;
|
||||
|
||||
/**
|
||||
* Constructs a <code>SimpleDoc</code> with the specified
|
||||
* print data, doc flavor and doc attribute set.
|
||||
* @param printData the print data object
|
||||
* @param flavor the <code>DocFlavor</code> object
|
||||
* @param attributes a <code>DocAttributeSet</code>, which can
|
||||
* be <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>flavor</code> or
|
||||
* <code>printData</code> is <code>null</code>, or the
|
||||
* <code>printData</code> does not correspond
|
||||
* to the specified doc flavor--for example, the data is
|
||||
* not of the type specified as the representation in the
|
||||
* <code>DocFlavor</code>.
|
||||
*/
|
||||
public SimpleDoc(Object printData,
|
||||
DocFlavor flavor, DocAttributeSet attributes) {
|
||||
|
||||
if (flavor == null || printData == null) {
|
||||
throw new IllegalArgumentException("null argument(s)");
|
||||
}
|
||||
|
||||
Class repClass = null;
|
||||
try {
|
||||
String className = flavor.getRepresentationClassName();
|
||||
sun.reflect.misc.ReflectUtil.checkPackageAccess(className);
|
||||
repClass = Class.forName(className, false,
|
||||
Thread.currentThread().getContextClassLoader());
|
||||
} catch (Throwable e) {
|
||||
throw new IllegalArgumentException("unknown representation class");
|
||||
}
|
||||
|
||||
if (!repClass.isInstance(printData)) {
|
||||
throw new IllegalArgumentException("data is not of declared type");
|
||||
}
|
||||
|
||||
this.flavor = flavor;
|
||||
if (attributes != null) {
|
||||
this.attributes = AttributeSetUtilities.unmodifiableView(attributes);
|
||||
}
|
||||
this.printData = printData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the doc flavor in which this doc object will supply its
|
||||
* piece of print data.
|
||||
*
|
||||
* @return Doc flavor.
|
||||
*/
|
||||
public DocFlavor getDocFlavor() {
|
||||
return flavor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the set of printing attributes for this doc object. If the
|
||||
* returned attribute set includes an instance of a particular attribute
|
||||
* <I>X,</I> the printer must use that attribute value for this doc,
|
||||
* overriding any value of attribute <I>X</I> in the job's attribute set.
|
||||
* If the returned attribute set does not include an instance
|
||||
* of a particular attribute <I>X</I> or if null is returned, the printer
|
||||
* must consult the job's attribute set to obtain the value for
|
||||
* attribute <I>X,</I> and if not found there, the printer must use an
|
||||
* implementation-dependent default value. The returned attribute set is
|
||||
* unmodifiable.
|
||||
*
|
||||
* @return Unmodifiable set of printing attributes for this doc, or null
|
||||
* to obtain all attribute values from the job's attribute
|
||||
* set.
|
||||
*/
|
||||
public DocAttributeSet getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Obtains the print data representation object that contains this doc
|
||||
* object's piece of print data in the format corresponding to the
|
||||
* supported doc flavor.
|
||||
* The <CODE>getPrintData()</CODE> method returns an instance of
|
||||
* the representation class whose name is given by
|
||||
* {@link DocFlavor#getRepresentationClassName() getRepresentationClassName},
|
||||
* and the return value can be cast
|
||||
* from class Object to that representation class.
|
||||
*
|
||||
* @return Print data representation object.
|
||||
*
|
||||
* @exception IOException if the representation class is a stream and
|
||||
* there was an I/O error while constructing the stream.
|
||||
*/
|
||||
public Object getPrintData() throws IOException {
|
||||
return printData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a reader for extracting character print data from this doc.
|
||||
* The <code>Doc</code> implementation is required to support this
|
||||
* method if the <code>DocFlavor</code> has one of the following print
|
||||
* data representation classes, and return <code>null</code>
|
||||
* otherwise:
|
||||
* <UL>
|
||||
* <LI> <code>char[]</code>
|
||||
* <LI> <code>java.lang.String</code>
|
||||
* <LI> <code>java.io.Reader</code>
|
||||
* </UL>
|
||||
* The doc's print data representation object is used to construct and
|
||||
* return a <code>Reader</code> for reading the print data as a stream
|
||||
* of characters from the print data representation object.
|
||||
* However, if the print data representation object is itself a
|
||||
* <code>Reader</code> then the print data representation object is
|
||||
* simply returned.
|
||||
* <P>
|
||||
* @return a <code>Reader</code> for reading the print data
|
||||
* characters from this doc.
|
||||
* If a reader cannot be provided because this doc does not meet
|
||||
* the criteria stated above, <code>null</code> is returned.
|
||||
*
|
||||
* @exception IOException if there was an I/O error while creating
|
||||
* the reader.
|
||||
*/
|
||||
public Reader getReaderForText() throws IOException {
|
||||
|
||||
if (printData instanceof Reader) {
|
||||
return (Reader)printData;
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (reader != null) {
|
||||
return reader;
|
||||
}
|
||||
|
||||
if (printData instanceof char[]) {
|
||||
reader = new CharArrayReader((char[])printData);
|
||||
}
|
||||
else if (printData instanceof String) {
|
||||
reader = new StringReader((String)printData);
|
||||
}
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains an input stream for extracting byte print data from
|
||||
* this doc.
|
||||
* The <code>Doc</code> implementation is required to support this
|
||||
* method if the <code>DocFlavor</code> has one of the following print
|
||||
* data representation classes; otherwise this method
|
||||
* returns <code>null</code>:
|
||||
* <UL>
|
||||
* <LI> <code>byte[]</code>
|
||||
* <LI> <code>java.io.InputStream</code>
|
||||
* </UL>
|
||||
* The doc's print data representation object is obtained. Then, an
|
||||
* input stream for reading the print data
|
||||
* from the print data representation object as a stream of bytes is
|
||||
* created and returned.
|
||||
* However, if the print data representation object is itself an
|
||||
* input stream then the print data representation object is simply
|
||||
* returned.
|
||||
* <P>
|
||||
* @return an <code>InputStream</code> for reading the print data
|
||||
* bytes from this doc. If an input stream cannot be
|
||||
* provided because this doc does not meet
|
||||
* the criteria stated above, <code>null</code> is returned.
|
||||
*
|
||||
* @exception IOException
|
||||
* if there was an I/O error while creating the input stream.
|
||||
*/
|
||||
public InputStream getStreamForBytes() throws IOException {
|
||||
|
||||
if (printData instanceof InputStream) {
|
||||
return (InputStream)printData;
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (inStream != null) {
|
||||
return inStream;
|
||||
}
|
||||
|
||||
if (printData instanceof byte[]) {
|
||||
inStream = new ByteArrayInputStream((byte[])printData);
|
||||
}
|
||||
}
|
||||
return inStream;
|
||||
}
|
||||
|
||||
}
|
||||
114
jdkSrc/jdk8/javax/print/StreamPrintService.java
Normal file
114
jdkSrc/jdk8/javax/print/StreamPrintService.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* This class extends {@link PrintService} and represents a
|
||||
* print service that prints data in different formats to a
|
||||
* client-provided output stream.
|
||||
* This is principally intended for services where
|
||||
* the output format is a document type suitable for viewing
|
||||
* or archiving.
|
||||
* The output format must be declared as a mime type.
|
||||
* This is equivalent to an output document flavor where the
|
||||
* representation class is always "java.io.OutputStream"
|
||||
* An instance of the <code>StreamPrintService</code> class is
|
||||
* obtained from a {@link StreamPrintServiceFactory} instance.
|
||||
* <p>
|
||||
* Note that a <code>StreamPrintService</code> is different from a
|
||||
* <code>PrintService</code>, which supports a
|
||||
* {@link javax.print.attribute.standard.Destination Destination}
|
||||
* attribute. A <code>StreamPrintService</code> always requires an output
|
||||
* stream, whereas a <code>PrintService</code> optionally accepts a
|
||||
* <code>Destination</code>. A <code>StreamPrintService</code>
|
||||
* has no default destination for its formatted output.
|
||||
* Additionally a <code>StreamPrintService</code> is expected to generate
|
||||
output in
|
||||
* a format useful in other contexts.
|
||||
* StreamPrintService's are not expected to support the Destination attribute.
|
||||
*/
|
||||
|
||||
public abstract class StreamPrintService implements PrintService {
|
||||
|
||||
private OutputStream outStream;
|
||||
private boolean disposed = false;
|
||||
|
||||
private StreamPrintService() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructs a StreamPrintService object.
|
||||
*
|
||||
* @param out stream to which to send formatted print data.
|
||||
*/
|
||||
protected StreamPrintService(OutputStream out) {
|
||||
this.outStream = out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output stream.
|
||||
*
|
||||
* @return the stream to which this service will send formatted print data.
|
||||
*/
|
||||
public OutputStream getOutputStream() {
|
||||
return outStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the document format emitted by this print service.
|
||||
* Must be in mimetype format, compatible with the mime type
|
||||
* components of DocFlavors @see DocFlavor.
|
||||
* @return mime type identifying the output format.
|
||||
*/
|
||||
public abstract String getOutputFormat();
|
||||
|
||||
/**
|
||||
* Disposes this <code>StreamPrintService</code>.
|
||||
* 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.
|
||||
*/
|
||||
public void dispose() {
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>boolean</code> indicating whether or not
|
||||
* this <code>StreamPrintService</code> 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.
|
||||
* @return if this <code>StreamPrintService</code> has been disposed
|
||||
*/
|
||||
public boolean isDisposed() {
|
||||
return disposed;
|
||||
}
|
||||
|
||||
}
|
||||
235
jdkSrc/jdk8/javax/print/StreamPrintServiceFactory.java
Normal file
235
jdkSrc/jdk8/javax/print/StreamPrintServiceFactory.java
Normal file
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.print.DocFlavor;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.ServiceConfigurationError;
|
||||
|
||||
/**
|
||||
* A <code>StreamPrintServiceFactory</code> is the factory for
|
||||
* {@link StreamPrintService} instances,
|
||||
* which can print to an output stream in a particular
|
||||
* document format described as a mime type.
|
||||
* A typical output document format may be Postscript(TM).
|
||||
* <p>
|
||||
* This class is implemented by a service and located by the
|
||||
* implementation using the
|
||||
* <a href="../../../technotes/guides/jar/jar.html#Service Provider">
|
||||
* SPI JAR File specification</a>.
|
||||
* <p>
|
||||
* Applications locate instances of this class by calling the
|
||||
* {@link #lookupStreamPrintServiceFactories(DocFlavor, String)} method.
|
||||
* <p>
|
||||
* Applications can use a <code>StreamPrintService</code> obtained from a
|
||||
* factory in place of a <code>PrintService</code> which represents a
|
||||
* physical printer device.
|
||||
*/
|
||||
|
||||
public abstract class StreamPrintServiceFactory {
|
||||
|
||||
static class Services {
|
||||
private ArrayList listOfFactories = null;
|
||||
}
|
||||
|
||||
private static Services getServices() {
|
||||
Services services =
|
||||
(Services)AppContext.getAppContext().get(Services.class);
|
||||
if (services == null) {
|
||||
services = new Services();
|
||||
AppContext.getAppContext().put(Services.class, services);
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
private static ArrayList getListOfFactories() {
|
||||
return getServices().listOfFactories;
|
||||
}
|
||||
|
||||
private static ArrayList initListOfFactories() {
|
||||
ArrayList listOfFactories = new ArrayList();
|
||||
getServices().listOfFactories = listOfFactories;
|
||||
return listOfFactories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates factories for print services that can be used with
|
||||
* a print job to output a stream of data in the
|
||||
* format specified by {@code outputMimeType}.
|
||||
* <p>
|
||||
* The {@code outputMimeType} parameter describes the document type that
|
||||
* you want to create, whereas the {@code flavor} parameter describes the
|
||||
* format in which the input data will be provided by the application
|
||||
* to the {@code StreamPrintService}.
|
||||
* <p>
|
||||
* Although null is an acceptable value to use in the lookup of stream
|
||||
* printing services, it's typical to search for a particular
|
||||
* desired format, such as Postscript(TM).
|
||||
* <p>
|
||||
* @param flavor of the input document type - null means match all
|
||||
* types.
|
||||
* @param outputMimeType representing the required output format, used to
|
||||
* identify suitable stream printer factories. A value of null means
|
||||
* match all formats.
|
||||
* @return - matching factories for stream print service instance,
|
||||
* empty if no suitable factories could be located.
|
||||
*/
|
||||
public static StreamPrintServiceFactory[]
|
||||
lookupStreamPrintServiceFactories(DocFlavor flavor,
|
||||
String outputMimeType) {
|
||||
|
||||
ArrayList list = getFactories(flavor, outputMimeType);
|
||||
return (StreamPrintServiceFactory[])
|
||||
(list.toArray(new StreamPrintServiceFactory[list.size()]));
|
||||
}
|
||||
|
||||
/** Queries the factory for the document format that is emitted
|
||||
* by printers obtained from this factory.
|
||||
*
|
||||
* @return the output format described as a mime type.
|
||||
*/
|
||||
public abstract String getOutputFormat();
|
||||
|
||||
/**
|
||||
* Queries the factory for the document flavors that can be accepted
|
||||
* by printers obtained from this factory.
|
||||
* @return array of supported doc flavors.
|
||||
*/
|
||||
public abstract DocFlavor[] getSupportedDocFlavors();
|
||||
|
||||
/**
|
||||
* Returns a <code>StreamPrintService</code> that can print to
|
||||
* the specified output stream.
|
||||
* The output stream is created and managed by the application.
|
||||
* It is the application's responsibility to close the stream and
|
||||
* to ensure that this Printer is not reused.
|
||||
* The application should not close this stream until any print job
|
||||
* created from the printer is complete. Doing so earlier may generate
|
||||
* a <code>PrinterException</code> and an event indicating that the
|
||||
* job failed.
|
||||
* <p>
|
||||
* Whereas a <code>PrintService</code> connected to a physical printer
|
||||
* can be reused,
|
||||
* a <code>StreamPrintService</code> connected to a stream cannot.
|
||||
* The underlying <code>StreamPrintService</code> may be disposed by
|
||||
* the print system with
|
||||
* the {@link StreamPrintService#dispose() dispose} method
|
||||
* before returning from the
|
||||
* {@link DocPrintJob#print(Doc, javax.print.attribute.PrintRequestAttributeSet) print}
|
||||
* method of <code>DocPrintJob</code> so that the print system knows
|
||||
* this printer is no longer usable.
|
||||
* This is equivalent to a physical printer going offline - permanently.
|
||||
* Applications may supply a null print stream to create a queryable
|
||||
* service. It is not valid to create a PrintJob for such a stream.
|
||||
* Implementations which allocate resources on construction should examine
|
||||
* the stream and may wish to only allocate resources if the stream is
|
||||
* non-null.
|
||||
* <p>
|
||||
* @param out destination stream for generated output.
|
||||
* @return a PrintService which will generate the format specified by the
|
||||
* DocFlavor supported by this Factory.
|
||||
*/
|
||||
public abstract StreamPrintService getPrintService(OutputStream out);
|
||||
|
||||
|
||||
private static ArrayList getAllFactories() {
|
||||
synchronized (StreamPrintServiceFactory.class) {
|
||||
|
||||
ArrayList listOfFactories = getListOfFactories();
|
||||
if (listOfFactories != null) {
|
||||
return listOfFactories;
|
||||
} else {
|
||||
listOfFactories = initListOfFactories();
|
||||
}
|
||||
|
||||
try {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedExceptionAction() {
|
||||
public Object run() {
|
||||
Iterator<StreamPrintServiceFactory> iterator =
|
||||
ServiceLoader.load
|
||||
(StreamPrintServiceFactory.class).iterator();
|
||||
ArrayList lof = getListOfFactories();
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
lof.add(iterator.next());
|
||||
} catch (ServiceConfigurationError err) {
|
||||
/* In the applet case, we continue */
|
||||
if (System.getSecurityManager() != null) {
|
||||
err.printStackTrace();
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (java.security.PrivilegedActionException e) {
|
||||
}
|
||||
return listOfFactories;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMember(DocFlavor flavor, DocFlavor[] flavors) {
|
||||
for (int f=0; f<flavors.length; f++ ) {
|
||||
if (flavor.equals(flavors[f])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ArrayList getFactories(DocFlavor flavor, String outType) {
|
||||
|
||||
if (flavor == null && outType == null) {
|
||||
return getAllFactories();
|
||||
}
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
Iterator iterator = getAllFactories().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
StreamPrintServiceFactory factory =
|
||||
(StreamPrintServiceFactory)iterator.next();
|
||||
if ((outType == null ||
|
||||
outType.equalsIgnoreCase(factory.getOutputFormat())) &&
|
||||
(flavor == null ||
|
||||
isMember(flavor, factory.getSupportedDocFlavors()))) {
|
||||
list.add(factory);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
73
jdkSrc/jdk8/javax/print/URIException.java
Normal file
73
jdkSrc/jdk8/javax/print/URIException.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Interface URIException is a mixin interface which a subclass of {@link
|
||||
* PrintException PrintException} can implement to report an error condition
|
||||
* involving a URI address. The Print Service API does not define any print
|
||||
* exception classes that implement interface URIException, that being left to
|
||||
* the Print Service implementor's discretion.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface URIException {
|
||||
|
||||
/**
|
||||
* Indicates that the printer cannot access the URI address.
|
||||
* For example, the printer might report this error if it goes to get
|
||||
* the print data and cannot even establish a connection to the
|
||||
* URI address.
|
||||
*/
|
||||
public static final int URIInaccessible = 1;
|
||||
|
||||
/**
|
||||
* Indicates that the printer does not support the URI
|
||||
* scheme ("http", "ftp", etc.) in the URI address.
|
||||
*/
|
||||
public static final int URISchemeNotSupported = 2;
|
||||
|
||||
/**
|
||||
* Indicates any kind of problem not specifically identified
|
||||
* by the other reasons.
|
||||
*/
|
||||
public static final int URIOtherProblem = -1;
|
||||
|
||||
/**
|
||||
* Return the URI.
|
||||
* @return the URI that is the cause of this exception.
|
||||
*/
|
||||
public URI getUnsupportedURI();
|
||||
|
||||
/**
|
||||
* Return the reason for the event.
|
||||
* @return one of the predefined reasons enumerated in this interface.
|
||||
*/
|
||||
public int getReason();
|
||||
|
||||
}
|
||||
63
jdkSrc/jdk8/javax/print/attribute/Attribute.java
Normal file
63
jdkSrc/jdk8/javax/print/attribute/Attribute.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Interface Attribute is the base interface implemented by any and every
|
||||
* printing attribute class to indicate that the class represents a
|
||||
* printing attribute. All printing attributes are serializable.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface Attribute extends Serializable {
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value when it is added to an attribute set.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public Class<? extends Attribute> getCategory();
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* <I>Note:</I> This method is intended to provide a default, nonlocalized
|
||||
* string for the attribute's category. If two attribute objects return the
|
||||
* same category from the <CODE>getCategory()</CODE> method, they should
|
||||
* return the same name from the <CODE>getName()</CODE> method.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
}
|
||||
310
jdkSrc/jdk8/javax/print/attribute/AttributeSet.java
Normal file
310
jdkSrc/jdk8/javax/print/attribute/AttributeSet.java
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface AttributeSet specifies the interface for a set of printing
|
||||
* attributes. A printing attribute is an object whose class implements
|
||||
* interface {@link Attribute Attribute}.
|
||||
* <P>
|
||||
* An attribute set contains a group of <I>attribute values,</I>
|
||||
* where duplicate values are not allowed in the set.
|
||||
* Furthermore, each value in an attribute set is
|
||||
* a member of some <I>category,</I> and at most one value in any particular
|
||||
* category is allowed in the set. For an attribute set, the values are {@link
|
||||
* Attribute Attribute} objects, and the categories are {@link java.lang.Class
|
||||
* Class} objects. An attribute's category is the class (or interface) at the
|
||||
* root of the class hierarchy for that kind of attribute. Note that an
|
||||
* attribute object's category may be a superclass of the attribute object's
|
||||
* class rather than the attribute object's class itself. An attribute
|
||||
* object's
|
||||
* category is determined by calling the {@link Attribute#getCategory()
|
||||
* getCategory()} method defined in interface {@link Attribute
|
||||
* Attribute}.
|
||||
* <P>
|
||||
* The interfaces of an AttributeSet resemble those of the Java Collections
|
||||
* API's java.util.Map interface, but is more restrictive in the types
|
||||
* it will accept, and combines keys and values into an Attribute.
|
||||
* <P>
|
||||
* Attribute sets are used in several places in the Print Service API. In
|
||||
* each context, only certain kinds of attributes are allowed to appear in the
|
||||
* attribute set, as determined by the tagging interfaces which the attribute
|
||||
* class implements -- {@link DocAttribute DocAttribute}, {@link
|
||||
* PrintRequestAttribute PrintRequestAttribute}, {@link PrintJobAttribute
|
||||
* PrintJobAttribute}, and {@link PrintServiceAttribute
|
||||
* PrintServiceAttribute}.
|
||||
* There are four specializations of an attribute set that are restricted to
|
||||
* contain just one of the four kinds of attribute -- {@link DocAttributeSet
|
||||
* DocAttributeSet}, {@link PrintRequestAttributeSet
|
||||
* PrintRequestAttributeSet},
|
||||
* {@link PrintJobAttributeSet PrintJobAttributeSet}, and {@link
|
||||
* PrintServiceAttributeSet PrintServiceAttributeSet}, respectively. Note that
|
||||
* many attribute classes implement more than one tagging interface and so may
|
||||
* appear in more than one context.
|
||||
* <UL>
|
||||
* <LI>
|
||||
* A {@link DocAttributeSet DocAttributeSet}, containing {@link DocAttribute
|
||||
* DocAttribute}s, specifies the characteristics of an individual doc and the
|
||||
* print job settings to be applied to an individual doc.
|
||||
* <P>
|
||||
* <LI>
|
||||
* A {@link PrintRequestAttributeSet PrintRequestAttributeSet}, containing
|
||||
* {@link PrintRequestAttribute PrintRequestAttribute}s, specifies the
|
||||
* settings
|
||||
* to be applied to a whole print job and to all the docs in the print job.
|
||||
* <P>
|
||||
* <LI>
|
||||
* A {@link PrintJobAttributeSet PrintJobAttributeSet}, containing {@link
|
||||
* PrintJobAttribute PrintJobAttribute}s, reports the status of a print job.
|
||||
* <P>
|
||||
* <LI>
|
||||
* A {@link PrintServiceAttributeSet PrintServiceAttributeSet}, containing
|
||||
* {@link PrintServiceAttribute PrintServiceAttribute}s, reports the status of
|
||||
* a Print Service instance.
|
||||
* </UL>
|
||||
* <P>
|
||||
* In some contexts, the client is only allowed to examine an attribute set's
|
||||
* contents but not change them (the set is read-only). In other places, the
|
||||
* client is allowed both to examine and to change an attribute set's contents
|
||||
* (the set is read-write). For a read-only attribute set, calling a mutating
|
||||
* operation throws an UnmodifiableSetException.
|
||||
* <P>
|
||||
* The Print Service API provides one implementation of interface
|
||||
* AttributeSet, class {@link HashAttributeSet HashAttributeSet}.
|
||||
* A client can use class {@link
|
||||
* HashAttributeSet HashAttributeSet} or provide its own implementation of
|
||||
* interface AttributeSet. The Print Service API also provides
|
||||
* implementations of interface AttributeSet's subinterfaces -- classes {@link
|
||||
* HashDocAttributeSet HashDocAttributeSet},
|
||||
* {@link HashPrintRequestAttributeSet
|
||||
* HashPrintRequestAttributeSet}, {@link HashPrintJobAttributeSet
|
||||
* HashPrintJobAttributeSet}, and {@link HashPrintServiceAttributeSet
|
||||
* HashPrintServiceAttributeSet}.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface AttributeSet {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the attribute value which this attribute set contains in the
|
||||
* given attribute category. Returns <tt>null</tt> if this attribute set
|
||||
* does not contain any attribute value in the given attribute category.
|
||||
*
|
||||
* @param category Attribute category whose associated attribute value
|
||||
* is to be returned. It must be a
|
||||
* {@link java.lang.Class Class}
|
||||
* that implements interface {@link Attribute
|
||||
* Attribute}.
|
||||
*
|
||||
* @return The attribute value in the given attribute category contained
|
||||
* in this attribute set, or <tt>null</tt> if this attribute set
|
||||
* does not contain any attribute value in the given attribute
|
||||
* category.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>category</CODE> is null.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the <CODE>category</CODE> is not a
|
||||
* {@link java.lang.Class Class} that implements interface {@link
|
||||
* Attribute Attribute}.
|
||||
*/
|
||||
public Attribute get(Class<?> category);
|
||||
|
||||
/**
|
||||
* Adds the specified attribute to this attribute set if it is not
|
||||
* already present, first removing any existing value in the same
|
||||
* attribute category as the specified attribute value.
|
||||
*
|
||||
* @param attribute Attribute value to be added to this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call, i.e., the given attribute value was not already a member
|
||||
* of this attribute set.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not support
|
||||
* the <CODE>add()</CODE> operation.
|
||||
*/
|
||||
public boolean add(Attribute attribute);
|
||||
|
||||
|
||||
/**
|
||||
* Removes any attribute for this category from this attribute set if
|
||||
* present. If <CODE>category</CODE> is null, then
|
||||
* <CODE>remove()</CODE> does nothing and returns <tt>false</tt>.
|
||||
*
|
||||
* @param category Attribute category to be removed from this
|
||||
* attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call, i.e., the given attribute value had been a member of this
|
||||
* attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not support
|
||||
* the <CODE>remove()</CODE> operation.
|
||||
*/
|
||||
public boolean remove(Class<?> category);
|
||||
|
||||
/**
|
||||
* Removes the specified attribute from this attribute set if
|
||||
* present. If <CODE>attribute</CODE> is null, then
|
||||
* <CODE>remove()</CODE> does nothing and returns <tt>false</tt>.
|
||||
*
|
||||
* @param attribute Attribute value to be removed from this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call, i.e., the given attribute value had been a member of this
|
||||
* attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not support
|
||||
* the <CODE>remove()</CODE> operation.
|
||||
*/
|
||||
public boolean remove(Attribute attribute);
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this attribute set contains an
|
||||
* attribute for the specified category.
|
||||
*
|
||||
* @param category whose presence in this attribute set is
|
||||
* to be tested.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set contains an attribute
|
||||
* value for the specified category.
|
||||
*/
|
||||
public boolean containsKey(Class<?> category);
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this attribute set contains the given
|
||||
* attribute value.
|
||||
*
|
||||
* @param attribute Attribute value whose presence in this
|
||||
* attribute set is to be tested.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set contains the given
|
||||
* attribute value.
|
||||
*/
|
||||
public boolean containsValue(Attribute attribute);
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified set to this attribute.
|
||||
* The outcome is the same as if the =
|
||||
* {@link #add(Attribute) add(Attribute)}
|
||||
* operation had been applied to this attribute set successively with each
|
||||
* element from the specified set.
|
||||
* The behavior of the <CODE>addAll(AttributeSet)</CODE>
|
||||
* operation is unspecified if the specified set is modified while
|
||||
* the operation is in progress.
|
||||
* <P>
|
||||
* If the <CODE>addAll(AttributeSet)</CODE> operation throws an exception,
|
||||
* the effect on this attribute set's state is implementation dependent;
|
||||
* elements from the specified set before the point of the exception may
|
||||
* or may not have been added to this attribute set.
|
||||
*
|
||||
* @param attributes whose elements are to be added to this attribute
|
||||
* set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (Unchecked exception) Thrown if this attribute set does not support
|
||||
* the <tt>addAll(AttributeSet)</tt> method.
|
||||
* @throws NullPointerException
|
||||
* (Unchecked exception) Thrown if some element in the specified
|
||||
* set is null.
|
||||
*
|
||||
* @see #add(Attribute)
|
||||
*/
|
||||
public boolean addAll(AttributeSet attributes);
|
||||
|
||||
/**
|
||||
* Returns the number of attributes in this attribute set. If this
|
||||
* attribute set contains more than <tt>Integer.MAX_VALUE</tt> elements,
|
||||
* returns <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return The number of attributes in this attribute set.
|
||||
*/
|
||||
public int size();
|
||||
|
||||
/**
|
||||
* Returns an array of the attributes contained in this set.
|
||||
* @return the Attributes contained in this set as an array, zero length
|
||||
* if the AttributeSet is empty.
|
||||
*/
|
||||
public Attribute[] toArray();
|
||||
|
||||
|
||||
/**
|
||||
* Removes all attributes from this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not support
|
||||
* the <CODE>clear()</CODE> operation.
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Returns true if this attribute set contains no attributes.
|
||||
*
|
||||
* @return true if this attribute set contains no attributes.
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Compares the specified object with this attribute set for equality.
|
||||
* Returns <tt>true</tt> if the given object is also an attribute set and
|
||||
* the two attribute sets contain the same attribute category-attribute
|
||||
* value mappings. This ensures that the
|
||||
* <tt>equals()</tt> method works properly across different
|
||||
* implementations of the AttributeSet interface.
|
||||
*
|
||||
* @param object to be compared for equality with this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if the specified object is equal to this
|
||||
* attribute set.
|
||||
*/
|
||||
public boolean equals(Object object);
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this attribute set. The hash code of an
|
||||
* attribute set is defined to be the sum of the hash codes of each entry
|
||||
* in the AttributeSet.
|
||||
* This ensures that <tt>t1.equals(t2)</tt> implies that
|
||||
* <tt>t1.hashCode()==t2.hashCode()</tt> for any two attribute sets
|
||||
* <tt>t1</tt> and <tt>t2</tt>, as required by the general contract of
|
||||
* {@link java.lang.Object#hashCode() Object.hashCode()}.
|
||||
*
|
||||
* @return The hash code value for this attribute set.
|
||||
*/
|
||||
public int hashCode();
|
||||
|
||||
}
|
||||
578
jdkSrc/jdk8/javax/print/attribute/AttributeSetUtilities.java
Normal file
578
jdkSrc/jdk8/javax/print/attribute/AttributeSetUtilities.java
Normal file
@@ -0,0 +1,578 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class AttributeSetUtilities provides static methods for manipulating
|
||||
* AttributeSets.
|
||||
* <ul>
|
||||
* <li>Methods for creating unmodifiable and synchronized views of attribute
|
||||
* sets.
|
||||
* <li>operations useful for building
|
||||
* implementations of interface {@link AttributeSet AttributeSet}
|
||||
* </ul>
|
||||
* <P>
|
||||
* An <B>unmodifiable view</B> <I>U</I> of an AttributeSet <I>S</I> provides a
|
||||
* client with "read-only" access to <I>S</I>. Query operations on <I>U</I>
|
||||
* "read through" to <I>S</I>; thus, changes in <I>S</I> are reflected in
|
||||
* <I>U</I>. However, any attempt to modify <I>U</I>,
|
||||
* results in an UnmodifiableSetException.
|
||||
* The unmodifiable view object <I>U</I> will be serializable if the
|
||||
* attribute set object <I>S</I> is serializable.
|
||||
* <P>
|
||||
* A <B>synchronized view</B> <I>V</I> of an attribute set <I>S</I> provides a
|
||||
* client with synchronized (multiple thread safe) access to <I>S</I>. Each
|
||||
* operation of <I>V</I> is synchronized using <I>V</I> itself as the lock
|
||||
* object and then merely invokes the corresponding operation of <I>S</I>. In
|
||||
* order to guarantee mutually exclusive access, it is critical that all
|
||||
* access to <I>S</I> is accomplished through <I>V</I>. The synchronized view
|
||||
* object <I>V</I> will be serializable if the attribute set object <I>S</I>
|
||||
* is serializable.
|
||||
* <P>
|
||||
* As mentioned in the package description of javax.print, a null reference
|
||||
* parameter to methods is
|
||||
* incorrect unless explicitly documented on the method as having a meaningful
|
||||
* interpretation. Usage to the contrary is incorrect coding and may result in
|
||||
* a run time exception either immediately
|
||||
* or at some later time. IllegalArgumentException and NullPointerException
|
||||
* are examples of typical and acceptable run time exceptions for such cases.
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class AttributeSetUtilities {
|
||||
|
||||
/* Suppress default constructor, ensuring non-instantiability.
|
||||
*/
|
||||
private AttributeSetUtilities() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class UnmodifiableAttributeSet
|
||||
implements AttributeSet, Serializable {
|
||||
|
||||
private AttributeSet attrset;
|
||||
|
||||
/* Unmodifiable view of the underlying attribute set.
|
||||
*/
|
||||
public UnmodifiableAttributeSet(AttributeSet attributeSet) {
|
||||
|
||||
attrset = attributeSet;
|
||||
}
|
||||
|
||||
public Attribute get(Class<?> key) {
|
||||
return attrset.get(key);
|
||||
}
|
||||
|
||||
public boolean add(Attribute attribute) {
|
||||
throw new UnmodifiableSetException();
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Class<?> category) {
|
||||
throw new UnmodifiableSetException();
|
||||
}
|
||||
|
||||
public boolean remove(Attribute attribute) {
|
||||
throw new UnmodifiableSetException();
|
||||
}
|
||||
|
||||
public boolean containsKey(Class<?> category) {
|
||||
return attrset.containsKey(category);
|
||||
}
|
||||
|
||||
public boolean containsValue(Attribute attribute) {
|
||||
return attrset.containsValue(attribute);
|
||||
}
|
||||
|
||||
public boolean addAll(AttributeSet attributes) {
|
||||
throw new UnmodifiableSetException();
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return attrset.size();
|
||||
}
|
||||
|
||||
public Attribute[] toArray() {
|
||||
return attrset.toArray();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
throw new UnmodifiableSetException();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return attrset.isEmpty();
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return attrset.equals (o);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return attrset.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class UnmodifiableDocAttributeSet
|
||||
extends UnmodifiableAttributeSet
|
||||
implements DocAttributeSet, Serializable {
|
||||
|
||||
public UnmodifiableDocAttributeSet(DocAttributeSet attributeSet) {
|
||||
|
||||
super (attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class UnmodifiablePrintRequestAttributeSet
|
||||
extends UnmodifiableAttributeSet
|
||||
implements PrintRequestAttributeSet, Serializable
|
||||
{
|
||||
public UnmodifiablePrintRequestAttributeSet
|
||||
(PrintRequestAttributeSet attributeSet) {
|
||||
|
||||
super (attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class UnmodifiablePrintJobAttributeSet
|
||||
extends UnmodifiableAttributeSet
|
||||
implements PrintJobAttributeSet, Serializable
|
||||
{
|
||||
public UnmodifiablePrintJobAttributeSet
|
||||
(PrintJobAttributeSet attributeSet) {
|
||||
|
||||
super (attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class UnmodifiablePrintServiceAttributeSet
|
||||
extends UnmodifiableAttributeSet
|
||||
implements PrintServiceAttributeSet, Serializable
|
||||
{
|
||||
public UnmodifiablePrintServiceAttributeSet
|
||||
(PrintServiceAttributeSet attributeSet) {
|
||||
|
||||
super (attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unmodifiable view of the given attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying attribute set.
|
||||
*
|
||||
* @return Unmodifiable view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null. Null is never a
|
||||
*/
|
||||
public static AttributeSet unmodifiableView(AttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
return new UnmodifiableAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unmodifiable view of the given doc attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying doc attribute set.
|
||||
*
|
||||
* @return Unmodifiable view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static DocAttributeSet unmodifiableView
|
||||
(DocAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new UnmodifiableDocAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unmodifiable view of the given print request attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying print request attribute set.
|
||||
*
|
||||
* @return Unmodifiable view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static PrintRequestAttributeSet
|
||||
unmodifiableView(PrintRequestAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new UnmodifiablePrintRequestAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unmodifiable view of the given print job attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying print job attribute set.
|
||||
*
|
||||
* @return Unmodifiable view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static PrintJobAttributeSet
|
||||
unmodifiableView(PrintJobAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new UnmodifiablePrintJobAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an unmodifiable view of the given print service attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying print service attribute set.
|
||||
*
|
||||
* @return Unmodifiable view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static PrintServiceAttributeSet
|
||||
unmodifiableView(PrintServiceAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new UnmodifiablePrintServiceAttributeSet (attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class SynchronizedAttributeSet
|
||||
implements AttributeSet, Serializable {
|
||||
|
||||
private AttributeSet attrset;
|
||||
|
||||
public SynchronizedAttributeSet(AttributeSet attributeSet) {
|
||||
attrset = attributeSet;
|
||||
}
|
||||
|
||||
public synchronized Attribute get(Class<?> category) {
|
||||
return attrset.get(category);
|
||||
}
|
||||
|
||||
public synchronized boolean add(Attribute attribute) {
|
||||
return attrset.add(attribute);
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Class<?> category) {
|
||||
return attrset.remove(category);
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Attribute attribute) {
|
||||
return attrset.remove(attribute);
|
||||
}
|
||||
|
||||
public synchronized boolean containsKey(Class<?> category) {
|
||||
return attrset.containsKey(category);
|
||||
}
|
||||
|
||||
public synchronized boolean containsValue(Attribute attribute) {
|
||||
return attrset.containsValue(attribute);
|
||||
}
|
||||
|
||||
public synchronized boolean addAll(AttributeSet attributes) {
|
||||
return attrset.addAll(attributes);
|
||||
}
|
||||
|
||||
public synchronized int size() {
|
||||
return attrset.size();
|
||||
}
|
||||
|
||||
public synchronized Attribute[] toArray() {
|
||||
return attrset.toArray();
|
||||
}
|
||||
|
||||
public synchronized void clear() {
|
||||
attrset.clear();
|
||||
}
|
||||
|
||||
public synchronized boolean isEmpty() {
|
||||
return attrset.isEmpty();
|
||||
}
|
||||
|
||||
public synchronized boolean equals(Object o) {
|
||||
return attrset.equals (o);
|
||||
}
|
||||
|
||||
public synchronized int hashCode() {
|
||||
return attrset.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class SynchronizedDocAttributeSet
|
||||
extends SynchronizedAttributeSet
|
||||
implements DocAttributeSet, Serializable {
|
||||
|
||||
public SynchronizedDocAttributeSet(DocAttributeSet attributeSet) {
|
||||
super(attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class SynchronizedPrintRequestAttributeSet
|
||||
extends SynchronizedAttributeSet
|
||||
implements PrintRequestAttributeSet, Serializable {
|
||||
|
||||
public SynchronizedPrintRequestAttributeSet
|
||||
(PrintRequestAttributeSet attributeSet) {
|
||||
super(attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class SynchronizedPrintJobAttributeSet
|
||||
extends SynchronizedAttributeSet
|
||||
implements PrintJobAttributeSet, Serializable {
|
||||
|
||||
public SynchronizedPrintJobAttributeSet
|
||||
(PrintJobAttributeSet attributeSet) {
|
||||
super(attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @serial include
|
||||
*/
|
||||
private static class SynchronizedPrintServiceAttributeSet
|
||||
extends SynchronizedAttributeSet
|
||||
implements PrintServiceAttributeSet, Serializable {
|
||||
public SynchronizedPrintServiceAttributeSet
|
||||
(PrintServiceAttributeSet attributeSet) {
|
||||
super(attributeSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a synchronized view of the given attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying attribute set.
|
||||
*
|
||||
* @return Synchronized view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static AttributeSet synchronizedView
|
||||
(AttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new SynchronizedAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a synchronized view of the given doc attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying doc attribute set.
|
||||
*
|
||||
* @return Synchronized view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static DocAttributeSet
|
||||
synchronizedView(DocAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new SynchronizedDocAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a synchronized view of the given print request attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying print request attribute set.
|
||||
*
|
||||
* @return Synchronized view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static PrintRequestAttributeSet
|
||||
synchronizedView(PrintRequestAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new SynchronizedPrintRequestAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a synchronized view of the given print job attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying print job attribute set.
|
||||
*
|
||||
* @return Synchronized view of <CODE>attributeSet</CODE>.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* Thrown if <CODE>attributeSet</CODE> is null.
|
||||
*/
|
||||
public static PrintJobAttributeSet
|
||||
synchronizedView(PrintJobAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new SynchronizedPrintJobAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a synchronized view of the given print service attribute set.
|
||||
*
|
||||
* @param attributeSet Underlying print service attribute set.
|
||||
*
|
||||
* @return Synchronized view of <CODE>attributeSet</CODE>.
|
||||
*/
|
||||
public static PrintServiceAttributeSet
|
||||
synchronizedView(PrintServiceAttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return new SynchronizedPrintServiceAttributeSet(attributeSet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verify that the given object is a {@link java.lang.Class Class} that
|
||||
* implements the given interface, which is assumed to be interface {@link
|
||||
* Attribute Attribute} or a subinterface thereof.
|
||||
*
|
||||
* @param object Object to test.
|
||||
* @param interfaceName Interface the object must implement.
|
||||
*
|
||||
* @return If <CODE>object</CODE> is a {@link java.lang.Class Class}
|
||||
* that implements <CODE>interfaceName</CODE>,
|
||||
* <CODE>object</CODE> is returned downcast to type {@link
|
||||
* java.lang.Class Class}; otherwise an exception is thrown.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>object</CODE> is null.
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if <CODE>object</CODE> is not a
|
||||
* {@link java.lang.Class Class} that implements
|
||||
* <CODE>interfaceName</CODE>.
|
||||
*/
|
||||
public static Class<?>
|
||||
verifyAttributeCategory(Object object, Class<?> interfaceName) {
|
||||
|
||||
Class result = (Class) object;
|
||||
if (interfaceName.isAssignableFrom (result)) {
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
throw new ClassCastException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the given object is an instance of the given interface, which
|
||||
* is assumed to be interface {@link Attribute Attribute} or a subinterface
|
||||
* thereof.
|
||||
*
|
||||
* @param object Object to test.
|
||||
* @param interfaceName Interface of which the object must be an instance.
|
||||
*
|
||||
* @return If <CODE>object</CODE> is an instance of
|
||||
* <CODE>interfaceName</CODE>, <CODE>object</CODE> is returned
|
||||
* downcast to type {@link Attribute Attribute}; otherwise an
|
||||
* exception is thrown.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>object</CODE> is null.
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if <CODE>object</CODE> is not an
|
||||
* instance of <CODE>interfaceName</CODE>.
|
||||
*/
|
||||
public static Attribute
|
||||
verifyAttributeValue(Object object, Class<?> interfaceName) {
|
||||
|
||||
if (object == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
else if (interfaceName.isInstance (object)) {
|
||||
return (Attribute) object;
|
||||
} else {
|
||||
throw new ClassCastException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the given attribute category object is equal to the
|
||||
* category of the given attribute value object. If so, this method
|
||||
* returns doing nothing. If not, this method throws an exception.
|
||||
*
|
||||
* @param category Attribute category to test.
|
||||
* @param attribute Attribute value to test.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>category</CODE> is
|
||||
* null or if the <CODE>attribute</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if the <CODE>category</CODE> is not
|
||||
* equal to the category of the <CODE>attribute</CODE>.
|
||||
*/
|
||||
public static void
|
||||
verifyCategoryForValue(Class<?> category, Attribute attribute) {
|
||||
|
||||
if (!category.equals (attribute.getCategory())) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
}
|
||||
146
jdkSrc/jdk8/javax/print/attribute/DateTimeSyntax.java
Normal file
146
jdkSrc/jdk8/javax/print/attribute/DateTimeSyntax.java
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Class DateTimeSyntax is an abstract base class providing the common
|
||||
* implementation of all attributes whose value is a date and time.
|
||||
* <P>
|
||||
* Under the hood, a date-time attribute is stored as a value of class <code>
|
||||
* java.util.Date</code>. You can get a date-time attribute's Date value by
|
||||
* calling {@link #getValue() getValue()}. A date-time attribute's
|
||||
* Date value is established when it is constructed (see {@link
|
||||
* #DateTimeSyntax(Date) DateTimeSyntax(Date)}). Once
|
||||
* constructed, a date-time attribute's value is immutable.
|
||||
* <P>
|
||||
* To construct a date-time attribute from separate values of the year, month,
|
||||
* day, hour, minute, and so on, use a <code>java.util.Calendar</code>
|
||||
* object to construct a <code>java.util.Date</code> object, then use the
|
||||
* <code>java.util.Date</code> object to construct the date-time attribute.
|
||||
* To convert
|
||||
* a date-time attribute to separate values of the year, month, day, hour,
|
||||
* minute, and so on, create a <code>java.util.Calendar</code> object and
|
||||
* set it to the <code>java.util.Date</code> from the date-time attribute. Class
|
||||
* DateTimeSyntax stores its value in the form of a <code>java.util.Date
|
||||
* </code>
|
||||
* rather than a <code>java.util.Calendar</code> because it typically takes
|
||||
* less memory to store and less time to compare a <code>java.util.Date</code>
|
||||
* than a <code>java.util.Calendar</code>.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class DateTimeSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -1400819079791208582L;
|
||||
|
||||
// Hidden data members.
|
||||
|
||||
/**
|
||||
* This date-time attribute's<code>java.util.Date</code> value.
|
||||
* @serial
|
||||
*/
|
||||
private Date value;
|
||||
|
||||
// Hidden constructors.
|
||||
|
||||
/**
|
||||
* Construct a new date-time attribute with the given
|
||||
* <code>java.util.Date </code> value.
|
||||
*
|
||||
* @param value <code>java.util.Date</code> value.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>theValue</CODE> is null.
|
||||
*/
|
||||
protected DateTimeSyntax(Date value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value is null");
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
// Exported operations.
|
||||
|
||||
/**
|
||||
* Returns this date-time attribute's <code>java.util.Date</code>
|
||||
* value.
|
||||
* @return the Date.
|
||||
*/
|
||||
public Date getValue() {
|
||||
return new Date (value.getTime());
|
||||
}
|
||||
|
||||
// Exported operations inherited and overridden from class Object.
|
||||
|
||||
/**
|
||||
* Returns whether this date-time attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class DateTimeSyntax.
|
||||
* <LI>
|
||||
* This date-time attribute's <code>java.util.Date</code> value and
|
||||
* <CODE>object</CODE>'s <code>java.util.Date</code> value are
|
||||
* equal. </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this date-time
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (object != null &&
|
||||
object instanceof DateTimeSyntax &&
|
||||
value.equals(((DateTimeSyntax) object).value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this date-time attribute. The hashcode is
|
||||
* that of this attribute's <code>java.util.Date</code> value.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string value corresponding to this date-time attribute.
|
||||
* The string value is just this attribute's
|
||||
* <code>java.util.Date</code> value
|
||||
* converted to a string.
|
||||
*/
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
|
||||
}
|
||||
48
jdkSrc/jdk8/javax/print/attribute/DocAttribute.java
Normal file
48
jdkSrc/jdk8/javax/print/attribute/DocAttribute.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface DocAttribute is a tagging interface which a printing attribute
|
||||
* class implements to indicate the attribute denotes a setting for a doc.
|
||||
* ("Doc" is a short, easy-to-pronounce term that means "a piece of print
|
||||
* data.") The client may include a DocAttribute in a <code>Doc</code>'s
|
||||
* attribute set to specify a characteristic of
|
||||
* that doc. If an attribute implements {@link PrintRequestAttribute
|
||||
* PrintRequestAttribute} as well as DocAttribute, the client may include the
|
||||
* attribute in a attribute set which specifies a print job
|
||||
* to specify a characteristic for all the docs in that job.
|
||||
* <P>
|
||||
*
|
||||
* @see DocAttributeSet
|
||||
* @see PrintRequestAttributeSet
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface DocAttribute extends Attribute {
|
||||
|
||||
}
|
||||
111
jdkSrc/jdk8/javax/print/attribute/DocAttributeSet.java
Normal file
111
jdkSrc/jdk8/javax/print/attribute/DocAttributeSet.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface DocAttributeSet specifies the interface for a set of doc
|
||||
* attributes, i.e. printing attributes that implement interface {@link
|
||||
* DocAttribute DocAttribute}. In the Print Service API, the client uses a
|
||||
* DocAttributeSet to specify the characteristics of an individual doc and
|
||||
* the print job settings to be applied to an individual doc.
|
||||
* <P>
|
||||
* A DocAttributeSet is just an {@link AttributeSet AttributeSet} whose
|
||||
* constructors and mutating operations guarantee an additional invariant,
|
||||
* namely that all attribute values in the DocAttributeSet must be instances
|
||||
* of interface {@link DocAttribute DocAttribute}.
|
||||
* The {@link #add(Attribute) add(Attribute)}, and
|
||||
* {@link #addAll(AttributeSet) addAll(AttributeSet)} operations
|
||||
* are respecified below to guarantee this additional invariant.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface DocAttributeSet extends AttributeSet {
|
||||
|
||||
|
||||
/**
|
||||
* Adds the specified attribute value to this attribute set if it is not
|
||||
* already present, first removing any existing value in the same
|
||||
* attribute category as the specified attribute value (optional
|
||||
* operation).
|
||||
*
|
||||
* @param attribute Attribute value to be added to this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call, i.e., the given attribute value was not already a
|
||||
* member of this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not
|
||||
* support the <CODE>add()</CODE> operation.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is
|
||||
* not an instance of interface
|
||||
* {@link DocAttribute DocAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public boolean add(Attribute attribute);
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified set to this attribute.
|
||||
* The outcome is the same as if the
|
||||
* {@link #add(Attribute) add(Attribute)}
|
||||
* operation had been applied to this attribute set successively with
|
||||
* each element from the specified set. If none of the categories in the
|
||||
* specified set are the same as any categories in this attribute set,
|
||||
* the <tt>addAll()</tt> operation effectively modifies this attribute
|
||||
* set so that its value is the <i>union</i> of the two sets.
|
||||
* <P>
|
||||
* The behavior of the <CODE>addAll()</CODE> operation is unspecified if
|
||||
* the specified set is modified while the operation is in progress.
|
||||
* <P>
|
||||
* If the <CODE>addAll()</CODE> operation throws an exception, the effect
|
||||
* on this attribute set's state is implementation dependent; elements
|
||||
* from the specified set before the point of the exception may or
|
||||
* may not have been added to this attribute set.
|
||||
*
|
||||
* @param attributes whose elements are to be added to this attribute
|
||||
* set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (Unchecked exception) Thrown if this attribute set does not
|
||||
* support the <tt>addAll()</tt> method.
|
||||
* @throws ClassCastException
|
||||
* (Unchecked exception) Thrown if some element in the specified
|
||||
* set is not an instance of interface {@link DocAttribute
|
||||
* DocAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (Unchecked exception) Thrown if the specified set is null.
|
||||
*
|
||||
* @see #add(Attribute)
|
||||
*/
|
||||
public boolean addAll(AttributeSet attributes);
|
||||
}
|
||||
281
jdkSrc/jdk8/javax/print/attribute/EnumSyntax.java
Normal file
281
jdkSrc/jdk8/javax/print/attribute/EnumSyntax.java
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class EnumSyntax is an abstract base class providing the common
|
||||
* implementation of all "type safe enumeration" objects. An enumeration class
|
||||
* (which extends class EnumSyntax) provides a group of enumeration values
|
||||
* (objects) that are singleton instances of the enumeration class; for example:
|
||||
* <PRE>
|
||||
* public class Bach extends EnumSyntax {
|
||||
* public static final Bach JOHANN_SEBASTIAN = new Bach(0);
|
||||
* public static final Bach WILHELM_FRIEDEMANN = new Bach(1);
|
||||
* public static final Bach CARL_PHILIP_EMMANUEL = new Bach(2);
|
||||
* public static final Bach JOHANN_CHRISTIAN = new Bach(3);
|
||||
* public static final Bach P_D_Q = new Bach(4);
|
||||
*
|
||||
* private static final String[] stringTable = {
|
||||
* "Johann Sebastian Bach",
|
||||
* "Wilhelm Friedemann Bach",
|
||||
* "Carl Philip Emmanuel Bach",
|
||||
* "Johann Christian Bach",
|
||||
* "P.D.Q. Bach"
|
||||
* };
|
||||
*
|
||||
* protected String[] getStringTable() {
|
||||
* return stringTable;
|
||||
* }
|
||||
*
|
||||
* private static final Bach[] enumValueTable = {
|
||||
* JOHANN_SEBASTIAN,
|
||||
* WILHELM_FRIEDEMANN,
|
||||
* CARL_PHILIP_EMMANUEL,
|
||||
* JOHANN_CHRISTIAN,
|
||||
* P_D_Q
|
||||
* };
|
||||
*
|
||||
* protected EnumSyntax[] getEnumValueTable() {
|
||||
* return enumValueTable;
|
||||
* }
|
||||
* }
|
||||
* </PRE>
|
||||
* You can then write code that uses the <CODE>==</CODE> and <CODE>!=</CODE>
|
||||
* operators to test enumeration values; for example:
|
||||
* <PRE>
|
||||
* Bach theComposer;
|
||||
* . . .
|
||||
* if (theComposer == Bach.JOHANN_SEBASTIAN) {
|
||||
* System.out.println ("The greatest composer of all time!");
|
||||
* }
|
||||
* </PRE>
|
||||
* The <CODE>equals()</CODE> method for an enumeration class just does a test
|
||||
* for identical objects (<CODE>==</CODE>).
|
||||
* <P>
|
||||
* You can convert an enumeration value to a string by calling {@link
|
||||
* #toString() toString()}. The string is obtained from a table
|
||||
* supplied by the enumeration class.
|
||||
* <P>
|
||||
* Under the hood, an enumeration value is just an integer, a different integer
|
||||
* for each enumeration value within an enumeration class. You can get an
|
||||
* enumeration value's integer value by calling {@link #getValue()
|
||||
* getValue()}. An enumeration value's integer value is established
|
||||
* when it is constructed (see {@link #EnumSyntax(int)
|
||||
* EnumSyntax(int)}). Since the constructor is protected, the only
|
||||
* possible enumeration values are the singleton objects declared in the
|
||||
* enumeration class; additional enumeration values cannot be created at run
|
||||
* time.
|
||||
* <P>
|
||||
* You can define a subclass of an enumeration class that extends it with
|
||||
* additional enumeration values. The subclass's enumeration values' integer
|
||||
* values need not be distinct from the superclass's enumeration values' integer
|
||||
* values; the <CODE>==</CODE>, <CODE>!=</CODE>, <CODE>equals()</CODE>, and
|
||||
* <CODE>toString()</CODE> methods will still work properly even if the subclass
|
||||
* uses some of the same integer values as the superclass. However, the
|
||||
* application in which the enumeration class and subclass are used may need to
|
||||
* have distinct integer values in the superclass and subclass.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class EnumSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -2739521845085831642L;
|
||||
|
||||
/**
|
||||
* This enumeration value's integer value.
|
||||
* @serial
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Construct a new enumeration value with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected EnumSyntax(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this enumeration value's integer value.
|
||||
* @return the value
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of this enumeration value, which to preserve the
|
||||
* semantics of enumeration values is the same object as this enumeration
|
||||
* value.
|
||||
*/
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this enumeration value. The hash code is
|
||||
* just this enumeration value's integer value.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string value corresponding to this enumeration value.
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
String[] theTable = getStringTable();
|
||||
int theIndex = value - getOffset();
|
||||
return
|
||||
theTable != null && theIndex >= 0 && theIndex < theTable.length ?
|
||||
theTable[theIndex] :
|
||||
Integer.toString (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* During object input, convert this deserialized enumeration instance to
|
||||
* the proper enumeration value defined in the enumeration attribute class.
|
||||
*
|
||||
* @return The enumeration singleton value stored at index
|
||||
* <I>i</I>-<I>L</I> in the enumeration value table returned by
|
||||
* {@link #getEnumValueTable() getEnumValueTable()},
|
||||
* where <I>i</I> is this enumeration value's integer value and
|
||||
* <I>L</I> is the value returned by {@link #getOffset()
|
||||
* getOffset()}.
|
||||
*
|
||||
* @throws ObjectStreamException if the stream can't be deserialised
|
||||
* @throws InvalidObjectException
|
||||
* Thrown if the enumeration value table is null, this enumeration
|
||||
* value's integer value does not correspond to an element in the
|
||||
* enumeration value table, or the corresponding element in the
|
||||
* enumeration value table is null. (Note: {@link
|
||||
* java.io.InvalidObjectException InvalidObjectException} is a subclass
|
||||
* of {@link java.io.ObjectStreamException ObjectStreamException}, which
|
||||
* <CODE>readResolve()</CODE> is declared to throw.)
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
|
||||
EnumSyntax[] theTable = getEnumValueTable();
|
||||
|
||||
if (theTable == null) {
|
||||
throw new InvalidObjectException(
|
||||
"Null enumeration value table for class " +
|
||||
getClass());
|
||||
}
|
||||
|
||||
int theOffset = getOffset();
|
||||
int theIndex = value - theOffset;
|
||||
|
||||
if (0 > theIndex || theIndex >= theTable.length) {
|
||||
throw new InvalidObjectException
|
||||
("Integer value = " + value + " not in valid range " +
|
||||
theOffset + ".." + (theOffset + theTable.length - 1) +
|
||||
"for class " + getClass());
|
||||
}
|
||||
|
||||
EnumSyntax result = theTable[theIndex];
|
||||
if (result == null) {
|
||||
throw new InvalidObjectException
|
||||
("No enumeration value for integer value = " +
|
||||
value + "for class " + getClass());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Hidden operations to be implemented in a subclass.
|
||||
|
||||
/**
|
||||
* Returns the string table for this enumeration value's enumeration class.
|
||||
* The enumeration class's integer values are assumed to lie in the range
|
||||
* <I>L</I>..<I>L</I>+<I>N</I>-1, where <I>L</I> is the value returned by
|
||||
* {@link #getOffset() getOffset()} and <I>N</I> is the length
|
||||
* of the string table. The element in the string table at index
|
||||
* <I>i</I>-<I>L</I> is the value returned by {@link #toString()
|
||||
* toString()} for the enumeration value whose integer value
|
||||
* is <I>i</I>. If an integer within the above range is not used by any
|
||||
* enumeration value, leave the corresponding table element null.
|
||||
* <P>
|
||||
* The default implementation returns null. If the enumeration class (a
|
||||
* subclass of class EnumSyntax) does not override this method to return a
|
||||
* non-null string table, and the subclass does not override the {@link
|
||||
* #toString() toString()} method, the base class {@link
|
||||
* #toString() toString()} method will return just a string
|
||||
* representation of this enumeration value's integer value.
|
||||
* @return the string table
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for this enumeration value's
|
||||
* enumeration class. The enumeration class's integer values are assumed to
|
||||
* lie in the range <I>L</I>..<I>L</I>+<I>N</I>-1, where <I>L</I> is the
|
||||
* value returned by {@link #getOffset() getOffset()} and
|
||||
* <I>N</I> is the length of the enumeration value table. The element in the
|
||||
* enumeration value table at index <I>i</I>-<I>L</I> is the enumeration
|
||||
* value object whose integer value is <I>i</I>; the {@link #readResolve()
|
||||
* readResolve()} method needs this to preserve singleton
|
||||
* semantics during deserialization of an enumeration instance. If an
|
||||
* integer within the above range is not used by any enumeration value,
|
||||
* leave the corresponding table element null.
|
||||
* <P>
|
||||
* The default implementation returns null. If the enumeration class (a
|
||||
* subclass of class EnumSyntax) does not override this method to return
|
||||
* a non-null enumeration value table, and the subclass does not override
|
||||
* the {@link #readResolve() readResolve()} method, the base
|
||||
* class {@link #readResolve() readResolve()} method will throw
|
||||
* an exception whenever an enumeration instance is deserialized from an
|
||||
* object input stream.
|
||||
* @return the value table
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowest integer value used by this enumeration value's
|
||||
* enumeration class.
|
||||
* <P>
|
||||
* The default implementation returns 0. If the enumeration class (a
|
||||
* subclass of class EnumSyntax) uses integer values starting at other than
|
||||
* 0, override this method in the subclass.
|
||||
* @return the offset of the lowest enumeration value.
|
||||
*/
|
||||
protected int getOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
528
jdkSrc/jdk8/javax/print/attribute/HashAttributeSet.java
Normal file
528
jdkSrc/jdk8/javax/print/attribute/HashAttributeSet.java
Normal file
@@ -0,0 +1,528 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Class HashAttributeSet provides an <code>AttributeSet</code>
|
||||
* implementation with characteristics of a hash map.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class HashAttributeSet implements AttributeSet, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5311560590283707917L;
|
||||
|
||||
/**
|
||||
* The interface of which all members of this attribute set must be an
|
||||
* instance. It is assumed to be interface {@link Attribute Attribute}
|
||||
* or a subinterface thereof.
|
||||
* @serial
|
||||
*/
|
||||
private Class myInterface;
|
||||
|
||||
/*
|
||||
* A HashMap used by the implementation.
|
||||
* The serialised form doesn't include this instance variable.
|
||||
*/
|
||||
private transient HashMap attrMap = new HashMap();
|
||||
|
||||
/**
|
||||
* Write the instance to a stream (ie serialize the object)
|
||||
*
|
||||
* @serialData
|
||||
* The serialized form of an attribute set explicitly writes the
|
||||
* number of attributes in the set, and each of the attributes.
|
||||
* This does not guarantee equality of serialized forms since
|
||||
* the order in which the attributes are written is not defined.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream s) throws IOException {
|
||||
|
||||
s.defaultWriteObject();
|
||||
Attribute [] attrs = toArray();
|
||||
s.writeInt(attrs.length);
|
||||
for (int i = 0; i < attrs.length; i++) {
|
||||
s.writeObject(attrs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconstitute an instance from a stream that is, deserialize it).
|
||||
*/
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws ClassNotFoundException, IOException {
|
||||
|
||||
s.defaultReadObject();
|
||||
attrMap = new HashMap();
|
||||
int count = s.readInt();
|
||||
Attribute attr;
|
||||
for (int i = 0; i < count; i++) {
|
||||
attr = (Attribute)s.readObject();
|
||||
add(attr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new, empty attribute set.
|
||||
*/
|
||||
public HashAttributeSet() {
|
||||
this(Attribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set,
|
||||
* initially populated with the given attribute.
|
||||
*
|
||||
* @param attribute Attribute value to add to the set.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public HashAttributeSet(Attribute attribute) {
|
||||
this (attribute, Attribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set,
|
||||
* initially populated with the values from the
|
||||
* given array. The new attribute set is populated by
|
||||
* adding the elements of <CODE>attributes</CODE> array to the set in
|
||||
* sequence, starting at index 0. Thus, later array elements may replace
|
||||
* earlier array elements if the array contains duplicate attribute
|
||||
* values or attribute categories.
|
||||
*
|
||||
* @param attributes Array of attribute values to add to the set.
|
||||
* If null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is null.
|
||||
*/
|
||||
public HashAttributeSet(Attribute[] attributes) {
|
||||
this (attributes, Attribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set,
|
||||
* initially populated with the values from the given set.
|
||||
*
|
||||
* @param attributes Set of attributes from which to initialise this set.
|
||||
* If null, an empty attribute set is constructed.
|
||||
*
|
||||
*/
|
||||
public HashAttributeSet(AttributeSet attributes) {
|
||||
this (attributes, Attribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new, empty attribute set, where the members of
|
||||
* the attribute set are restricted to the given interface.
|
||||
*
|
||||
* @param interfaceName The interface of which all members of this
|
||||
* attribute set must be an instance. It is assumed to
|
||||
* be interface {@link Attribute Attribute} or a
|
||||
* subinterface thereof.
|
||||
* @exception NullPointerException if interfaceName is null.
|
||||
*/
|
||||
protected HashAttributeSet(Class<?> interfaceName) {
|
||||
if (interfaceName == null) {
|
||||
throw new NullPointerException("null interface");
|
||||
}
|
||||
myInterface = interfaceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, initially populated with the given
|
||||
* attribute, where the members of the attribute set are restricted to the
|
||||
* given interface.
|
||||
*
|
||||
* @param attribute Attribute value to add to the set.
|
||||
* @param interfaceName The interface of which all members of this
|
||||
* attribute set must be an instance. It is assumed to
|
||||
* be interface {@link Attribute Attribute} or a
|
||||
* subinterface thereof.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is null.
|
||||
* @exception NullPointerException if interfaceName is null.
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is not an
|
||||
* instance of <CODE>interfaceName</CODE>.
|
||||
*/
|
||||
protected HashAttributeSet(Attribute attribute, Class<?> interfaceName) {
|
||||
if (interfaceName == null) {
|
||||
throw new NullPointerException("null interface");
|
||||
}
|
||||
myInterface = interfaceName;
|
||||
add (attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, where the members of the attribute
|
||||
* set are restricted to the given interface.
|
||||
* The new attribute set is populated
|
||||
* by adding the elements of <CODE>attributes</CODE> array to the set in
|
||||
* sequence, starting at index 0. Thus, later array elements may replace
|
||||
* earlier array elements if the array contains duplicate attribute
|
||||
* values or attribute categories.
|
||||
*
|
||||
* @param attributes Array of attribute values to add to the set. If
|
||||
* null, an empty attribute set is constructed.
|
||||
* @param interfaceName The interface of which all members of this
|
||||
* attribute set must be an instance. It is assumed to
|
||||
* be interface {@link Attribute Attribute} or a
|
||||
* subinterface thereof.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is null.
|
||||
* @exception NullPointerException if interfaceName is null.
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is not an instance of
|
||||
* <CODE>interfaceName</CODE>.
|
||||
*/
|
||||
protected HashAttributeSet(Attribute[] attributes, Class<?> interfaceName) {
|
||||
if (interfaceName == null) {
|
||||
throw new NullPointerException("null interface");
|
||||
}
|
||||
myInterface = interfaceName;
|
||||
int n = attributes == null ? 0 : attributes.length;
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
add (attributes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, initially populated with the
|
||||
* values from the given set where the members of the attribute
|
||||
* set are restricted to the given interface.
|
||||
*
|
||||
* @param attributes set of attribute values to initialise the set. If
|
||||
* null, an empty attribute set is constructed.
|
||||
* @param interfaceName The interface of which all members of this
|
||||
* attribute set must be an instance. It is assumed to
|
||||
* be interface {@link Attribute Attribute} or a
|
||||
* subinterface thereof.
|
||||
*
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is not an instance of
|
||||
* <CODE>interfaceName</CODE>.
|
||||
*/
|
||||
protected HashAttributeSet(AttributeSet attributes, Class<?> interfaceName) {
|
||||
myInterface = interfaceName;
|
||||
if (attributes != null) {
|
||||
Attribute[] attribArray = attributes.toArray();
|
||||
int n = attribArray == null ? 0 : attribArray.length;
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
add (attribArray[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the attribute value which this attribute set contains in the
|
||||
* given attribute category. Returns <tt>null</tt> if this attribute set
|
||||
* does not contain any attribute value in the given attribute category.
|
||||
*
|
||||
* @param category Attribute category whose associated attribute value
|
||||
* is to be returned. It must be a
|
||||
* {@link java.lang.Class Class}
|
||||
* that implements interface {@link Attribute
|
||||
* Attribute}.
|
||||
*
|
||||
* @return The attribute value in the given attribute category contained
|
||||
* in this attribute set, or <tt>null</tt> if this attribute set
|
||||
* does not contain any attribute value in the given attribute
|
||||
* category.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>category</CODE> is null.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the <CODE>category</CODE> is not a
|
||||
* {@link java.lang.Class Class} that implements interface {@link
|
||||
* Attribute Attribute}.
|
||||
*/
|
||||
public Attribute get(Class<?> category) {
|
||||
return (Attribute)
|
||||
attrMap.get(AttributeSetUtilities.
|
||||
verifyAttributeCategory(category,
|
||||
Attribute.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified attribute to this attribute set if it is not
|
||||
* already present, first removing any existing in the same
|
||||
* attribute category as the specified attribute value.
|
||||
*
|
||||
* @param attribute Attribute value to be added to this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call, i.e., the given attribute value was not already a
|
||||
* member of this attribute set.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not support
|
||||
* the <CODE>add()</CODE> operation.
|
||||
*/
|
||||
public boolean add(Attribute attribute) {
|
||||
Object oldAttribute =
|
||||
attrMap.put(attribute.getCategory(),
|
||||
AttributeSetUtilities.
|
||||
verifyAttributeValue(attribute, myInterface));
|
||||
return (!attribute.equals(oldAttribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes any attribute for this category from this attribute set if
|
||||
* present. If <CODE>category</CODE> is null, then
|
||||
* <CODE>remove()</CODE> does nothing and returns <tt>false</tt>.
|
||||
*
|
||||
* @param category Attribute category to be removed from this
|
||||
* attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call, i.e., the given attribute category had been a member of
|
||||
* this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not
|
||||
* support the <CODE>remove()</CODE> operation.
|
||||
*/
|
||||
public boolean remove(Class<?> category) {
|
||||
return
|
||||
category != null &&
|
||||
AttributeSetUtilities.
|
||||
verifyAttributeCategory(category, Attribute.class) != null &&
|
||||
attrMap.remove(category) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified attribute from this attribute set if
|
||||
* present. If <CODE>attribute</CODE> is null, then
|
||||
* <CODE>remove()</CODE> does nothing and returns <tt>false</tt>.
|
||||
*
|
||||
* @param attribute Attribute value to be removed from this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call, i.e., the given attribute value had been a member of
|
||||
* this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not
|
||||
* support the <CODE>remove()</CODE> operation.
|
||||
*/
|
||||
public boolean remove(Attribute attribute) {
|
||||
return
|
||||
attribute != null &&
|
||||
attrMap.remove(attribute.getCategory()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this attribute set contains an
|
||||
* attribute for the specified category.
|
||||
*
|
||||
* @param category whose presence in this attribute set is
|
||||
* to be tested.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set contains an attribute
|
||||
* value for the specified category.
|
||||
*/
|
||||
public boolean containsKey(Class<?> category) {
|
||||
return
|
||||
category != null &&
|
||||
AttributeSetUtilities.
|
||||
verifyAttributeCategory(category, Attribute.class) != null &&
|
||||
attrMap.get(category) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if this attribute set contains the given
|
||||
* attribute.
|
||||
*
|
||||
* @param attribute value whose presence in this attribute set is
|
||||
* to be tested.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set contains the given
|
||||
* attribute value.
|
||||
*/
|
||||
public boolean containsValue(Attribute attribute) {
|
||||
return
|
||||
attribute != null &&
|
||||
attribute instanceof Attribute &&
|
||||
attribute.equals(attrMap.get(((Attribute)attribute).getCategory()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified set to this attribute.
|
||||
* The outcome is the same as if the
|
||||
* {@link #add(Attribute) add(Attribute)}
|
||||
* operation had been applied to this attribute set successively with
|
||||
* each element from the specified set.
|
||||
* The behavior of the <CODE>addAll(AttributeSet)</CODE>
|
||||
* operation is unspecified if the specified set is modified while
|
||||
* the operation is in progress.
|
||||
* <P>
|
||||
* If the <CODE>addAll(AttributeSet)</CODE> operation throws an exception,
|
||||
* the effect on this attribute set's state is implementation dependent;
|
||||
* elements from the specified set before the point of the exception may
|
||||
* or may not have been added to this attribute set.
|
||||
*
|
||||
* @param attributes whose elements are to be added to this attribute
|
||||
* set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of the
|
||||
* call.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (Unchecked exception) Thrown if this attribute set does not
|
||||
* support the <tt>addAll(AttributeSet)</tt> method.
|
||||
* @throws NullPointerException
|
||||
* (Unchecked exception) Thrown if some element in the specified
|
||||
* set is null, or the set is null.
|
||||
*
|
||||
* @see #add(Attribute)
|
||||
*/
|
||||
public boolean addAll(AttributeSet attributes) {
|
||||
|
||||
Attribute []attrs = attributes.toArray();
|
||||
boolean result = false;
|
||||
for (int i=0; i<attrs.length; i++) {
|
||||
Attribute newValue =
|
||||
AttributeSetUtilities.verifyAttributeValue(attrs[i],
|
||||
myInterface);
|
||||
Object oldValue = attrMap.put(newValue.getCategory(), newValue);
|
||||
result = (! newValue.equals(oldValue)) || result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of attributes in this attribute set. If this
|
||||
* attribute set contains more than <tt>Integer.MAX_VALUE</tt> elements,
|
||||
* returns <tt>Integer.MAX_VALUE</tt>.
|
||||
*
|
||||
* @return The number of attributes in this attribute set.
|
||||
*/
|
||||
public int size() {
|
||||
return attrMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the Attributes contained in this set as an array, zero length
|
||||
* if the AttributeSet is empty.
|
||||
*/
|
||||
public Attribute[] toArray() {
|
||||
Attribute []attrs = new Attribute[size()];
|
||||
attrMap.values().toArray(attrs);
|
||||
return attrs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes all attributes from this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not support
|
||||
* the <CODE>clear()</CODE> operation.
|
||||
*/
|
||||
public void clear() {
|
||||
attrMap.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this attribute set contains no attributes.
|
||||
*
|
||||
* @return true if this attribute set contains no attributes.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return attrMap.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the specified object with this attribute set for equality.
|
||||
* Returns <tt>true</tt> if the given object is also an attribute set and
|
||||
* the two attribute sets contain the same attribute category-attribute
|
||||
* value mappings. This ensures that the
|
||||
* <tt>equals()</tt> method works properly across different
|
||||
* implementations of the AttributeSet interface.
|
||||
*
|
||||
* @param object to be compared for equality with this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if the specified object is equal to this
|
||||
* attribute set.
|
||||
*/
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object == null || !(object instanceof AttributeSet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AttributeSet aset = (AttributeSet)object;
|
||||
if (aset.size() != size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Attribute[] attrs = toArray();
|
||||
for (int i=0;i<attrs.length; i++) {
|
||||
if (!aset.containsValue(attrs[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hash code value for this attribute set.
|
||||
* The hash code of an attribute set is defined to be the sum
|
||||
* of the hash codes of each entry in the AttributeSet.
|
||||
* This ensures that <tt>t1.equals(t2)</tt> implies that
|
||||
* <tt>t1.hashCode()==t2.hashCode()</tt> for any two attribute sets
|
||||
* <tt>t1</tt> and <tt>t2</tt>, as required by the general contract of
|
||||
* {@link java.lang.Object#hashCode() Object.hashCode()}.
|
||||
*
|
||||
* @return The hash code value for this attribute set.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int hcode = 0;
|
||||
Attribute[] attrs = toArray();
|
||||
for (int i=0;i<attrs.length; i++) {
|
||||
hcode += attrs[i].hashCode();
|
||||
}
|
||||
return hcode;
|
||||
}
|
||||
|
||||
}
|
||||
102
jdkSrc/jdk8/javax/print/attribute/HashDocAttributeSet.java
Normal file
102
jdkSrc/jdk8/javax/print/attribute/HashDocAttributeSet.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class HashDocAttributeSet provides an attribute set which
|
||||
* inherits its implementation from class {@link HashAttributeSet
|
||||
* HashAttributeSet} and enforces the semantic restrictions of interface {@link
|
||||
* DocAttributeSet DocAttributeSet}.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class HashDocAttributeSet extends HashAttributeSet
|
||||
implements DocAttributeSet, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1128534486061432528L;
|
||||
|
||||
/**
|
||||
* Construct a new, empty hash doc attribute set.
|
||||
*/
|
||||
public HashDocAttributeSet() {
|
||||
super (DocAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new hash doc attribute set,
|
||||
* initially populated with the given value.
|
||||
*
|
||||
* @param attribute Attribute value to add to the set.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public HashDocAttributeSet(DocAttribute attribute) {
|
||||
super (attribute, DocAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new hash doc attribute set,
|
||||
* initially populated with the values from the given array.
|
||||
* The new attribute set is populated by
|
||||
* adding the elements of <CODE>attributes</CODE> array to the set in
|
||||
* sequence, starting at index 0. Thus, later array elements may replace
|
||||
* earlier array elements if the array contains duplicate attribute
|
||||
* values or attribute categories.
|
||||
*
|
||||
* @param attributes Array of attribute values to add to the set.
|
||||
* If null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception)
|
||||
* Thrown if any element of <CODE>attributes</CODE> is null.
|
||||
*/
|
||||
public HashDocAttributeSet(DocAttribute[] attributes) {
|
||||
super (attributes, DocAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, initially populated with the
|
||||
* values from the given set where the members of the attribute set
|
||||
* are restricted to the <code>DocAttribute</code> interface.
|
||||
*
|
||||
* @param attributes set of attribute values to initialise the set. If
|
||||
* null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is not an instance of
|
||||
* <CODE>DocAttribute</CODE>.
|
||||
*/
|
||||
public HashDocAttributeSet(DocAttributeSet attributes) {
|
||||
super(attributes, DocAttribute.class);
|
||||
}
|
||||
|
||||
}
|
||||
100
jdkSrc/jdk8/javax/print/attribute/HashPrintJobAttributeSet.java
Normal file
100
jdkSrc/jdk8/javax/print/attribute/HashPrintJobAttributeSet.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class HashPrintJobAttributeSet provides an attribute set
|
||||
* which inherits its implementation from class {@link HashAttributeSet
|
||||
* HashAttributeSet} and enforces the semantic restrictions of interface
|
||||
* {@link PrintJobAttributeSet PrintJobAttributeSet}.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class HashPrintJobAttributeSet extends HashAttributeSet
|
||||
implements PrintJobAttributeSet, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4204473656070350348L;
|
||||
|
||||
/**
|
||||
* Construct a new, empty hash print job attribute set.
|
||||
*/
|
||||
public HashPrintJobAttributeSet() {
|
||||
super(PrintJobAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new hash print job attribute set,
|
||||
* initially populated with the given value.
|
||||
*
|
||||
* @param attribute Attribute value to add to the set.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public HashPrintJobAttributeSet(PrintJobAttribute attribute) {
|
||||
super(attribute, PrintJobAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new hash print job attribute set,
|
||||
* initially populated with the values from the given array.
|
||||
* The new attribute set is populated
|
||||
* by adding the elements of <CODE>attributes</CODE> array to the set in
|
||||
* sequence, starting at index 0. Thus, later array elements may replace
|
||||
* earlier array elements if the array contains duplicate attribute
|
||||
* values or attribute categories.
|
||||
*
|
||||
* @param attributes Array of attribute values to add to the set.
|
||||
* If null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception NullPointerException (unchecked exception)
|
||||
* Thrown if any element of <CODE>attributes</CODE> is null.
|
||||
*/
|
||||
public HashPrintJobAttributeSet(PrintJobAttribute[] attributes) {
|
||||
super (attributes, PrintJobAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, initially populated with the
|
||||
* values from the given set where the members of the attribute set
|
||||
* are restricted to the <code>PrintJobAttribute</code> interface.
|
||||
*
|
||||
* @param attributes set of attribute values to initialise the set. If
|
||||
* null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is not an instance of
|
||||
* <CODE>PrintJobAttribute</CODE>.
|
||||
*/
|
||||
public HashPrintJobAttributeSet(PrintJobAttributeSet attributes) {
|
||||
super(attributes, PrintJobAttribute.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class HashPrintRequestAttributeSet inherits its implementation from
|
||||
* class {@link HashAttributeSet HashAttributeSet} and enforces the
|
||||
* semantic restrictions of interface
|
||||
* {@link PrintRequestAttributeSet PrintRequestAttributeSet}.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class HashPrintRequestAttributeSet extends HashAttributeSet
|
||||
implements PrintRequestAttributeSet, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2364756266107751933L;
|
||||
|
||||
/**
|
||||
* Construct a new, empty print request attribute set.
|
||||
*/
|
||||
public HashPrintRequestAttributeSet() {
|
||||
super (PrintRequestAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new print request attribute set,
|
||||
* initially populated with the given value.
|
||||
*
|
||||
* @param attribute Attribute value to add to the set.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public HashPrintRequestAttributeSet(PrintRequestAttribute attribute) {
|
||||
super (attribute, PrintRequestAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new print request attribute set, initially populated with
|
||||
* the values from the given array. The new attribute set is populated
|
||||
* by adding the elements of <CODE>attributes</CODE> array to the set in
|
||||
* sequence, starting at index 0. Thus, later array elements may replace
|
||||
* earlier array elements if the array contains duplicate attribute
|
||||
* values or attribute categories.
|
||||
*
|
||||
* @param attributes Array of attribute values to add to the set.
|
||||
* If null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception)
|
||||
* Thrown if any element of <CODE>attributes</CODE> is null.
|
||||
*/
|
||||
public HashPrintRequestAttributeSet(PrintRequestAttribute[] attributes) {
|
||||
super (attributes, PrintRequestAttribute.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, initially populated with the
|
||||
* values from the given set where the members of the attribute set
|
||||
* are restricted to the <code>(PrintRequestAttributeSe</code> interface.
|
||||
*
|
||||
* @param attributes set of attribute values to initialise the set. If
|
||||
* null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is not an instance of
|
||||
* <CODE>(PrintRequestAttributeSe</CODE>.
|
||||
*/
|
||||
public HashPrintRequestAttributeSet(PrintRequestAttributeSet attributes)
|
||||
{
|
||||
super(attributes, PrintRequestAttribute.class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class HashPrintServiceAttributeSet provides an attribute set
|
||||
* which inherits its implementation from class {@link HashAttributeSet
|
||||
* HashAttributeSet} and enforces the semantic restrictions of interface
|
||||
* {@link PrintServiceAttributeSet PrintServiceAttributeSet}.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class HashPrintServiceAttributeSet extends HashAttributeSet
|
||||
implements PrintServiceAttributeSet, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6642904616179203070L;
|
||||
|
||||
/**
|
||||
* Construct a new, empty hash print service attribute set.
|
||||
*/
|
||||
public HashPrintServiceAttributeSet() {
|
||||
super (PrintServiceAttribute.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new hash print service attribute set,
|
||||
* initially populated with the given value.
|
||||
*
|
||||
* @param attribute Attribute value to add to the set.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public HashPrintServiceAttributeSet(PrintServiceAttribute attribute) {
|
||||
super (attribute, PrintServiceAttribute.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new print service attribute set, initially populated with
|
||||
* the values from the given array. The new attribute set is populated
|
||||
* by adding the elements of <CODE>attributes</CODE> array to the set in
|
||||
* sequence, starting at index 0. Thus, later array elements may replace
|
||||
* earlier array elements if the array contains duplicate attribute
|
||||
* values or attribute categories.
|
||||
*
|
||||
* @param attributes Array of attribute values to add to the set.
|
||||
* If null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception)
|
||||
* Thrown if any element of <CODE>attributes</CODE> is null.
|
||||
*/
|
||||
public HashPrintServiceAttributeSet(PrintServiceAttribute[] attributes) {
|
||||
super (attributes, PrintServiceAttribute.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new attribute set, initially populated with the
|
||||
* values from the given set where the members of the attribute set
|
||||
* are restricted to the <code>PrintServiceAttribute</code> interface.
|
||||
*
|
||||
* @param attributes set of attribute values to initialise the set. If
|
||||
* null, an empty attribute set is constructed.
|
||||
*
|
||||
* @exception ClassCastException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>attributes</CODE> is not an instance of
|
||||
* <CODE>PrintServiceAttribute</CODE>.
|
||||
*/
|
||||
public HashPrintServiceAttributeSet(PrintServiceAttributeSet attributes)
|
||||
{
|
||||
super(attributes, PrintServiceAttribute.class);
|
||||
}
|
||||
}
|
||||
134
jdkSrc/jdk8/javax/print/attribute/IntegerSyntax.java
Normal file
134
jdkSrc/jdk8/javax/print/attribute/IntegerSyntax.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class IntegerSyntax is an abstract base class providing the common
|
||||
* implementation of all attributes with integer values.
|
||||
* <P>
|
||||
* Under the hood, an integer attribute is just an integer. You can get an
|
||||
* integer attribute's integer value by calling {@link #getValue()
|
||||
* getValue()}. An integer attribute's integer value is
|
||||
* established when it is constructed (see {@link #IntegerSyntax(int)
|
||||
* IntegerSyntax(int)}). Once constructed, an integer attribute's
|
||||
* value is immutable.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class IntegerSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 3644574816328081943L;
|
||||
|
||||
/**
|
||||
* This integer attribute's integer value.
|
||||
* @serial
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Construct a new integer attribute with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected IntegerSyntax(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new integer attribute with the given integer value, which
|
||||
* must lie within the given range.
|
||||
*
|
||||
* @param value Integer value.
|
||||
* @param lowerBound Lower bound.
|
||||
* @param upperBound Upper bound.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than
|
||||
* <CODE>lowerBound</CODE> or greater than
|
||||
* <CODE>upperBound</CODE>.
|
||||
*/
|
||||
protected IntegerSyntax(int value, int lowerBound, int upperBound) {
|
||||
if (lowerBound > value || value > upperBound) {
|
||||
throw new IllegalArgumentException("Value " + value +
|
||||
" not in range " + lowerBound +
|
||||
".." + upperBound);
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this integer attribute's integer value.
|
||||
* @return the integer value
|
||||
*/
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this integer attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class IntegerSyntax.
|
||||
* <LI>
|
||||
* This integer attribute's value and <CODE>object</CODE>'s value are
|
||||
* equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this integer
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
|
||||
return (object != null && object instanceof IntegerSyntax &&
|
||||
value == ((IntegerSyntax) object).value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this integer attribute. The hash code is
|
||||
* just this integer attribute's integer value.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string value corresponding to this integer attribute. The
|
||||
* string value is just this integer attribute's integer value converted to
|
||||
* a string.
|
||||
*/
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
||||
45
jdkSrc/jdk8/javax/print/attribute/PrintJobAttribute.java
Normal file
45
jdkSrc/jdk8/javax/print/attribute/PrintJobAttribute.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* PrintJobAttribute is a tagging interface which a printing attribute
|
||||
* class implements to indicate the attribute describes the status of a Print
|
||||
* Job or some other characteristic of a Print Job. A Print Service
|
||||
* instance adds a number of PrintJobAttributes to a Print Job's attribute set
|
||||
* to report the Print Job's status. If an attribute implements {@link
|
||||
* PrintRequestAttribute PrintRequestAttribute} as well as PrintJobAttribute,
|
||||
* the client may include the attribute in a attribute set to
|
||||
* specify the attribute's value for the Print Job.
|
||||
* <P>
|
||||
*
|
||||
* @see PrintRequestAttributeSet
|
||||
* @see PrintJobAttributeSet
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface PrintJobAttribute extends Attribute {
|
||||
}
|
||||
109
jdkSrc/jdk8/javax/print/attribute/PrintJobAttributeSet.java
Normal file
109
jdkSrc/jdk8/javax/print/attribute/PrintJobAttributeSet.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface PrintJobAttributeSet specifies the interface for a set of print
|
||||
* job attributes, i.e. printing attributes that implement interface {@link
|
||||
* PrintJobAttribute PrintJobAttribute}. In the Print Service API, a
|
||||
* service uses a PrintJobAttributeSet to report the status of a print job.
|
||||
* <P>
|
||||
* A PrintJobAttributeSet is just an {@link AttributeSet AttributeSet} whose
|
||||
* constructors and mutating operations guarantee an additional invariant,
|
||||
* namely that all attribute values in the PrintJobAttributeSet must be
|
||||
* instances of interface {@link PrintJobAttribute PrintJobAttribute}.
|
||||
* The {@link #add(Attribute) add(Attribute)}, and
|
||||
* {@link #addAll(AttributeSet) >addAll(AttributeSet)} operations
|
||||
* are respecified below to guarantee this additional invariant.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface PrintJobAttributeSet extends AttributeSet {
|
||||
|
||||
/**
|
||||
* Adds the specified attribute value to this attribute set if it is not
|
||||
* already present, first removing any existing value in the same
|
||||
* attribute category as the specified attribute value (optional
|
||||
* operation).
|
||||
*
|
||||
* @param attribute Attribute value to be added to this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call, i.e., the given attribute value was not already a
|
||||
* member of this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not
|
||||
* support the <CODE>add()</CODE> operation.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is
|
||||
* not an instance of interface
|
||||
* {@link PrintJobAttribute PrintJobAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public boolean add(Attribute attribute);
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified set to this attribute.
|
||||
* The outcome is the same as if the
|
||||
* {@link #add(Attribute) add(Attribute)}
|
||||
* operation had been applied to this attribute set successively with
|
||||
* each element from the specified set. If none of the categories in the
|
||||
* specified set are the same as any categories in this attribute set,
|
||||
* the <tt>addAll()</tt> operation effectively modifies this attribute
|
||||
* set so that its value is the <i>union</i> of the two sets.
|
||||
* <P>
|
||||
* The behavior of the <CODE>addAll()</CODE> operation is unspecified if
|
||||
* the specified set is modified while the operation is in progress.
|
||||
* <P>
|
||||
* If the <CODE>addAll()</CODE> operation throws an exception, the effect
|
||||
* on this attribute set's state is implementation dependent; elements
|
||||
* from the specified set before the point of the exception may or
|
||||
* may not have been added to this attribute set.
|
||||
*
|
||||
* @param attributes whose elements are to be added to this attribute
|
||||
* set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (Unchecked exception) Thrown if this attribute set does not
|
||||
* support the <tt>addAll()</tt> method.
|
||||
* @throws ClassCastException
|
||||
* (Unchecked exception) Thrown if some element in the specified
|
||||
* set is not an instance of interface {@link PrintJobAttribute
|
||||
* PrintJobAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (Unchecked exception) Thrown if the specified set is null.
|
||||
*
|
||||
* @see #add(Attribute)
|
||||
*/
|
||||
public boolean addAll(AttributeSet attributes);
|
||||
}
|
||||
51
jdkSrc/jdk8/javax/print/attribute/PrintRequestAttribute.java
Normal file
51
jdkSrc/jdk8/javax/print/attribute/PrintRequestAttribute.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface PrintRequestAttribute is a tagging interface which a printing
|
||||
* attribute class implements to indicate the attribute denotes a
|
||||
* requested setting for a print job.
|
||||
* <p>
|
||||
* Attributes which are tagged with PrintRequestAttribute and are also tagged
|
||||
* as PrintJobAttribute, represent the subset of job attributes which
|
||||
* can be part of the specification of a job request.
|
||||
* <p>
|
||||
* If an attribute implements {@link DocAttribute DocAttribute}
|
||||
* as well as PrintRequestAttribute, the client may include the
|
||||
* attribute in a <code>Doc</code>}'s attribute set to specify
|
||||
* a job setting which pertains just to that doc.
|
||||
* <P>
|
||||
*
|
||||
* @see DocAttributeSet
|
||||
* @see PrintRequestAttributeSet
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
|
||||
public interface PrintRequestAttribute extends Attribute {
|
||||
}
|
||||
111
jdkSrc/jdk8/javax/print/attribute/PrintRequestAttributeSet.java
Normal file
111
jdkSrc/jdk8/javax/print/attribute/PrintRequestAttributeSet.java
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface PrintRequestAttributeSet specifies the interface for a set of
|
||||
* print request attributes, i.e. printing attributes that implement interface
|
||||
* {@link PrintRequestAttribute PrintRequestAttribute}.
|
||||
* The client uses a PrintRequestAttributeSet to specify the settings to be
|
||||
* applied to a whole print job and to all the docs in the print job.
|
||||
* <P>
|
||||
* PrintRequestAttributeSet is just an {@link AttributeSet AttributeSet} whose
|
||||
* constructors and mutating operations guarantee an additional invariant,
|
||||
* namely that all attribute values in the PrintRequestAttributeSet must be
|
||||
* instances of interface {@link PrintRequestAttribute PrintRequestAttribute}.
|
||||
* The {@link #add(Attribute) add(Attribute)}, and
|
||||
* {@link #addAll(AttributeSet) addAll(AttributeSet)} operations
|
||||
* are respecified below to guarantee this additional invariant.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface PrintRequestAttributeSet extends AttributeSet {
|
||||
|
||||
/**
|
||||
* Adds the specified attribute value to this attribute set if it is not
|
||||
* already present, first removing any existing value in the same
|
||||
* attribute category as the specified attribute value (optional
|
||||
* operation).
|
||||
*
|
||||
* @param attribute Attribute value to be added to this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call, i.e., the given attribute value was not already a
|
||||
* member of this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not
|
||||
* support the <CODE>add()</CODE> operation.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is
|
||||
* not an instance of interface
|
||||
* {@link PrintRequestAttribute PrintRequestAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public boolean add(Attribute attribute);
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified set to this attribute.
|
||||
* The outcome is the same as if the
|
||||
* {@link #add(Attribute) add(Attribute)}
|
||||
* operation had been applied to this attribute set successively with
|
||||
* each element from the specified set. If none of the categories in the
|
||||
* specified set are the same as any categories in this attribute set,
|
||||
* the <tt>addAll()</tt> operation effectively modifies this attribute
|
||||
* set so that its value is the <i>union</i> of the two sets.
|
||||
* <P>
|
||||
* The behavior of the <CODE>addAll()</CODE> operation is unspecified if
|
||||
* the specified set is modified while the operation is in progress.
|
||||
* <P>
|
||||
* If the <CODE>addAll()</CODE> operation throws an exception, the effect
|
||||
* on this attribute set's state is implementation dependent; elements
|
||||
* from the specified set before the point of the exception may or
|
||||
* may not have been added to this attribute set.
|
||||
*
|
||||
* @param attributes whose elements are to be added to this attribute
|
||||
* set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (Unchecked exception) Thrown if this attribute set does not
|
||||
* support the <tt>addAll()</tt> method.
|
||||
* @throws ClassCastException
|
||||
* (Unchecked exception) Thrown if some element in the specified
|
||||
* set is not an instance of interface {@link PrintRequestAttribute
|
||||
* PrintRequestAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (Unchecked exception) Thrown if the specified set is null.
|
||||
*
|
||||
* @see #add(Attribute)
|
||||
*/
|
||||
public boolean addAll(AttributeSet attributes);
|
||||
|
||||
}
|
||||
41
jdkSrc/jdk8/javax/print/attribute/PrintServiceAttribute.java
Normal file
41
jdkSrc/jdk8/javax/print/attribute/PrintServiceAttribute.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface PrintServiceAttribute is a tagging interface which a printing
|
||||
* attribute class implements to indicate the attribute describes the status
|
||||
* of a Print Service or some other characteristic of a Print Service. A Print
|
||||
* Service instance adds a number of PrintServiceAttributes to a Print
|
||||
* service's attribute set to report the Print Service's status.
|
||||
* <P>
|
||||
*
|
||||
* @see PrintServiceAttributeSet
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface PrintServiceAttribute extends Attribute {
|
||||
}
|
||||
114
jdkSrc/jdk8/javax/print/attribute/PrintServiceAttributeSet.java
Normal file
114
jdkSrc/jdk8/javax/print/attribute/PrintServiceAttributeSet.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface PrintServiceAttributeSet specifies the interface for a set of
|
||||
* print job attributes, i.e. printing attributes that implement interface
|
||||
* {@link
|
||||
* PrintServiceAttribute PrintServiceAttribute}. In the Print Service API,
|
||||
* the Print Service instance uses a PrintServiceAttributeSet to report the
|
||||
* status of the print service.
|
||||
* <P>
|
||||
* A PrintServiceAttributeSet is just an {@link AttributeSet AttributeSet}
|
||||
* whose constructors and mutating operations guarantee an additional
|
||||
* invariant,
|
||||
* namely that all attribute values in the PrintServiceAttributeSet must be
|
||||
* instances of interface {@link PrintServiceAttribute PrintServiceAttribute}.
|
||||
* The {@link #add(Attribute) add(Attribute)}, and
|
||||
* {@link #addAll(AttributeSet) addAll(AttributeSet)} operations
|
||||
* are respecified below to guarantee this additional invariant.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface PrintServiceAttributeSet extends AttributeSet {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the specified attribute value to this attribute set if it is not
|
||||
* already present, first removing any existing value in the same
|
||||
* attribute category as the specified attribute value (optional
|
||||
* operation).
|
||||
*
|
||||
* @param attribute Attribute value to be added to this attribute set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call, i.e., the given attribute value was not already a
|
||||
* member of this attribute set.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (unchecked exception) Thrown if this attribute set does not
|
||||
* support the <CODE>add()</CODE> operation.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is
|
||||
* not an instance of interface
|
||||
* {@link PrintServiceAttribute PrintServiceAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the <CODE>attribute</CODE> is null.
|
||||
*/
|
||||
public boolean add(Attribute attribute);
|
||||
|
||||
/**
|
||||
* Adds all of the elements in the specified set to this attribute.
|
||||
* The outcome is the same as if the
|
||||
* {@link #add(Attribute) add(Attribute)}
|
||||
* operation had been applied to this attribute set successively with
|
||||
* each element from the specified set. If none of the categories in the
|
||||
* specified set are the same as any categories in this attribute set,
|
||||
* the <tt>addAll()</tt> operation effectively modifies this attribute
|
||||
* set so that its value is the <i>union</i> of the two sets.
|
||||
* <P>
|
||||
* The behavior of the <CODE>addAll()</CODE> operation is unspecified if
|
||||
* the specified set is modified while the operation is in progress.
|
||||
* <P>
|
||||
* If the <CODE>addAll()</CODE> operation throws an exception, the effect
|
||||
* on this attribute set's state is implementation dependent; elements
|
||||
* from the specified set before the point of the exception may or
|
||||
* may not have been added to this attribute set.
|
||||
*
|
||||
* @param attributes whose elements are to be added to this attribute
|
||||
* set.
|
||||
*
|
||||
* @return <tt>true</tt> if this attribute set changed as a result of
|
||||
* the call.
|
||||
*
|
||||
* @throws UnmodifiableSetException
|
||||
* (Unchecked exception) Thrown if this attribute set does not
|
||||
* support the <tt>addAll()</tt> method.
|
||||
* @throws ClassCastException
|
||||
* (Unchecked exception) Thrown if some element in the specified
|
||||
* set is not an instance of interface {@link PrintServiceAttribute
|
||||
* PrintServiceAttribute}.
|
||||
* @throws NullPointerException
|
||||
* (Unchecked exception) Thrown if the specified set is null.
|
||||
*
|
||||
* @see #add(Attribute)
|
||||
*/
|
||||
public boolean addAll(AttributeSet attributes);
|
||||
}
|
||||
358
jdkSrc/jdk8/javax/print/attribute/ResolutionSyntax.java
Normal file
358
jdkSrc/jdk8/javax/print/attribute/ResolutionSyntax.java
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class ResolutionSyntax is an abstract base class providing the common
|
||||
* implementation of all attributes denoting a printer resolution.
|
||||
* <P>
|
||||
* A resolution attribute's value consists of two items, the cross feed
|
||||
* direction resolution and the feed direction resolution. A resolution
|
||||
* attribute may be constructed by supplying the two values and indicating the
|
||||
* units in which the values are measured. Methods are provided to return a
|
||||
* resolution attribute's values, indicating the units in which the values are
|
||||
* to be returned. The two most common resolution units are dots per inch (dpi)
|
||||
* and dots per centimeter (dpcm), and exported constants {@link #DPI
|
||||
* DPI} and {@link #DPCM DPCM} are provided for
|
||||
* indicating those units.
|
||||
* <P>
|
||||
* Once constructed, a resolution attribute's value is immutable.
|
||||
* <P>
|
||||
* <B>Design</B>
|
||||
* <P>
|
||||
* A resolution attribute's cross feed direction resolution and feed direction
|
||||
* resolution values are stored internally using units of dots per 100 inches
|
||||
* (dphi). Storing the values in dphi rather than, say, metric units allows
|
||||
* precise integer arithmetic conversions between dpi and dphi and between dpcm
|
||||
* and dphi: 1 dpi = 100 dphi, 1 dpcm = 254 dphi. Thus, the values can be stored
|
||||
* into and retrieved back from a resolution attribute in either units with no
|
||||
* loss of precision. This would not be guaranteed if a floating point
|
||||
* representation were used. However, roundoff error will in general occur if a
|
||||
* resolution attribute's values are created in one units and retrieved in
|
||||
* different units; for example, 600 dpi will be rounded to 236 dpcm, whereas
|
||||
* the true value (to five figures) is 236.22 dpcm.
|
||||
* <P>
|
||||
* Storing the values internally in common units of dphi lets two resolution
|
||||
* attributes be compared without regard to the units in which they were
|
||||
* created; for example, 300 dpcm will compare equal to 762 dpi, as they both
|
||||
* are stored as 76200 dphi. In particular, a lookup service can
|
||||
* match resolution attributes based on equality of their serialized
|
||||
* representations regardless of the units in which they were created. Again,
|
||||
* using integers for internal storage allows precise equality comparisons to be
|
||||
* done, which would not be guaranteed if a floating point representation were
|
||||
* used.
|
||||
* <P>
|
||||
* The exported constant {@link #DPI DPI} is actually the
|
||||
* conversion factor by which to multiply a value in dpi to get the value in
|
||||
* dphi. Likewise, the exported constant {@link #DPCM DPCM} is the
|
||||
* conversion factor by which to multiply a value in dpcm to get the value in
|
||||
* dphi. A client can specify a resolution value in units other than dpi or dpcm
|
||||
* by supplying its own conversion factor. However, since the internal units of
|
||||
* dphi was chosen with supporting only the external units of dpi and dpcm in
|
||||
* mind, there is no guarantee that the conversion factor for the client's units
|
||||
* will be an exact integer. If the conversion factor isn't an exact integer,
|
||||
* resolution values in the client's units won't be stored precisely.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class ResolutionSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 2706743076526672017L;
|
||||
|
||||
/**
|
||||
* Cross feed direction resolution in units of dots per 100 inches (dphi).
|
||||
* @serial
|
||||
*/
|
||||
private int crossFeedResolution;
|
||||
|
||||
/**
|
||||
* Feed direction resolution in units of dots per 100 inches (dphi).
|
||||
* @serial
|
||||
*/
|
||||
private int feedResolution;
|
||||
|
||||
/**
|
||||
* Value to indicate units of dots per inch (dpi). It is actually the
|
||||
* conversion factor by which to multiply dpi to yield dphi (100).
|
||||
*/
|
||||
public static final int DPI = 100;
|
||||
|
||||
/**
|
||||
* Value to indicate units of dots per centimeter (dpcm). It is actually
|
||||
* the conversion factor by which to multiply dpcm to yield dphi (254).
|
||||
*/
|
||||
public static final int DPCM = 254;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new resolution attribute from the given items.
|
||||
*
|
||||
* @param crossFeedResolution
|
||||
* Cross feed direction resolution.
|
||||
* @param feedResolution
|
||||
* Feed direction resolution.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #DPI DPI} or
|
||||
* {@link #DPCM DPCM}.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code crossFeedResolution < 1}
|
||||
* or {@code feedResolution < 1} or {@code units < 1}.
|
||||
*/
|
||||
public ResolutionSyntax(int crossFeedResolution, int feedResolution,
|
||||
int units) {
|
||||
|
||||
if (crossFeedResolution < 1) {
|
||||
throw new IllegalArgumentException("crossFeedResolution is < 1");
|
||||
}
|
||||
if (feedResolution < 1) {
|
||||
throw new IllegalArgumentException("feedResolution is < 1");
|
||||
}
|
||||
if (units < 1) {
|
||||
throw new IllegalArgumentException("units is < 1");
|
||||
}
|
||||
|
||||
this.crossFeedResolution = crossFeedResolution * units;
|
||||
this.feedResolution = feedResolution * units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a value from dphi to some other units. The result is rounded to
|
||||
* the nearest integer.
|
||||
*
|
||||
* @param dphi
|
||||
* Value (dphi) to convert.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #DPI <CODE>DPI</CODE>} or
|
||||
* {@link #DPCM <CODE>DPCM</CODE>}.
|
||||
*
|
||||
* @return The value of <CODE>dphi</CODE> converted to the desired units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>units</CODE> < 1.
|
||||
*/
|
||||
private static int convertFromDphi(int dphi, int units) {
|
||||
if (units < 1) {
|
||||
throw new IllegalArgumentException(": units is < 1");
|
||||
}
|
||||
int round = units / 2;
|
||||
return (dphi + round) / units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this resolution attribute's resolution values in the given units.
|
||||
* The values are rounded to the nearest integer.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #DPI DPI} or
|
||||
* {@link #DPCM DPCM}.
|
||||
*
|
||||
* @return A two-element array with the cross feed direction resolution
|
||||
* at index 0 and the feed direction resolution at index 1.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public int[] getResolution(int units) {
|
||||
return new int[] { getCrossFeedResolution(units),
|
||||
getFeedResolution(units)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this resolution attribute's cross feed direction resolution in
|
||||
* the given units. The value is rounded to the nearest integer.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #DPI DPI} or
|
||||
* {@link #DPCM DPCM}.
|
||||
*
|
||||
* @return Cross feed direction resolution.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public int getCrossFeedResolution(int units) {
|
||||
return convertFromDphi (crossFeedResolution, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this resolution attribute's feed direction resolution in the
|
||||
* given units. The value is rounded to the nearest integer.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #DPI DPI} or {@link
|
||||
* #DPCM DPCM}.
|
||||
*
|
||||
* @return Feed direction resolution.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public int getFeedResolution(int units) {
|
||||
return convertFromDphi (feedResolution, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string version of this resolution attribute in the given units.
|
||||
* The string takes the form <CODE>"<I>C</I>x<I>F</I> <I>U</I>"</CODE>,
|
||||
* where <I>C</I> is the cross feed direction resolution, <I>F</I> is the
|
||||
* feed direction resolution, and <I>U</I> is the units name. The values are
|
||||
* rounded to the nearest integer.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #DPI CODE>DPI} or {@link
|
||||
* #DPCM DPCM}.
|
||||
* @param unitsName
|
||||
* Units name string, e.g. <CODE>"dpi"</CODE> or <CODE>"dpcm"</CODE>. If
|
||||
* null, no units name is appended to the result.
|
||||
*
|
||||
* @return String version of this resolution attribute.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public String toString(int units, String unitsName) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append(getCrossFeedResolution (units));
|
||||
result.append('x');
|
||||
result.append(getFeedResolution (units));
|
||||
if (unitsName != null) {
|
||||
result.append (' ');
|
||||
result.append (unitsName);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine whether this resolution attribute's value is less than or
|
||||
* equal to the given resolution attribute's value. This is true if all
|
||||
* of the following conditions are true:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* This attribute's cross feed direction resolution is less than or equal to
|
||||
* the <CODE>other</CODE> attribute's cross feed direction resolution.
|
||||
* <LI>
|
||||
* This attribute's feed direction resolution is less than or equal to the
|
||||
* <CODE>other</CODE> attribute's feed direction resolution.
|
||||
* </UL>
|
||||
*
|
||||
* @param other Resolution attribute to compare with.
|
||||
*
|
||||
* @return True if this resolution attribute is less than or equal to the
|
||||
* <CODE>other</CODE> resolution attribute, false otherwise.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>other</CODE> is null.
|
||||
*/
|
||||
public boolean lessThanOrEquals(ResolutionSyntax other) {
|
||||
return (this.crossFeedResolution <= other.crossFeedResolution &&
|
||||
this.feedResolution <= other.feedResolution);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this resolution attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class ResolutionSyntax.
|
||||
* <LI>
|
||||
* This attribute's cross feed direction resolution is equal to
|
||||
* <CODE>object</CODE>'s cross feed direction resolution.
|
||||
* <LI>
|
||||
* This attribute's feed direction resolution is equal to
|
||||
* <CODE>object</CODE>'s feed direction resolution.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this resolution
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
|
||||
return(object != null &&
|
||||
object instanceof ResolutionSyntax &&
|
||||
this.crossFeedResolution ==
|
||||
((ResolutionSyntax) object).crossFeedResolution &&
|
||||
this.feedResolution ==
|
||||
((ResolutionSyntax) object).feedResolution);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this resolution attribute.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return(((crossFeedResolution & 0x0000FFFF)) |
|
||||
((feedResolution & 0x0000FFFF) << 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string version of this resolution attribute. The string takes
|
||||
* the form <CODE>"<I>C</I>x<I>F</I> dphi"</CODE>, where <I>C</I> is the
|
||||
* cross feed direction resolution and <I>F</I> is the feed direction
|
||||
* resolution. The values are reported in the internal units of dphi.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append(crossFeedResolution);
|
||||
result.append('x');
|
||||
result.append(feedResolution);
|
||||
result.append(" dphi");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns this resolution attribute's cross feed direction resolution in
|
||||
* units of dphi. (For use in a subclass.)
|
||||
*
|
||||
* @return Cross feed direction resolution.
|
||||
*/
|
||||
protected int getCrossFeedResolutionDphi() {
|
||||
return crossFeedResolution;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this resolution attribute's feed direction resolution in units
|
||||
* of dphi. (For use in a subclass.)
|
||||
*
|
||||
* @return Feed direction resolution.
|
||||
*/
|
||||
protected int getFeedResolutionDphi() {
|
||||
return feedResolution;
|
||||
}
|
||||
|
||||
}
|
||||
558
jdkSrc/jdk8/javax/print/attribute/SetOfIntegerSyntax.java
Normal file
558
jdkSrc/jdk8/javax/print/attribute/SetOfIntegerSyntax.java
Normal file
@@ -0,0 +1,558 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Class SetOfIntegerSyntax is an abstract base class providing the common
|
||||
* implementation of all attributes whose value is a set of nonnegative
|
||||
* integers. This includes attributes whose value is a single range of integers
|
||||
* and attributes whose value is a set of ranges of integers.
|
||||
* <P>
|
||||
* You can construct an instance of SetOfIntegerSyntax by giving it in "string
|
||||
* form." The string consists of zero or more comma-separated integer groups.
|
||||
* Each integer group consists of either one integer, two integers separated by
|
||||
* a hyphen (<CODE>-</CODE>), or two integers separated by a colon
|
||||
* (<CODE>:</CODE>). Each integer consists of one or more decimal digits
|
||||
* (<CODE>0</CODE> through <CODE>9</CODE>). Whitespace characters cannot
|
||||
* appear within an integer but are otherwise ignored. For example:
|
||||
* <CODE>""</CODE>, <CODE>"1"</CODE>, <CODE>"5-10"</CODE>, <CODE>"1:2,
|
||||
* 4"</CODE>.
|
||||
* <P>
|
||||
* You can also construct an instance of SetOfIntegerSyntax by giving it in
|
||||
* "array form." Array form consists of an array of zero or more integer groups
|
||||
* where each integer group is a length-1 or length-2 array of
|
||||
* <CODE>int</CODE>s; for example, <CODE>int[0][]</CODE>,
|
||||
* <CODE>int[][]{{1}}</CODE>, <CODE>int[][]{{5,10}}</CODE>,
|
||||
* <CODE>int[][]{{1,2},{4}}</CODE>.
|
||||
* <P>
|
||||
* In both string form and array form, each successive integer group gives a
|
||||
* range of integers to be included in the set. The first integer in each group
|
||||
* gives the lower bound of the range; the second integer in each group gives
|
||||
* the upper bound of the range; if there is only one integer in the group, the
|
||||
* upper bound is the same as the lower bound. If the upper bound is less than
|
||||
* the lower bound, it denotes a null range (no values). If the upper bound is
|
||||
* equal to the lower bound, it denotes a range consisting of a single value. If
|
||||
* the upper bound is greater than the lower bound, it denotes a range
|
||||
* consisting of more than one value. The ranges may appear in any order and are
|
||||
* allowed to overlap. The union of all the ranges gives the set's contents.
|
||||
* Once a SetOfIntegerSyntax instance is constructed, its value is immutable.
|
||||
* <P>
|
||||
* The SetOfIntegerSyntax object's value is actually stored in "<I>canonical</I>
|
||||
* array form." This is the same as array form, except there are no null ranges;
|
||||
* the members of the set are represented in as few ranges as possible (i.e.,
|
||||
* overlapping ranges are coalesced); the ranges appear in ascending order; and
|
||||
* each range is always represented as a length-two array of <CODE>int</CODE>s
|
||||
* in the form {lower bound, upper bound}. An empty set is represented as a
|
||||
* zero-length array.
|
||||
* <P>
|
||||
* Class SetOfIntegerSyntax has operations to return the set's members in
|
||||
* canonical array form, to test whether a given integer is a member of the
|
||||
* set, and to iterate through the members of the set.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class SetOfIntegerSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 3666874174847632203L;
|
||||
|
||||
/**
|
||||
* This set's members in canonical array form.
|
||||
* @serial
|
||||
*/
|
||||
private int[][] members;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new set-of-integer attribute with the given members in
|
||||
* string form.
|
||||
*
|
||||
* @param members Set members in string form. If null, an empty set is
|
||||
* constructed.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>members</CODE> does not
|
||||
* obey the proper syntax.
|
||||
*/
|
||||
protected SetOfIntegerSyntax(String members) {
|
||||
this.members = parse (members);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given string, returning canonical array form.
|
||||
*/
|
||||
private static int[][] parse(String members) {
|
||||
// Create vector to hold int[] elements, each element being one range
|
||||
// parsed out of members.
|
||||
Vector theRanges = new Vector();
|
||||
|
||||
// Run state machine over members.
|
||||
int n = (members == null ? 0 : members.length());
|
||||
int i = 0;
|
||||
int state = 0;
|
||||
int lb = 0;
|
||||
int ub = 0;
|
||||
char c;
|
||||
int digit;
|
||||
while (i < n) {
|
||||
c = members.charAt(i ++);
|
||||
switch (state) {
|
||||
|
||||
case 0: // Before first integer in first group
|
||||
if (Character.isWhitespace(c)) {
|
||||
state = 0;
|
||||
}
|
||||
else if ((digit = Character.digit(c, 10)) != -1) {
|
||||
lb = digit;
|
||||
state = 1;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // In first integer in a group
|
||||
if (Character.isWhitespace(c)){
|
||||
state = 2;
|
||||
} else if ((digit = Character.digit(c, 10)) != -1) {
|
||||
lb = 10 * lb + digit;
|
||||
state = 1;
|
||||
} else if (c == '-' || c == ':') {
|
||||
state = 3;
|
||||
} else if (c == ',') {
|
||||
accumulate (theRanges, lb, lb);
|
||||
state = 6;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // After first integer in a group
|
||||
if (Character.isWhitespace(c)) {
|
||||
state = 2;
|
||||
}
|
||||
else if (c == '-' || c == ':') {
|
||||
state = 3;
|
||||
}
|
||||
else if (c == ',') {
|
||||
accumulate(theRanges, lb, lb);
|
||||
state = 6;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: // Before second integer in a group
|
||||
if (Character.isWhitespace(c)) {
|
||||
state = 3;
|
||||
} else if ((digit = Character.digit(c, 10)) != -1) {
|
||||
ub = digit;
|
||||
state = 4;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
|
||||
case 4: // In second integer in a group
|
||||
if (Character.isWhitespace(c)) {
|
||||
state = 5;
|
||||
} else if ((digit = Character.digit(c, 10)) != -1) {
|
||||
ub = 10 * ub + digit;
|
||||
state = 4;
|
||||
} else if (c == ',') {
|
||||
accumulate(theRanges, lb, ub);
|
||||
state = 6;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
|
||||
case 5: // After second integer in a group
|
||||
if (Character.isWhitespace(c)) {
|
||||
state = 5;
|
||||
} else if (c == ',') {
|
||||
accumulate(theRanges, lb, ub);
|
||||
state = 6;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: // Before first integer in second or later group
|
||||
if (Character.isWhitespace(c)) {
|
||||
state = 6;
|
||||
} else if ((digit = Character.digit(c, 10)) != -1) {
|
||||
lb = digit;
|
||||
state = 1;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Finish off the state machine.
|
||||
switch (state) {
|
||||
case 0: // Before first integer in first group
|
||||
break;
|
||||
case 1: // In first integer in a group
|
||||
case 2: // After first integer in a group
|
||||
accumulate(theRanges, lb, lb);
|
||||
break;
|
||||
case 4: // In second integer in a group
|
||||
case 5: // After second integer in a group
|
||||
accumulate(theRanges, lb, ub);
|
||||
break;
|
||||
case 3: // Before second integer in a group
|
||||
case 6: // Before first integer in second or later group
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
// Return canonical array form.
|
||||
return canonicalArrayForm (theRanges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accumulate the given range (lb .. ub) into the canonical array form
|
||||
* into the given vector of int[] objects.
|
||||
*/
|
||||
private static void accumulate(Vector ranges, int lb,int ub) {
|
||||
// Make sure range is non-null.
|
||||
if (lb <= ub) {
|
||||
// Stick range at the back of the vector.
|
||||
ranges.add(new int[] {lb, ub});
|
||||
|
||||
// Work towards the front of the vector to integrate the new range
|
||||
// with the existing ranges.
|
||||
for (int j = ranges.size()-2; j >= 0; -- j) {
|
||||
// Get lower and upper bounds of the two ranges being compared.
|
||||
int[] rangea = (int[]) ranges.elementAt (j);
|
||||
int lba = rangea[0];
|
||||
int uba = rangea[1];
|
||||
int[] rangeb = (int[]) ranges.elementAt (j+1);
|
||||
int lbb = rangeb[0];
|
||||
int ubb = rangeb[1];
|
||||
|
||||
/* If the two ranges overlap or are adjacent, coalesce them.
|
||||
* The two ranges overlap if the larger lower bound is less
|
||||
* than or equal to the smaller upper bound. The two ranges
|
||||
* are adjacent if the larger lower bound is one greater
|
||||
* than the smaller upper bound.
|
||||
*/
|
||||
if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) {
|
||||
// The coalesced range is from the smaller lower bound to
|
||||
// the larger upper bound.
|
||||
ranges.setElementAt(new int[]
|
||||
{Math.min(lba, lbb),
|
||||
Math.max(uba, ubb)}, j);
|
||||
ranges.remove (j+1);
|
||||
} else if (lba > lbb) {
|
||||
|
||||
/* If the two ranges don't overlap and aren't adjacent but
|
||||
* are out of order, swap them.
|
||||
*/
|
||||
ranges.setElementAt (rangeb, j);
|
||||
ranges.setElementAt (rangea, j+1);
|
||||
} else {
|
||||
/* If the two ranges don't overlap and aren't adjacent and
|
||||
* aren't out of order, we're done early.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given vector of int[] objects to canonical array form.
|
||||
*/
|
||||
private static int[][] canonicalArrayForm(Vector ranges) {
|
||||
return (int[][]) ranges.toArray (new int[ranges.size()][]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new set-of-integer attribute with the given members in
|
||||
* array form.
|
||||
*
|
||||
* @param members Set members in array form. If null, an empty set is
|
||||
* constructed.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (Unchecked exception) Thrown if any element of
|
||||
* <CODE>members</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if any element of
|
||||
* <CODE>members</CODE> is not a length-one or length-two array or if
|
||||
* any non-null range in <CODE>members</CODE> has a lower bound less
|
||||
* than zero.
|
||||
*/
|
||||
protected SetOfIntegerSyntax(int[][] members) {
|
||||
this.members = parse (members);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given array form, returning canonical array form.
|
||||
*/
|
||||
private static int[][] parse(int[][] members) {
|
||||
// Create vector to hold int[] elements, each element being one range
|
||||
// parsed out of members.
|
||||
Vector ranges = new Vector();
|
||||
|
||||
// Process all integer groups in members.
|
||||
int n = (members == null ? 0 : members.length);
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
// Get lower and upper bounds of the range.
|
||||
int lb, ub;
|
||||
if (members[i].length == 1) {
|
||||
lb = ub = members[i][0];
|
||||
} else if (members[i].length == 2) {
|
||||
lb = members[i][0];
|
||||
ub = members[i][1];
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
// Verify valid bounds.
|
||||
if (lb <= ub && lb < 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
// Accumulate the range.
|
||||
accumulate(ranges, lb, ub);
|
||||
}
|
||||
|
||||
// Return canonical array form.
|
||||
return canonicalArrayForm (ranges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new set-of-integer attribute containing a single integer.
|
||||
*
|
||||
* @param member Set member.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>member</CODE> is less than
|
||||
* zero.
|
||||
*/
|
||||
protected SetOfIntegerSyntax(int member) {
|
||||
if (member < 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
members = new int[][] {{member, member}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new set-of-integer attribute containing a single range of
|
||||
* integers. If the lower bound is greater than the upper bound (a null
|
||||
* range), an empty set is constructed.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if the range is non-null and
|
||||
* <CODE>lowerBound</CODE> is less than zero.
|
||||
*/
|
||||
protected SetOfIntegerSyntax(int lowerBound, int upperBound) {
|
||||
if (lowerBound <= upperBound && lowerBound < 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
members = lowerBound <=upperBound ?
|
||||
new int[][] {{lowerBound, upperBound}} :
|
||||
new int[0][];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain this set-of-integer attribute's members in canonical array form.
|
||||
* The returned array is "safe;" the client may alter it without affecting
|
||||
* this set-of-integer attribute.
|
||||
*
|
||||
* @return This set-of-integer attribute's members in canonical array form.
|
||||
*/
|
||||
public int[][] getMembers() {
|
||||
int n = members.length;
|
||||
int[][] result = new int[n][];
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
result[i] = new int[] {members[i][0], members[i][1]};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this set-of-integer attribute contains the given value.
|
||||
*
|
||||
* @param x Integer value.
|
||||
*
|
||||
* @return True if this set-of-integer attribute contains the value
|
||||
* <CODE>x</CODE>, false otherwise.
|
||||
*/
|
||||
public boolean contains(int x) {
|
||||
// Do a linear search to find the range that contains x, if any.
|
||||
int n = members.length;
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
if (x < members[i][0]) {
|
||||
return false;
|
||||
} else if (x <= members[i][1]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this set-of-integer attribute contains the given integer
|
||||
* attribute's value.
|
||||
*
|
||||
* @param attribute Integer attribute.
|
||||
*
|
||||
* @return True if this set-of-integer attribute contains
|
||||
* <CODE>theAttribute</CODE>'s value, false otherwise.
|
||||
*/
|
||||
public boolean contains(IntegerSyntax attribute) {
|
||||
return contains (attribute.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the smallest integer in this set-of-integer attribute that is
|
||||
* greater than the given value. If there are no integers in this
|
||||
* set-of-integer attribute greater than the given value, <CODE>-1</CODE> is
|
||||
* returned. (Since a set-of-integer attribute can only contain nonnegative
|
||||
* values, <CODE>-1</CODE> will never appear in the set.) You can use the
|
||||
* <CODE>next()</CODE> method to iterate through the integer values in a
|
||||
* set-of-integer attribute in ascending order, like this:
|
||||
* <PRE>
|
||||
* SetOfIntegerSyntax attribute = . . .;
|
||||
* int i = -1;
|
||||
* while ((i = attribute.next (i)) != -1)
|
||||
* {
|
||||
* foo (i);
|
||||
* }
|
||||
* </PRE>
|
||||
*
|
||||
* @param x Integer value.
|
||||
*
|
||||
* @return The smallest integer in this set-of-integer attribute that is
|
||||
* greater than <CODE>x</CODE>, or <CODE>-1</CODE> if no integer in
|
||||
* this set-of-integer attribute is greater than <CODE>x</CODE>.
|
||||
*/
|
||||
public int next(int x) {
|
||||
// Do a linear search to find the range that contains x, if any.
|
||||
int n = members.length;
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
if (x < members[i][0]) {
|
||||
return members[i][0];
|
||||
} else if (x < members[i][1]) {
|
||||
return x + 1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this set-of-integer attribute is equivalent to the passed
|
||||
* in object. To be equivalent, all of the following conditions must be
|
||||
* true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class SetOfIntegerSyntax.
|
||||
* <LI>
|
||||
* This set-of-integer attribute's members and <CODE>object</CODE>'s
|
||||
* members are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this
|
||||
* set-of-integer attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
if (object != null && object instanceof SetOfIntegerSyntax) {
|
||||
int[][] myMembers = this.members;
|
||||
int[][] otherMembers = ((SetOfIntegerSyntax) object).members;
|
||||
int m = myMembers.length;
|
||||
int n = otherMembers.length;
|
||||
if (m == n) {
|
||||
for (int i = 0; i < m; ++ i) {
|
||||
if (myMembers[i][0] != otherMembers[i][0] ||
|
||||
myMembers[i][1] != otherMembers[i][1]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this set-of-integer attribute. The hash
|
||||
* code is the sum of the lower and upper bounds of the ranges in the
|
||||
* canonical array form, or 0 for an empty set.
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
int n = members.length;
|
||||
for (int i = 0; i < n; ++ i) {
|
||||
result += members[i][0] + members[i][1];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string value corresponding to this set-of-integer attribute.
|
||||
* The string value is a zero-length string if this set is empty. Otherwise,
|
||||
* the string value is a comma-separated list of the ranges in the canonical
|
||||
* array form, where each range is represented as <CODE>"<I>i</I>"</CODE> if
|
||||
* the lower bound equals the upper bound or
|
||||
* <CODE>"<I>i</I>-<I>j</I>"</CODE> otherwise.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
int n = members.length;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) {
|
||||
result.append (',');
|
||||
}
|
||||
result.append (members[i][0]);
|
||||
if (members[i][0] != members[i][1]) {
|
||||
result.append ('-');
|
||||
result.append (members[i][1]);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
343
jdkSrc/jdk8/javax/print/attribute/Size2DSyntax.java
Normal file
343
jdkSrc/jdk8/javax/print/attribute/Size2DSyntax.java
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Class Size2DSyntax is an abstract base class providing the common
|
||||
* implementation of all attributes denoting a size in two dimensions.
|
||||
* <P>
|
||||
* A two-dimensional size attribute's value consists of two items, the X
|
||||
* dimension and the Y dimension. A two-dimensional size attribute may be
|
||||
* constructed by supplying the two values and indicating the units in which the
|
||||
* values are measured. Methods are provided to return a two-dimensional size
|
||||
* attribute's values, indicating the units in which the values are to be
|
||||
* returned. The two most common size units are inches (in) and millimeters
|
||||
* (mm), and exported constants {@link #INCH INCH} and {@link #MM
|
||||
* MM} are provided for indicating those units.
|
||||
* <P>
|
||||
* Once constructed, a two-dimensional size attribute's value is immutable.
|
||||
* <P>
|
||||
* <B>Design</B>
|
||||
* <P>
|
||||
* A two-dimensional size attribute's X and Y dimension values are stored
|
||||
* internally as integers in units of micrometers (µm), where 1 micrometer
|
||||
* = 10<SUP>-6</SUP> meter = 1/1000 millimeter = 1/25400 inch. This permits
|
||||
* dimensions to be represented exactly to a precision of 1/1000 mm (= 1
|
||||
* µm) or 1/100 inch (= 254 µm). If fractional inches are expressed in
|
||||
* negative powers of two, this permits dimensions to be represented exactly to
|
||||
* a precision of 1/8 inch (= 3175 µm) but not 1/16 inch (because 1/16 inch
|
||||
* does not equal an integral number of µm).
|
||||
* <P>
|
||||
* Storing the dimensions internally in common units of µm lets two size
|
||||
* attributes be compared without regard to the units in which they were
|
||||
* created; for example, 8.5 in will compare equal to 215.9 mm, as they both are
|
||||
* stored as 215900 µm. For example, a lookup service can
|
||||
* match resolution attributes based on equality of their serialized
|
||||
* representations regardless of the units in which they were created. Using
|
||||
* integers for internal storage allows precise equality comparisons to be done,
|
||||
* which would not be guaranteed if an internal floating point representation
|
||||
* were used. Note that if you're looking for U.S. letter sized media in metric
|
||||
* units, you have to search for a media size of 215.9 x 279.4 mm; rounding off
|
||||
* to an integral 216 x 279 mm will not match.
|
||||
* <P>
|
||||
* The exported constant {@link #INCH INCH} is actually the
|
||||
* conversion factor by which to multiply a value in inches to get the value in
|
||||
* µm. Likewise, the exported constant {@link #MM MM} is the
|
||||
* conversion factor by which to multiply a value in mm to get the value in
|
||||
* µm. A client can specify a resolution value in units other than inches
|
||||
* or mm by supplying its own conversion factor. However, since the internal
|
||||
* units of µm was chosen with supporting only the external units of inch
|
||||
* and mm in mind, there is no guarantee that the conversion factor for the
|
||||
* client's units will be an exact integer. If the conversion factor isn't an
|
||||
* exact integer, resolution values in the client's units won't be stored
|
||||
* precisely.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class Size2DSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 5584439964938660530L;
|
||||
|
||||
/**
|
||||
* X dimension in units of micrometers (µm).
|
||||
* @serial
|
||||
*/
|
||||
private int x;
|
||||
|
||||
/**
|
||||
* Y dimension in units of micrometers (µm).
|
||||
* @serial
|
||||
*/
|
||||
private int y;
|
||||
|
||||
/**
|
||||
* Value to indicate units of inches (in). It is actually the conversion
|
||||
* factor by which to multiply inches to yield µm (25400).
|
||||
*/
|
||||
public static final int INCH = 25400;
|
||||
|
||||
/**
|
||||
* Value to indicate units of millimeters (mm). It is actually the
|
||||
* conversion factor by which to multiply mm to yield µm (1000).
|
||||
*/
|
||||
public static final int MM = 1000;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new two-dimensional size attribute from the given
|
||||
* floating-point values.
|
||||
*
|
||||
* @param x X dimension.
|
||||
* @param y Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
|
||||
* {@code units < 1}.
|
||||
*/
|
||||
protected Size2DSyntax(float x, float y, int units) {
|
||||
if (x < 0.0f) {
|
||||
throw new IllegalArgumentException("x < 0");
|
||||
}
|
||||
if (y < 0.0f) {
|
||||
throw new IllegalArgumentException("y < 0");
|
||||
}
|
||||
if (units < 1) {
|
||||
throw new IllegalArgumentException("units < 1");
|
||||
}
|
||||
this.x = (int) (x * units + 0.5f);
|
||||
this.y = (int) (y * units + 0.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new two-dimensional size attribute from the given integer
|
||||
* values.
|
||||
*
|
||||
* @param x X dimension.
|
||||
* @param y Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0}
|
||||
* or {@code units < 1}.
|
||||
*/
|
||||
protected Size2DSyntax(int x, int y, int units) {
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("x < 0");
|
||||
}
|
||||
if (y < 0) {
|
||||
throw new IllegalArgumentException("y < 0");
|
||||
}
|
||||
if (units < 1) {
|
||||
throw new IllegalArgumentException("units < 1");
|
||||
}
|
||||
this.x = x * units;
|
||||
this.y = y * units;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a value from micrometers to some other units. The result is
|
||||
* returned as a floating-point number.
|
||||
*
|
||||
* @param x
|
||||
* Value (micrometers) to convert.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH <CODE>INCH</CODE>} or
|
||||
* {@link #MM <CODE>MM</CODE>}.
|
||||
*
|
||||
* @return The value of <CODE>x</CODE> converted to the desired units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if <CODE>units</CODE> < 1.
|
||||
*/
|
||||
private static float convertFromMicrometers(int x, int units) {
|
||||
if (units < 1) {
|
||||
throw new IllegalArgumentException("units is < 1");
|
||||
}
|
||||
return ((float)x) / ((float)units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this two-dimensional size attribute's dimensions in the given units
|
||||
* as floating-point values.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}.
|
||||
*
|
||||
* @return A two-element array with the X dimension at index 0 and the Y
|
||||
* dimension at index 1.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float[] getSize(int units) {
|
||||
return new float[] {getX(units), getY(units)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this two-dimensional size attribute's X dimension in the given
|
||||
* units as a floating-point value.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}.
|
||||
*
|
||||
* @return X dimension.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float getX(int units) {
|
||||
return convertFromMicrometers(x, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this two-dimensional size attribute's Y dimension in the given
|
||||
* units as a floating-point value.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}.
|
||||
*
|
||||
* @return Y dimension.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float getY(int units) {
|
||||
return convertFromMicrometers(y, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string version of this two-dimensional size attribute in the
|
||||
* given units. The string takes the form <CODE>"<I>X</I>x<I>Y</I>
|
||||
* <I>U</I>"</CODE>, where <I>X</I> is the X dimension, <I>Y</I> is the Y
|
||||
* dimension, and <I>U</I> is the units name. The values are displayed in
|
||||
* floating point.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}.
|
||||
*
|
||||
* @param unitsName
|
||||
* Units name string, e.g. {@code in} or {@code mm}. If
|
||||
* null, no units name is appended to the result.
|
||||
*
|
||||
* @return String version of this two-dimensional size attribute.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public String toString(int units, String unitsName) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append(getX (units));
|
||||
result.append('x');
|
||||
result.append(getY (units));
|
||||
if (unitsName != null) {
|
||||
result.append(' ');
|
||||
result.append(unitsName);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this two-dimensional size attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions must
|
||||
* be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class Size2DSyntax.
|
||||
* <LI>
|
||||
* This attribute's X dimension is equal to <CODE>object</CODE>'s X
|
||||
* dimension.
|
||||
* <LI>
|
||||
* This attribute's Y dimension is equal to <CODE>object</CODE>'s Y
|
||||
* dimension.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this
|
||||
* two-dimensional size attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null &&
|
||||
object instanceof Size2DSyntax &&
|
||||
this.x == ((Size2DSyntax) object).x &&
|
||||
this.y == ((Size2DSyntax) object).y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this two-dimensional size attribute.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return (((x & 0x0000FFFF) ) |
|
||||
((y & 0x0000FFFF) << 16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string version of this two-dimensional size attribute. The
|
||||
* string takes the form <CODE>"<I>X</I>x<I>Y</I> um"</CODE>, where
|
||||
* <I>X</I> is the X dimension and <I>Y</I> is the Y dimension.
|
||||
* The values are reported in the internal units of micrometers.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer();
|
||||
result.append(x);
|
||||
result.append('x');
|
||||
result.append(y);
|
||||
result.append(" um");
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this two-dimensional size attribute's X dimension in units of
|
||||
* micrometers (µm). (For use in a subclass.)
|
||||
*
|
||||
* @return X dimension (µm).
|
||||
*/
|
||||
protected int getXMicrometers(){
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this two-dimensional size attribute's Y dimension in units of
|
||||
* micrometers (µm). (For use in a subclass.)
|
||||
*
|
||||
* @return Y dimension (µm).
|
||||
*/
|
||||
protected int getYMicrometers() {
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Interface SupportedValuesAttribute is a tagging interface which a printing
|
||||
* attribute class implements to indicate the attribute describes the supported
|
||||
* values for another attribute. For example, if a Print Service instance
|
||||
* supports the {@link javax.print.attribute.standard.Copies Copies}
|
||||
* attribute, the Print Service instance will have a {@link
|
||||
* javax.print.attribute.standard.CopiesSupported CopiesSupported} attribute,
|
||||
* which is a SupportedValuesAttribute giving the legal values a client may
|
||||
* specify for the {@link javax.print.attribute.standard.Copies Copies}
|
||||
* attribute.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public interface SupportedValuesAttribute extends Attribute {
|
||||
}
|
||||
152
jdkSrc/jdk8/javax/print/attribute/TextSyntax.java
Normal file
152
jdkSrc/jdk8/javax/print/attribute/TextSyntax.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Class TextSyntax is an abstract base class providing the common
|
||||
* implementation of all attributes whose value is a string. The text attribute
|
||||
* includes a locale to indicate the natural language. Thus, a text attribute
|
||||
* always represents a localized string. Once constructed, a text attribute's
|
||||
* value is immutable.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class TextSyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -8130648736378144102L;
|
||||
|
||||
/**
|
||||
* String value of this text attribute.
|
||||
* @serial
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Locale of this text attribute.
|
||||
* @serial
|
||||
*/
|
||||
private Locale locale;
|
||||
|
||||
/**
|
||||
* Constructs a TextAttribute with the specified string and locale.
|
||||
*
|
||||
* @param value Text string.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale for as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>value</CODE> is null.
|
||||
*/
|
||||
protected TextSyntax(String value, Locale locale) {
|
||||
this.value = verify (value);
|
||||
this.locale = verify (locale);
|
||||
}
|
||||
|
||||
private static String verify(String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException(" value is null");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static Locale verify(Locale locale) {
|
||||
if (locale == null) {
|
||||
return Locale.getDefault();
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this text attribute's text string.
|
||||
* @return the text string.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this text attribute's text string's natural language (locale).
|
||||
* @return the locale
|
||||
*/
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this text attribute.
|
||||
*
|
||||
* @return A hashcode value for this object.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return value.hashCode() ^ locale.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this text attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class TextSyntax.
|
||||
* <LI>
|
||||
* This text attribute's underlying string and <CODE>object</CODE>'s
|
||||
* underlying string are equal.
|
||||
* <LI>
|
||||
* This text attribute's locale and <CODE>object</CODE>'s locale are
|
||||
* equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this text
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null &&
|
||||
object instanceof TextSyntax &&
|
||||
this.value.equals (((TextSyntax) object).value) &&
|
||||
this.locale.equals (((TextSyntax) object).locale));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String identifying this text attribute. The String is
|
||||
* the attribute's underlying text string.
|
||||
*
|
||||
* @return A String identifying this object.
|
||||
*/
|
||||
public String toString(){
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
121
jdkSrc/jdk8/javax/print/attribute/URISyntax.java
Normal file
121
jdkSrc/jdk8/javax/print/attribute/URISyntax.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Class URISyntax is an abstract base class providing the common
|
||||
* implementation of all attributes whose value is a Uniform Resource
|
||||
* Identifier (URI). Once constructed, a URI attribute's value is immutable.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public abstract class URISyntax implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = -7842661210486401678L;
|
||||
|
||||
/**
|
||||
* URI value of this URI attribute.
|
||||
* @serial
|
||||
*/
|
||||
private URI uri;
|
||||
|
||||
/**
|
||||
* Constructs a URI attribute with the specified URI.
|
||||
*
|
||||
* @param uri URI.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>uri</CODE> is null.
|
||||
*/
|
||||
protected URISyntax(URI uri) {
|
||||
this.uri = verify (uri);
|
||||
}
|
||||
|
||||
private static URI verify(URI uri) {
|
||||
if (uri == null) {
|
||||
throw new NullPointerException(" uri is null");
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this URI attribute's URI value.
|
||||
* @return the URI.
|
||||
*/
|
||||
public URI getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hashcode for this URI attribute.
|
||||
*
|
||||
* @return A hashcode value for this object.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return uri.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this URI attribute is equivalent to the passed in
|
||||
* object.
|
||||
* To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class URISyntax.
|
||||
* <LI>
|
||||
* This URI attribute's underlying URI and <CODE>object</CODE>'s
|
||||
* underlying URI are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this URI
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null &&
|
||||
object instanceof URISyntax &&
|
||||
this.uri.equals (((URISyntax) object).uri));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a String identifying this URI attribute. The String is the
|
||||
* string representation of the attribute's underlying URI.
|
||||
*
|
||||
* @return A String identifying this object.
|
||||
*/
|
||||
public String toString() {
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute;
|
||||
|
||||
/**
|
||||
* Thrown to indicate that the requested operation cannot be performed
|
||||
* because the set is unmodifiable.
|
||||
*
|
||||
* @author Phil Race
|
||||
* @since 1.4
|
||||
*/
|
||||
public class UnmodifiableSetException extends RuntimeException {
|
||||
/**
|
||||
* Constructs an UnsupportedOperationException with no detail message.
|
||||
*/
|
||||
public UnmodifiableSetException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an UnmodifiableSetException with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public UnmodifiableSetException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
159
jdkSrc/jdk8/javax/print/attribute/standard/Chromaticity.java
Normal file
159
jdkSrc/jdk8/javax/print/attribute/standard/Chromaticity.java
Normal file
@@ -0,0 +1,159 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class Chromaticity is a printing attribute class, an enumeration, that
|
||||
* specifies monochrome or color printing. This is used by a print client
|
||||
* to specify how the print data should be generated or processed. It is not
|
||||
* descriptive of the color capabilities of the device. Query the service's
|
||||
* {@link ColorSupported ColorSupported} attribute to determine if the device
|
||||
* can be verified to support color printing.
|
||||
* <P>
|
||||
* The table below shows the effects of specifying a Chromaticity attribute of
|
||||
* {@link #MONOCHROME MONOCHROME} or {@link #COLOR COLOR}
|
||||
* for a monochrome or color document.
|
||||
* <P>
|
||||
* <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=1 SUMMARY="Shows effects of specifying MONOCHROME or COLOR Chromaticity attributes">
|
||||
* <TR>
|
||||
* <TH>
|
||||
* Chromaticity<BR>Attribute
|
||||
* </TH>
|
||||
* <TH>
|
||||
* Effect on<BR>Monochrome Document
|
||||
* </TH>
|
||||
* <TH>
|
||||
* Effect on<BR>Color Document
|
||||
* </TH>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>
|
||||
* {@link #MONOCHROME MONOCHROME}
|
||||
* </TD>
|
||||
* <TD>
|
||||
* Printed as is, in monochrome
|
||||
* </TD>
|
||||
* <TD>
|
||||
* Printed in monochrome, with colors converted to shades of gray
|
||||
* </TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>
|
||||
* {@link #COLOR COLOR}
|
||||
* </TD>
|
||||
* <TD>
|
||||
* Printed as is, in monochrome
|
||||
* </TD>
|
||||
* <TD>
|
||||
* Printed as is, in color
|
||||
* </TD>
|
||||
* </TR>
|
||||
* </TABLE>
|
||||
* <P>
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> Chromaticity is not an IPP attribute at present.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class Chromaticity extends EnumSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 4660543931355214012L;
|
||||
|
||||
/**
|
||||
* Monochrome printing.
|
||||
*/
|
||||
public static final Chromaticity MONOCHROME = new Chromaticity(0);
|
||||
|
||||
/**
|
||||
* Color printing.
|
||||
*/
|
||||
public static final Chromaticity COLOR = new Chromaticity(1);
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new chromaticity enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected Chromaticity(int value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {"monochrome",
|
||||
"color"};
|
||||
|
||||
private static final Chromaticity[] myEnumValueTable = {MONOCHROME,
|
||||
COLOR};
|
||||
|
||||
/**
|
||||
* Returns the string table for class Chromaticity.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class Chromaticity.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Chromaticity, the category is the class Chromaticity itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Chromaticity.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Chromaticity, the category name is <CODE>"chromaticity"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "chromaticity";
|
||||
}
|
||||
|
||||
}
|
||||
130
jdkSrc/jdk8/javax/print/attribute/standard/ColorSupported.java
Normal file
130
jdkSrc/jdk8/javax/print/attribute/standard/ColorSupported.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class ColorSupported is a printing attribute class, an enumeration, that
|
||||
* identifies whether the device is capable of any type of color printing at
|
||||
* all, including highlight color as well as full process color. All document
|
||||
* instructions having to do with color are embedded within the print data (none
|
||||
* are attributes attached to the job outside the print data).
|
||||
* <P>
|
||||
* Note: End users are able to determine the nature and details of the color
|
||||
* support by querying the {@link PrinterMoreInfoManufacturer
|
||||
* PrinterMoreInfoManufacturer} attribute.
|
||||
* <P>
|
||||
* Don't confuse the ColorSupported attribute with the {@link Chromaticity
|
||||
* Chromaticity} attribute. {@link Chromaticity Chromaticity} is an attribute
|
||||
* the client can specify for a job to tell the printer whether to print a
|
||||
* document in monochrome or color, possibly causing the printer to print a
|
||||
* color document in monochrome. ColorSupported is a printer description
|
||||
* attribute that tells whether the printer can print in color regardless of how
|
||||
* the client specifies to print any particular document.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The IPP boolean value is "true" for SUPPORTED and
|
||||
* "false" for NOT_SUPPORTED. The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class ColorSupported extends EnumSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = -2700555589688535545L;
|
||||
|
||||
/**
|
||||
* The printer is not capable of any type of color printing.
|
||||
*/
|
||||
public static final ColorSupported NOT_SUPPORTED = new ColorSupported(0);
|
||||
|
||||
/**
|
||||
* The printer is capable of some type of color printing, such as
|
||||
* highlight color or full process color.
|
||||
*/
|
||||
public static final ColorSupported SUPPORTED = new ColorSupported(1);
|
||||
|
||||
/**
|
||||
* Construct a new color supported enumeration value with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected ColorSupported(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {"not-supported",
|
||||
"supported"};
|
||||
|
||||
private static final ColorSupported[] myEnumValueTable = {NOT_SUPPORTED,
|
||||
SUPPORTED};
|
||||
|
||||
/**
|
||||
* Returns the string table for class ColorSupported.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class ColorSupported.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class ColorSupported, the category is class ColorSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return ColorSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class ColorSupported, the category name is <CODE>"color-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "color-supported";
|
||||
}
|
||||
|
||||
}
|
||||
134
jdkSrc/jdk8/javax/print/attribute/standard/Compression.java
Normal file
134
jdkSrc/jdk8/javax/print/attribute/standard/Compression.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
|
||||
/**
|
||||
* Class Compression is a printing attribute class, an enumeration, that
|
||||
* specifies how print data is compressed. Compression is an attribute of the
|
||||
* print data (the doc), not of the Print Job. If a Compression attribute is not
|
||||
* specified for a doc, the printer assumes the doc's print data is uncompressed
|
||||
* (i.e., the default Compression value is always {@link #NONE
|
||||
* NONE}).
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class Compression extends EnumSyntax implements DocAttribute {
|
||||
|
||||
private static final long serialVersionUID = -5716748913324997674L;
|
||||
|
||||
/**
|
||||
* No compression is used.
|
||||
*/
|
||||
public static final Compression NONE = new Compression(0);
|
||||
|
||||
/**
|
||||
* ZIP public domain inflate/deflate compression technology.
|
||||
*/
|
||||
public static final Compression DEFLATE = new Compression(1);
|
||||
|
||||
/**
|
||||
* GNU zip compression technology described in
|
||||
* <A HREF="http://www.ietf.org/rfc/rfc1952.txt">RFC 1952</A>.
|
||||
*/
|
||||
public static final Compression GZIP = new Compression(2);
|
||||
|
||||
/**
|
||||
* UNIX compression technology.
|
||||
*/
|
||||
public static final Compression COMPRESS = new Compression(3);
|
||||
|
||||
/**
|
||||
* Construct a new compression enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected Compression(int value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
|
||||
private static final String[] myStringTable = {"none",
|
||||
"deflate",
|
||||
"gzip",
|
||||
"compress"};
|
||||
|
||||
private static final Compression[] myEnumValueTable = {NONE,
|
||||
DEFLATE,
|
||||
GZIP,
|
||||
COMPRESS};
|
||||
|
||||
/**
|
||||
* Returns the string table for class Compression.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class Compression.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Compression and any vendor-defined subclasses, the category is
|
||||
* class Compression itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Compression.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Compression and any vendor-defined subclasses, the category
|
||||
* name is <CODE>"compression"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "compression";
|
||||
}
|
||||
|
||||
}
|
||||
136
jdkSrc/jdk8/javax/print/attribute/standard/Copies.java
Normal file
136
jdkSrc/jdk8/javax/print/attribute/standard/Copies.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class Copies is an integer valued printing attribute class that specifies the
|
||||
* number of copies to be printed.
|
||||
* <P>
|
||||
* On many devices the supported number of collated copies will be limited by
|
||||
* the number of physical output bins on the device, and may be different from
|
||||
* the number of uncollated copies which can be supported.
|
||||
* <P>
|
||||
* The effect of a Copies attribute with a value of <I>n</I> on a multidoc print
|
||||
* job (a job with multiple documents) depends on the (perhaps defaulted) value
|
||||
* of the {@link MultipleDocumentHandling MultipleDocumentHandling} attribute:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT -- The result will be <I>n</I> copies of a single output
|
||||
* document comprising all the input docs.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT_NEW_SHEET -- The result will be <I>n</I> copies of a single
|
||||
* output document comprising all the input docs, and the first impression of
|
||||
* each input doc will always start on a new media sheet.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The result will be <I>n</I> copies of
|
||||
* the first input document, followed by <I>n</I> copies of the second input
|
||||
* document, . . . followed by <I>n</I> copies of the last input document.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- The result will be the first input
|
||||
* document, the second input document, . . . the last input document, the group
|
||||
* of documents being repeated <I>n</I> times.
|
||||
* </UL>
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kamihensky
|
||||
*/
|
||||
public final class Copies extends IntegerSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -6426631521680023833L;
|
||||
|
||||
/**
|
||||
* Construct a new copies attribute with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1.
|
||||
*/
|
||||
public Copies(int value) {
|
||||
super (value, 1, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this copies attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class Copies.
|
||||
* <LI>
|
||||
* This copies attribute's value and <CODE>object</CODE>'s value are
|
||||
* equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this copies
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return super.equals (object) && object instanceof Copies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Copies, the category is class Copies itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Copies.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Copies, the category name is <CODE>"copies"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "copies";
|
||||
}
|
||||
|
||||
}
|
||||
141
jdkSrc/jdk8/javax/print/attribute/standard/CopiesSupported.java
Normal file
141
jdkSrc/jdk8/javax/print/attribute/standard/CopiesSupported.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.SetOfIntegerSyntax;
|
||||
import javax.print.attribute.SupportedValuesAttribute;
|
||||
|
||||
/**
|
||||
* Class CopiesSupported is a printing attribute class, a set of integers, that
|
||||
* gives the supported values for a {@link Copies Copies} attribute. It is
|
||||
* restricted to a single contiguous range of integers; multiple non-overlapping
|
||||
* ranges are not allowed.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The CopiesSupported attribute's canonical array
|
||||
* form gives the lower and upper bound for the range of copies to be included
|
||||
* in an IPP "copies-supported" attribute. See class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of canonical array form. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class CopiesSupported extends SetOfIntegerSyntax
|
||||
implements SupportedValuesAttribute {
|
||||
|
||||
private static final long serialVersionUID = 6927711687034846001L;
|
||||
|
||||
/**
|
||||
* Construct a new copies supported attribute containing a single integer.
|
||||
* That is, only the one value of Copies is supported.
|
||||
*
|
||||
* @param member Set member.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>member</CODE> is less than 1.
|
||||
*/
|
||||
public CopiesSupported(int member) {
|
||||
super (member);
|
||||
if (member < 1) {
|
||||
throw new IllegalArgumentException("Copies value < 1 specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new copies supported attribute containing a single range of
|
||||
* integers. That is, only those values of Copies in the one range are
|
||||
* supported.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if a null range is specified or if a
|
||||
* non-null range is specified with <CODE>lowerBound</CODE> less than
|
||||
* 1.
|
||||
*/
|
||||
public CopiesSupported(int lowerBound, int upperBound) {
|
||||
super(lowerBound, upperBound);
|
||||
|
||||
if (lowerBound > upperBound) {
|
||||
throw new IllegalArgumentException("Null range specified");
|
||||
} else if (lowerBound < 1) {
|
||||
throw new IllegalArgumentException("Copies value < 1 specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this copies supported attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions must
|
||||
* be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class CopiesSupported.
|
||||
* <LI>
|
||||
* This copies supported attribute's members and <CODE>object</CODE>'s
|
||||
* members are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this copies
|
||||
* supported attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return super.equals (object) && object instanceof CopiesSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class CopiesSupported, the category
|
||||
* is class CopiesSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return CopiesSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class CopiesSupported, the category
|
||||
* name is <CODE>"copies-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "copies-supported";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.DateTimeSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class DateTimeAtCompleted is a printing attribute class, a date-time
|
||||
* attribute, that indicates the date and time at which the Print Job completed
|
||||
* (or was canceled or aborted).
|
||||
* <P>
|
||||
* To construct a DateTimeAtCompleted attribute from separate values of the
|
||||
* year, month, day, hour, minute, and so on, use a {@link java.util.Calendar
|
||||
* Calendar} object to construct a {@link java.util.Date Date} object, then use
|
||||
* the {@link java.util.Date Date} object to construct the DateTimeAtCompleted
|
||||
* attribute. To convert a DateTimeAtCompleted attribute to separate values of
|
||||
* the year, month, day, hour, minute, and so on, create a {@link
|
||||
* java.util.Calendar Calendar} object and set it to the {@link java.util.Date
|
||||
* Date} from the DateTimeAtCompleted attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The information needed to construct an IPP
|
||||
* "date-time-at-completed" attribute can be obtained as described above. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class DateTimeAtCompleted extends DateTimeSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 6497399708058490000L;
|
||||
|
||||
/**
|
||||
* Construct a new date-time at completed attribute with the given {@link
|
||||
* java.util.Date Date} value.
|
||||
*
|
||||
* @param dateTime {@link java.util.Date Date} value.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
|
||||
*/
|
||||
public DateTimeAtCompleted(Date dateTime) {
|
||||
super (dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this date-time at completed attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class DateTimeAtCompleted.
|
||||
* <LI>
|
||||
* This date-time at completed attribute's {@link java.util.Date Date} value
|
||||
* and <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this date-time
|
||||
* at completed attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(super.equals (object) &&
|
||||
object instanceof DateTimeAtCompleted);
|
||||
}
|
||||
|
||||
// Exported operations inherited and implemented from interface Attribute.
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class DateTimeAtCompleted, the category is class
|
||||
* DateTimeAtCompleted itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return DateTimeAtCompleted.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class DateTimeAtCompleted, the category name is
|
||||
* <CODE>"date-time-at-completed"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "date-time-at-completed";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.DateTimeSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class DateTimeAtCreation is a printing attribute class, a date-time
|
||||
* attribute, that indicates the date and time at which the Print Job was
|
||||
* created.
|
||||
* <P>
|
||||
* To construct a DateTimeAtCreation attribute from separate values of the year,
|
||||
* month, day, hour, minute, and so on, use a {@link java.util.Calendar
|
||||
* Calendar} object to construct a {@link java.util.Date Date} object, then use
|
||||
* the {@link java.util.Date Date} object to construct the DateTimeAtCreation
|
||||
* attribute. To convert a DateTimeAtCreation attribute to separate values of
|
||||
* the year, month, day, hour, minute, and so on, create a {@link
|
||||
* java.util.Calendar Calendar} object and set it to the {@link java.util.Date
|
||||
* Date} from the DateTimeAtCreation attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The information needed to construct an IPP
|
||||
* "date-time-at-creation" attribute can be obtained as described above. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class DateTimeAtCreation extends DateTimeSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -2923732231056647903L;
|
||||
|
||||
/**
|
||||
* Construct a new date-time at creation attribute with the given {@link
|
||||
* java.util.Date Date} value.
|
||||
*
|
||||
* @param dateTime {@link java.util.Date Date} value.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
|
||||
*/
|
||||
public DateTimeAtCreation(Date dateTime) {
|
||||
super (dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this date-time at creation attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class DateTimeAtCreation.
|
||||
* <LI>
|
||||
* This date-time at creation attribute's {@link java.util.Date Date} value
|
||||
* and <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this date-time
|
||||
* at creation attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(super.equals (object) &&
|
||||
object instanceof DateTimeAtCreation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class DateTimeAtCreation, the category is class
|
||||
* DateTimeAtCreation itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return DateTimeAtCreation.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class DateTimeAtCreation, the category name is
|
||||
* <CODE>"date-time-at-creation"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "date-time-at-creation";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.DateTimeSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class DateTimeAtProcessing is a printing attribute class, a date-time
|
||||
* attribute, that indicates the date and time at which the Print Job first
|
||||
* began processing.
|
||||
* <P>
|
||||
* To construct a DateTimeAtProcessing attribute from separate values of the
|
||||
* year, month, day, hour, minute, and so on, use a {@link java.util.Calendar
|
||||
* Calendar} object to construct a {@link java.util.Date Date} object, then use
|
||||
* the {@link java.util.Date Date} object to construct the DateTimeAtProcessing
|
||||
* attribute. To convert a DateTimeAtProcessing attribute to separate values of
|
||||
* the year, month, day, hour, minute, and so on, create a {@link
|
||||
* java.util.Calendar Calendar} object and set it to the {@link java.util.Date
|
||||
* Date} from the DateTimeAtProcessing attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The information needed to construct an IPP
|
||||
* "date-time-at-processing" attribute can be obtained as described above. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class DateTimeAtProcessing extends DateTimeSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -3710068197278263244L;
|
||||
|
||||
/**
|
||||
* Construct a new date-time at processing attribute with the given {@link
|
||||
* java.util.Date Date} value.
|
||||
*
|
||||
* @param dateTime {@link java.util.Date Date} value.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
|
||||
*/
|
||||
public DateTimeAtProcessing(Date dateTime) {
|
||||
super (dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this date-time at processing attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class DateTimeAtProcessing.
|
||||
* <LI>
|
||||
* This date-time at processing attribute's {@link java.util.Date Date}
|
||||
* value and <CODE>object</CODE>'s {@link java.util.Date Date} value
|
||||
* are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this date-time
|
||||
* at processing attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(super.equals (object) &&
|
||||
object instanceof DateTimeAtProcessing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class DateTimeAtProcessing, the category is class
|
||||
* DateTimeAtProcessing itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return DateTimeAtProcessing.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class DateTimeAtProcessing, the category name is
|
||||
* <CODE>"date-time-at-processing"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "date-time-at-processing";
|
||||
}
|
||||
|
||||
}
|
||||
123
jdkSrc/jdk8/javax/print/attribute/standard/Destination.java
Normal file
123
jdkSrc/jdk8/javax/print/attribute/standard/Destination.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.URISyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class Destination is a printing attribute class, a URI, that is used to
|
||||
* indicate an alternate destination for the spooled printer formatted
|
||||
* data. Many PrintServices will not support the notion of a destination
|
||||
* other than the printer device, and so will not support this attribute.
|
||||
* <p>
|
||||
* A common use for this attribute will be applications which want
|
||||
* to redirect output to a local disk file : eg."file:out.prn".
|
||||
* Note that proper construction of "file:" scheme URI instances should
|
||||
* be performed using the <code>toURI()</code> method of class
|
||||
* {@link java.io.File File}.
|
||||
* See the documentation on that class for more information.
|
||||
* <p>
|
||||
* If a destination URI is specified in a PrintRequest and it is not
|
||||
* accessible for output by the PrintService, a PrintException will be thrown.
|
||||
* The PrintException may implement URIException to provide a more specific
|
||||
* cause.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> Destination is not an IPP attribute.
|
||||
* <P>
|
||||
*
|
||||
* @author Phil Race.
|
||||
*/
|
||||
public final class Destination extends URISyntax
|
||||
implements PrintJobAttribute, PrintRequestAttribute {
|
||||
|
||||
private static final long serialVersionUID = 6776739171700415321L;
|
||||
|
||||
/**
|
||||
* Constructs a new destination attribute with the specified URI.
|
||||
*
|
||||
* @param uri URI.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>uri</CODE> is null.
|
||||
*/
|
||||
public Destination(URI uri) {
|
||||
super (uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this destination attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class Destination.
|
||||
* <LI>
|
||||
* This destination attribute's URI and <CODE>object</CODE>'s URI
|
||||
* are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this destination
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) &&
|
||||
object instanceof Destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Destination, the category is class Destination itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Destination.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Destination, the category name is <CODE>"spool-data-destination"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "spool-data-destination";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
|
||||
/**
|
||||
* Class DialogTypeSelection is a printing attribute class, an enumeration,
|
||||
* that indicates the user dialog type to be used for specifying
|
||||
* printing options.
|
||||
* If {@code NATIVE} is specified, then where available, a native
|
||||
* platform dialog is displayed.
|
||||
* If {@code COMMON} is specified, a cross-platform print dialog is displayed.
|
||||
*
|
||||
* This option to specify a native dialog for use with an IPP attribute
|
||||
* set provides a standard way to reflect back of the setting and option
|
||||
* changes made by a user to the calling application, and integrates
|
||||
* the native dialog into the Java printing APIs.
|
||||
* But note that some options and settings in a native dialog may not
|
||||
* necessarily map to IPP attributes as they may be non-standard platform,
|
||||
* or even printer specific options.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> This is not an IPP attribute.
|
||||
* <P>
|
||||
* @since 1.7
|
||||
*
|
||||
*/
|
||||
public final class DialogTypeSelection extends EnumSyntax
|
||||
implements PrintRequestAttribute {
|
||||
|
||||
private static final long serialVersionUID = 7518682952133256029L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final DialogTypeSelection
|
||||
NATIVE = new DialogTypeSelection(0);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final DialogTypeSelection
|
||||
COMMON = new DialogTypeSelection(1);
|
||||
|
||||
/**
|
||||
* Construct a new dialog type selection enumeration value with the
|
||||
* given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected DialogTypeSelection(int value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"native", "common"};
|
||||
|
||||
|
||||
private static final DialogTypeSelection[] myEnumValueTable = {
|
||||
NATIVE,
|
||||
COMMON
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class DialogTypeSelection.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class DialogTypeSelection.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class DialogTypeSelection the category is class
|
||||
* DialogTypeSelection itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class getCategory() {
|
||||
return DialogTypeSelection.class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class DialogTypeSelection the category name is
|
||||
* <CODE>"dialog-type-selection"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "dialog-type-selection";
|
||||
}
|
||||
|
||||
}
|
||||
121
jdkSrc/jdk8/javax/print/attribute/standard/DocumentName.java
Normal file
121
jdkSrc/jdk8/javax/print/attribute/standard/DocumentName.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
|
||||
/**
|
||||
* Class DocumentName is a printing attribute class, a text attribute, that
|
||||
* specifies the name of a document. DocumentName is an attribute of the print
|
||||
* data (the doc), not of the Print Job. A document's name is an arbitrary
|
||||
* string defined by the client.
|
||||
* However if a JobName is not specified, the DocumentName should be used
|
||||
* instead, which implies that supporting specification of DocumentName
|
||||
* requires reporting of JobName and vice versa.
|
||||
* See {@link JobName JobName} for more information.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class DocumentName extends TextSyntax implements DocAttribute {
|
||||
|
||||
private static final long serialVersionUID = 7883105848533280430L;
|
||||
|
||||
/**
|
||||
* Constructs a new document name attribute with the given document name
|
||||
* and locale.
|
||||
*
|
||||
* @param documentName Document name.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>documentName</CODE> is null.
|
||||
*/
|
||||
public DocumentName(String documentName, Locale locale) {
|
||||
super (documentName, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this document name attribute is equivalent to the
|
||||
* passed in object.
|
||||
* To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class DocumentName.
|
||||
* <LI>
|
||||
* This document name attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This document name attribute's locale and <CODE>object</CODE>'s locale
|
||||
* are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this document
|
||||
* name attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) && object instanceof DocumentName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class DocumentName, the category is class DocumentName itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return DocumentName.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class DocumentName, the category name is <CODE>"document-name"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "document-name";
|
||||
}
|
||||
|
||||
}
|
||||
129
jdkSrc/jdk8/javax/print/attribute/standard/Fidelity.java
Normal file
129
jdkSrc/jdk8/javax/print/attribute/standard/Fidelity.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
|
||||
/**
|
||||
* Class Fidelity is a printing attribute class, an enumeration,
|
||||
* that indicates whether total fidelity to client supplied print request
|
||||
* attributes is required.
|
||||
* If FIDELITY_TRUE is specified and a service cannot print the job exactly
|
||||
* as specified it must reject the job.
|
||||
* If FIDELITY_FALSE is specified a reasonable attempt to print the job is
|
||||
* acceptable. If not supplied the default is FIDELITY_FALSE.
|
||||
*
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The IPP boolean value is "true" for FIDELITY_TRUE
|
||||
* and "false" for FIDELITY_FALSE. The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* See <a href="http://www.ietf.org/rfc/rfc2911.txt">RFC 2911</a> Section 15.1 for
|
||||
* a fuller description of the IPP fidelity attribute.
|
||||
* <P>
|
||||
*
|
||||
*/
|
||||
public final class Fidelity extends EnumSyntax
|
||||
implements PrintJobAttribute, PrintRequestAttribute {
|
||||
|
||||
private static final long serialVersionUID = 6320827847329172308L;
|
||||
|
||||
/**
|
||||
* The job must be printed exactly as specified. or else rejected.
|
||||
*/
|
||||
public static final Fidelity
|
||||
FIDELITY_TRUE = new Fidelity(0);
|
||||
|
||||
/**
|
||||
* The printer should make reasonable attempts to print the job,
|
||||
* even if it cannot print it exactly as specified.
|
||||
*/
|
||||
public static final Fidelity
|
||||
FIDELITY_FALSE = new Fidelity(1);
|
||||
|
||||
/**
|
||||
* Construct a new fidelity enumeration value with the
|
||||
* given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected Fidelity(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"true",
|
||||
"false"
|
||||
};
|
||||
|
||||
|
||||
private static final Fidelity[] myEnumValueTable = {
|
||||
FIDELITY_TRUE,
|
||||
FIDELITY_FALSE
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class Fidelity.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class Fidelity.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
} /**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Fidelity the category is class Fidelity itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Fidelity.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Fidelity the category name is
|
||||
* <CODE>"ipp-attribute-fidelity"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "ipp-attribute-fidelity";
|
||||
}
|
||||
|
||||
}
|
||||
477
jdkSrc/jdk8/javax/print/attribute/standard/Finishings.java
Normal file
477
jdkSrc/jdk8/javax/print/attribute/standard/Finishings.java
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class Finishings is a printing attribute class, an enumeration, that
|
||||
* identifies whether the printer applies a finishing operation of some kind
|
||||
* of binding to each copy of each printed document in the job. For multidoc
|
||||
* print jobs (jobs with multiple documents), the
|
||||
* {@link MultipleDocumentHandling
|
||||
* MultipleDocumentHandling} attribute determines what constitutes a "copy"
|
||||
* for purposes of finishing.
|
||||
* <P>
|
||||
* Standard Finishings values are:
|
||||
* <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% SUMMARY="layout">
|
||||
* <TR>
|
||||
* <TD STYLE="WIDTH:10%">
|
||||
*
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #NONE NONE}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE STAPLE}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:36%">
|
||||
* {@link #EDGE_STITCH EDGE_STITCH}
|
||||
* </TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>
|
||||
*
|
||||
* </TD>
|
||||
* <TD>
|
||||
* {@link #BIND BIND}
|
||||
* </TD>
|
||||
* <TD>
|
||||
* {@link #SADDLE_STITCH SADDLE_STITCH}
|
||||
* </TD>
|
||||
* <TD>
|
||||
* {@link #COVER COVER}
|
||||
* </TD>
|
||||
* <TD>
|
||||
*
|
||||
* </TD>
|
||||
* </TR>
|
||||
* </TABLE>
|
||||
* <P>
|
||||
* The following Finishings values are more specific; they indicate a
|
||||
* corner or an edge as if the document were a portrait document:
|
||||
* <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% SUMMARY="layout">
|
||||
* <TR>
|
||||
* <TD STYLE="WIDTH:10%">
|
||||
*
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:9%">
|
||||
*
|
||||
* </TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD STYLE="WIDTH:10%">
|
||||
*
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #EDGE_STITCH_TOP EDGE_STITCH_TOP}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:9%">
|
||||
*
|
||||
* </TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD STYLE="WIDTH:10%">
|
||||
*
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:9%">
|
||||
*
|
||||
* </TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD STYLE="WIDTH:10%">
|
||||
*
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:27%">
|
||||
* {@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM}
|
||||
* </TD>
|
||||
* <TD STYLE="WIDTH:9%">
|
||||
*
|
||||
* </TD>
|
||||
* </TR>
|
||||
* </TABLE>
|
||||
* <P>
|
||||
* The STAPLE_<I>XXX</I> values are specified with respect to the
|
||||
* document as if the document were a portrait document. If the document is
|
||||
* actually a landscape or a reverse-landscape document, the client supplies the
|
||||
* appropriate transformed value. For example, to position a staple in the upper
|
||||
* left hand corner of a landscape document when held for reading, the client
|
||||
* supplies the STAPLE_BOTTOM_LEFT value (since landscape is
|
||||
* defined as a +90 degree rotation from portrait, i.e., anti-clockwise). On the
|
||||
* other hand, to position a staple in the upper left hand corner of a
|
||||
* reverse-landscape document when held for reading, the client supplies the
|
||||
* STAPLE_TOP_RIGHT value (since reverse-landscape is defined as a
|
||||
* -90 degree rotation from portrait, i.e., clockwise).
|
||||
* <P>
|
||||
* The angle (vertical, horizontal, angled) of each staple with respect to the
|
||||
* document depends on the implementation which may in turn depend on the value
|
||||
* of the attribute.
|
||||
* <P>
|
||||
* The effect of a Finishings attribute on a multidoc print job (a job
|
||||
* with multiple documents) depends on whether all the docs have the same
|
||||
* binding specified or whether different docs have different bindings
|
||||
* specified, and on the (perhaps defaulted) value of the {@link
|
||||
* MultipleDocumentHandling MultipleDocumentHandling} attribute.
|
||||
* <UL>
|
||||
* <LI>
|
||||
* If all the docs have the same binding specified, then any value of {@link
|
||||
* MultipleDocumentHandling MultipleDocumentHandling} makes sense, and the
|
||||
* printer's processing depends on the {@link MultipleDocumentHandling
|
||||
* MultipleDocumentHandling} value:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT -- All the input docs will be bound together as one output
|
||||
* document with the specified binding.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be bound together as one
|
||||
* output document with the specified binding, and the first impression of each
|
||||
* input doc will always start on a new media sheet.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will be bound
|
||||
* separately with the specified binding.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input doc will be bound separately
|
||||
* with the specified binding.
|
||||
* </UL>
|
||||
* <P>
|
||||
* <LI>
|
||||
* If different docs have different bindings specified, then only two values of
|
||||
* {@link MultipleDocumentHandling MultipleDocumentHandling} make sense, and the
|
||||
* printer reports an error when the job is submitted if any other value is
|
||||
* specified:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will be bound
|
||||
* separately with its own specified binding.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input doc will be bound separately
|
||||
* with its own specified binding.
|
||||
* </UL>
|
||||
* </UL>
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> Class Finishings encapsulates some of the
|
||||
* IPP enum values that can be included in an IPP "finishings" attribute, which
|
||||
* is a set of enums. The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* In IPP Finishings is a multi-value attribute, this API currently allows
|
||||
* only one binding to be specified.
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class Finishings extends EnumSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -627840419548391754L;
|
||||
|
||||
/**
|
||||
* Perform no binding.
|
||||
*/
|
||||
public static final Finishings NONE = new Finishings(3);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples. The exact number and
|
||||
* placement of the staples is site-defined.
|
||||
*/
|
||||
public static final Finishings STAPLE = new Finishings(4);
|
||||
|
||||
/**
|
||||
* This value is specified when it is desired to select a non-printed (or
|
||||
* pre-printed) cover for the document. This does not supplant the
|
||||
* specification of a printed cover (on cover stock medium) by the
|
||||
* document itself.
|
||||
*/
|
||||
public static final Finishings COVER = new Finishings(6);
|
||||
|
||||
/**
|
||||
* This value indicates that a binding is to be applied to the document;
|
||||
* the type and placement of the binding is site-defined.
|
||||
*/
|
||||
public static final Finishings BIND = new Finishings(7);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples (wire stitches) along the
|
||||
* middle fold. The exact number and placement of the staples and the
|
||||
* middle fold is implementation- and/or site-defined.
|
||||
*/
|
||||
public static final Finishings SADDLE_STITCH =
|
||||
new Finishings(8);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples (wire stitches) along one
|
||||
* edge. The exact number and placement of the staples is implementation-
|
||||
* and/or site- defined.
|
||||
*/
|
||||
public static final Finishings EDGE_STITCH =
|
||||
new Finishings(9);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples in the top left corner.
|
||||
*/
|
||||
public static final Finishings STAPLE_TOP_LEFT =
|
||||
new Finishings(20);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples in the bottom left
|
||||
* corner.
|
||||
*/
|
||||
public static final Finishings STAPLE_BOTTOM_LEFT =
|
||||
new Finishings(21);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples in the top right corner.
|
||||
*/
|
||||
public static final Finishings STAPLE_TOP_RIGHT =
|
||||
new Finishings(22);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples in the bottom right
|
||||
* corner.
|
||||
*/
|
||||
public static final Finishings STAPLE_BOTTOM_RIGHT =
|
||||
new Finishings(23);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples (wire stitches) along the
|
||||
* left edge. The exact number and placement of the staples is
|
||||
* implementation- and/or site-defined.
|
||||
*/
|
||||
public static final Finishings EDGE_STITCH_LEFT =
|
||||
new Finishings(24);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples (wire stitches) along the
|
||||
* top edge. The exact number and placement of the staples is
|
||||
* implementation- and/or site-defined.
|
||||
*/
|
||||
public static final Finishings EDGE_STITCH_TOP =
|
||||
new Finishings(25);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples (wire stitches) along the
|
||||
* right edge. The exact number and placement of the staples is
|
||||
* implementation- and/or site-defined.
|
||||
*/
|
||||
public static final Finishings EDGE_STITCH_RIGHT =
|
||||
new Finishings(26);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with one or more staples (wire stitches) along the
|
||||
* bottom edge. The exact number and placement of the staples is
|
||||
* implementation- and/or site-defined.
|
||||
*/
|
||||
public static final Finishings EDGE_STITCH_BOTTOM =
|
||||
new Finishings(27);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with two staples (wire stitches) along the left
|
||||
* edge assuming a portrait document (see above).
|
||||
*/
|
||||
public static final Finishings STAPLE_DUAL_LEFT =
|
||||
new Finishings(28);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with two staples (wire stitches) along the top
|
||||
* edge assuming a portrait document (see above).
|
||||
*/
|
||||
public static final Finishings STAPLE_DUAL_TOP =
|
||||
new Finishings(29);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with two staples (wire stitches) along the right
|
||||
* edge assuming a portrait document (see above).
|
||||
*/
|
||||
public static final Finishings STAPLE_DUAL_RIGHT =
|
||||
new Finishings(30);
|
||||
|
||||
/**
|
||||
* Bind the document(s) with two staples (wire stitches) along the bottom
|
||||
* edge assuming a portrait document (see above).
|
||||
*/
|
||||
public static final Finishings STAPLE_DUAL_BOTTOM =
|
||||
new Finishings(31);
|
||||
|
||||
/**
|
||||
* Construct a new finishings binding enumeration value with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected Finishings(int value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable =
|
||||
{"none",
|
||||
"staple",
|
||||
null,
|
||||
"cover",
|
||||
"bind",
|
||||
"saddle-stitch",
|
||||
"edge-stitch",
|
||||
null, // The next ten enum values are reserved.
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"staple-top-left",
|
||||
"staple-bottom-left",
|
||||
"staple-top-right",
|
||||
"staple-bottom-right",
|
||||
"edge-stitch-left",
|
||||
"edge-stitch-top",
|
||||
"edge-stitch-right",
|
||||
"edge-stitch-bottom",
|
||||
"staple-dual-left",
|
||||
"staple-dual-top",
|
||||
"staple-dual-right",
|
||||
"staple-dual-bottom"
|
||||
};
|
||||
|
||||
private static final Finishings[] myEnumValueTable =
|
||||
{NONE,
|
||||
STAPLE,
|
||||
null,
|
||||
COVER,
|
||||
BIND,
|
||||
SADDLE_STITCH,
|
||||
EDGE_STITCH,
|
||||
null, // The next ten enum values are reserved.
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
STAPLE_TOP_LEFT,
|
||||
STAPLE_BOTTOM_LEFT,
|
||||
STAPLE_TOP_RIGHT,
|
||||
STAPLE_BOTTOM_RIGHT,
|
||||
EDGE_STITCH_LEFT,
|
||||
EDGE_STITCH_TOP,
|
||||
EDGE_STITCH_RIGHT,
|
||||
EDGE_STITCH_BOTTOM,
|
||||
STAPLE_DUAL_LEFT,
|
||||
STAPLE_DUAL_TOP,
|
||||
STAPLE_DUAL_RIGHT,
|
||||
STAPLE_DUAL_BOTTOM
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class Finishings.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class Finishings.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowest integer value used by class Finishings.
|
||||
*/
|
||||
protected int getOffset() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Finishings and any vendor-defined subclasses, the
|
||||
* category is class Finishings itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Finishings.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Finishings and any vendor-defined subclasses, the
|
||||
* category name is <CODE>"finishings"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "finishings";
|
||||
}
|
||||
|
||||
}
|
||||
153
jdkSrc/jdk8/javax/print/attribute/standard/JobHoldUntil.java
Normal file
153
jdkSrc/jdk8/javax/print/attribute/standard/JobHoldUntil.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.DateTimeSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobHoldUntil is a printing attribute class, a date-time attribute, that
|
||||
* specifies the exact date and time at which the job must become a candidate
|
||||
* for printing.
|
||||
* <P>
|
||||
* If the value of this attribute specifies a date-time that is in the future,
|
||||
* the printer should add the {@link JobStateReason JobStateReason} value of
|
||||
* JOB_HOLD_UNTIL_SPECIFIED to the job's {@link JobStateReasons JobStateReasons}
|
||||
* attribute, must move the job to the PENDING_HELD state, and must not schedule
|
||||
* the job for printing until the specified date-time arrives.
|
||||
* <P>
|
||||
* When the specified date-time arrives, the printer must remove the {@link
|
||||
* JobStateReason JobStateReason} value of JOB_HOLD_UNTIL_SPECIFIED from the
|
||||
* job's {@link JobStateReasons JobStateReasons} attribute, if present. If there
|
||||
* are no other job state reasons that keep the job in the PENDING_HELD state,
|
||||
* the printer must consider the job as a candidate for processing by moving the
|
||||
* job to the PENDING state.
|
||||
* <P>
|
||||
* If the specified date-time has already passed, the job must be a candidate
|
||||
* for processing immediately. Thus, one way to make the job immediately become
|
||||
* a candidate for processing is to specify a JobHoldUntil attribute constructed
|
||||
* like this (denoting a date-time of January 1, 1970, 00:00:00 GMT):
|
||||
* <PRE>
|
||||
* JobHoldUntil immediately = new JobHoldUntil (new Date (0L));
|
||||
* </PRE>
|
||||
* <P>
|
||||
* If the client does not supply this attribute in a Print Request and the
|
||||
* printer supports this attribute, the printer must use its
|
||||
* (implementation-dependent) default JobHoldUntil value at job submission time
|
||||
* (unlike most job template attributes that are used if necessary at job
|
||||
* processing time).
|
||||
* <P>
|
||||
* To construct a JobHoldUntil attribute from separate values of the year,
|
||||
* month, day, hour, minute, and so on, use a {@link java.util.Calendar
|
||||
* Calendar} object to construct a {@link java.util.Date Date} object, then use
|
||||
* the {@link java.util.Date Date} object to construct the JobHoldUntil
|
||||
* attribute. To convert a JobHoldUntil attribute to separate values of the
|
||||
* year, month, day, hour, minute, and so on, create a {@link java.util.Calendar
|
||||
* Calendar} object and set it to the {@link java.util.Date Date} from the
|
||||
* JobHoldUntil attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> Although IPP supports a "job-hold-until" attribute
|
||||
* specified as a keyword, IPP does not at this time support a "job-hold-until"
|
||||
* attribute specified as a date and time. However, the date and time can be
|
||||
* converted to one of the standard IPP keywords with some loss of precision;
|
||||
* for example, a JobHoldUntil value with today's date and 9:00pm local time
|
||||
* might be converted to the standard IPP keyword "night". The category name
|
||||
* returned by <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobHoldUntil extends DateTimeSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -1664471048860415024L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new job hold until date-time attribute with the given
|
||||
* {@link java.util.Date Date} value.
|
||||
*
|
||||
* @param dateTime {@link java.util.Date Date} value.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>dateTime</CODE> is null.
|
||||
*/
|
||||
public JobHoldUntil(Date dateTime) {
|
||||
super (dateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job hold until attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobHoldUntil.
|
||||
* <LI>
|
||||
* This job hold until attribute's {@link java.util.Date Date} value and
|
||||
* <CODE>object</CODE>'s {@link java.util.Date Date} value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job hold
|
||||
* until attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof JobHoldUntil);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobHoldUntil, the category is class JobHoldUntil itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobHoldUntil.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobHoldUntil, the category name is <CODE>"job-hold-until"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-hold-until";
|
||||
}
|
||||
|
||||
}
|
||||
144
jdkSrc/jdk8/javax/print/attribute/standard/JobImpressions.java
Normal file
144
jdkSrc/jdk8/javax/print/attribute/standard/JobImpressions.java
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobImpressions is an integer valued printing attribute class that
|
||||
* specifies the total size in number of impressions of the document(s) being
|
||||
* submitted. An "impression" is the image (possibly many print-stream pages in
|
||||
* different configurations) imposed onto a single media page.
|
||||
* <P>
|
||||
* The JobImpressions attribute describes the size of the job. This attribute is
|
||||
* not intended to be a counter; it is intended to be useful routing and
|
||||
* scheduling information if known. The printer may try to compute the
|
||||
* JobImpressions attribute's value if it is not supplied in the Print Request.
|
||||
* Even if the client does supply a value for the JobImpressions attribute in
|
||||
* the Print Request, the printer may choose to change the value if the printer
|
||||
* is able to compute a value which is more accurate than the client supplied
|
||||
* value. The printer may be able to determine the correct value for the
|
||||
* JobImpressions attribute either right at job submission time or at any later
|
||||
* point in time.
|
||||
* <P>
|
||||
* As with {@link JobKOctets JobKOctets}, the JobImpressions value must not
|
||||
* include the multiplicative factors contributed by the number of copies
|
||||
* specified by the {@link Copies Copies} attribute, independent of whether the
|
||||
* device can process multiple copies without making multiple passes over the
|
||||
* job or document data and independent of whether the output is collated or
|
||||
* not. Thus the value is independent of the implementation and reflects the
|
||||
* size of the document(s) measured in impressions independent of the number of
|
||||
* copies.
|
||||
* <P>
|
||||
* As with {@link JobKOctets JobKOctets}, the JobImpressions value must also not
|
||||
* include the multiplicative factor due to a copies instruction embedded in the
|
||||
* document data. If the document data actually includes replications of the
|
||||
* document data, this value will include such replication. In other words, this
|
||||
* value is always the number of impressions in the source document data, rather
|
||||
* than a measure of the number of impressions to be produced by the job.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @see JobImpressionsSupported
|
||||
* @see JobImpressionsCompleted
|
||||
* @see JobKOctets
|
||||
* @see JobMediaSheets
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobImpressions extends IntegerSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 8225537206784322464L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new job impressions attribute with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public JobImpressions(int value) {
|
||||
super(value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job impressions attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions must
|
||||
* be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobImpressions.
|
||||
* <LI>
|
||||
* This job impressions attribute's value and <CODE>object</CODE>'s value
|
||||
* are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* impressions attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return super.equals (object) && object instanceof JobImpressions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobImpressions, the category is class JobImpressions itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobImpressions.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobImpressions, the category name is
|
||||
* <CODE>"job-impressions"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-impressions";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobImpressionsCompleted is an integer valued printing attribute class
|
||||
* that specifies the number of impressions completed for the job so far. For
|
||||
* printing devices, the impressions completed includes interpreting, marking,
|
||||
* and stacking the output.
|
||||
* <P>
|
||||
* The JobImpressionsCompleted attribute describes the progress of the job. This
|
||||
* attribute is intended to be a counter. That is, the JobImpressionsCompleted
|
||||
* value for a job that has not started processing must be 0. When the job's
|
||||
* {@link JobState JobState} is PROCESSING or PROCESSING_STOPPED, the
|
||||
* JobImpressionsCompleted value is intended to increase as the job is
|
||||
* processed; it indicates the amount of the job that has been processed at the
|
||||
* time the Print Job's attribute set is queried or at the time a print job
|
||||
* event is reported. When the job enters the COMPLETED, CANCELED, or ABORTED
|
||||
* states, the JobImpressionsCompleted value is the final value for the job.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @see JobImpressions
|
||||
* @see JobImpressionsSupported
|
||||
* @see JobKOctetsProcessed
|
||||
* @see JobMediaSheetsCompleted
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobImpressionsCompleted extends IntegerSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 6722648442432393294L;
|
||||
|
||||
/**
|
||||
* Construct a new job impressions completed attribute with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public JobImpressionsCompleted(int value) {
|
||||
super (value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job impressions completed attribute is equivalent
|
||||
* tp the passed in object. To be equivalent, all of the following
|
||||
* conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobImpressionsCompleted.
|
||||
* <LI>
|
||||
* This job impressions completed attribute's value and
|
||||
* <CODE>object</CODE>'s value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* impressions completed attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(super.equals (object) &&
|
||||
object instanceof JobImpressionsCompleted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobImpressionsCompleted, the category is class
|
||||
* JobImpressionsCompleted itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobImpressionsCompleted.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobImpressionsCompleted, the category name is
|
||||
* <CODE>"job-impressions-completed"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-impressions-completed";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.SetOfIntegerSyntax;
|
||||
import javax.print.attribute.SupportedValuesAttribute;
|
||||
|
||||
/**
|
||||
* Class JobImpressionsSupported is a printing attribute class, a set of
|
||||
* integers, that gives the supported values for a {@link JobImpressions
|
||||
* JobImpressions} attribute. It is restricted to a single contiguous range of
|
||||
* integers; multiple non-overlapping ranges are not allowed. This gives the
|
||||
* lower and upper bounds of the total sizes of print jobs in number of
|
||||
* impressions that the printer will accept.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The JobImpressionsSupported attribute's canonical
|
||||
* array form gives the lower and upper bound for the range of values to be
|
||||
* included in an IPP "job-impressions-supported" attribute. See class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of canonical array form. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobImpressionsSupported extends SetOfIntegerSyntax
|
||||
implements SupportedValuesAttribute {
|
||||
|
||||
private static final long serialVersionUID = -4887354803843173692L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new job impressions supported attribute containing a single
|
||||
* range of integers. That is, only those values of JobImpressions in the
|
||||
* one range are supported.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if a null range is specified or if a
|
||||
* non-null range is specified with <CODE>lowerBound</CODE> less than
|
||||
* 0.
|
||||
*/
|
||||
public JobImpressionsSupported(int lowerBound, int upperBound) {
|
||||
super (lowerBound, upperBound);
|
||||
if (lowerBound > upperBound) {
|
||||
throw new IllegalArgumentException("Null range specified");
|
||||
} else if (lowerBound < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Job K octets value < 0 specified");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this job impressions supported attribute is equivalent
|
||||
* to the passed in object. To be equivalent, all of the following
|
||||
* conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobImpressionsSupported.
|
||||
* <LI>
|
||||
* This job impressions supported attribute's members and
|
||||
* <CODE>object</CODE>'s members are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* impressions supported attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof JobImpressionsSupported);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobImpressionsSupported, the category is class
|
||||
* JobImpressionsSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobImpressionsSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobImpressionsSupported, the category name is
|
||||
* <CODE>"job-impressions-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-impressions-supported";
|
||||
}
|
||||
|
||||
}
|
||||
194
jdkSrc/jdk8/javax/print/attribute/standard/JobKOctets.java
Normal file
194
jdkSrc/jdk8/javax/print/attribute/standard/JobKOctets.java
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobKOctets is an integer valued printing attribute class that specifies
|
||||
* the total size of the document(s) in K octets, i.e., in units of 1024 octets
|
||||
* requested to be processed in the job. The value must be rounded up, so that a
|
||||
* job between 1 and 1024 octets must be indicated as being 1K octets, 1025 to
|
||||
* 2048 must be 2K octets, etc. For a multidoc print job (a job with multiple
|
||||
* documents), the JobKOctets value is computed by adding up the individual
|
||||
* documents' sizes in octets, then rounding up to the next K octets value.
|
||||
* <P>
|
||||
* The JobKOctets attribute describes the size of the job. This attribute is not
|
||||
* intended to be a counter; it is intended to be useful routing and scheduling
|
||||
* information if known. The printer may try to compute the JobKOctets
|
||||
* attribute's value if it is not supplied in the Print Request. Even if the
|
||||
* client does supply a value for the JobKOctets attribute in the Print Request,
|
||||
* the printer may choose to change the value if the printer is able to compute
|
||||
* a value which is more accurate than the client supplied value. The printer
|
||||
* may be able to determine the correct value for the JobKOctets attribute
|
||||
* either right at job submission time or at any later point in time.
|
||||
* <P>
|
||||
* The JobKOctets value must not include the multiplicative factors contributed
|
||||
* by the number of copies specified by the {@link Copies Copies} attribute,
|
||||
* independent of whether the device can process multiple copies without making
|
||||
* multiple passes over the job or document data and independent of whether the
|
||||
* output is collated or not. Thus the value is independent of the
|
||||
* implementation and indicates the size of the document(s) measured in K octets
|
||||
* independent of the number of copies.
|
||||
* <P>
|
||||
* The JobKOctets value must also not include the multiplicative factor due to a
|
||||
* copies instruction embedded in the document data. If the document data
|
||||
* actually includes replications of the document data, this value will include
|
||||
* such replication. In other words, this value is always the size of the source
|
||||
* document data, rather than a measure of the hardcopy output to be produced.
|
||||
* <P>
|
||||
* The size of a doc is computed based on the print data representation class as
|
||||
* specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as
|
||||
* shown in the table below.
|
||||
* <P>
|
||||
* <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=1 SUMMARY="Table showing computation of doc sizes">
|
||||
* <TR>
|
||||
* <TH>Representation Class</TH>
|
||||
* <TH>Document Size</TH>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>byte[]</TD>
|
||||
* <TD>Length of the byte array</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.io.InputStream</TD>
|
||||
* <TD>Number of bytes read from the stream</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>char[]</TD>
|
||||
* <TD>Length of the character array x 2</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.lang.String</TD>
|
||||
* <TD>Length of the string x 2</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.io.Reader</TD>
|
||||
* <TD>Number of characters read from the stream x 2</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.net.URL</TD>
|
||||
* <TD>Number of bytes read from the file at the given URL address</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.awt.image.renderable.RenderableImage</TD>
|
||||
* <TD>Implementation dependent*</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.awt.print.Printable</TD>
|
||||
* <TD>Implementation dependent*</TD>
|
||||
* </TR>
|
||||
* <TR>
|
||||
* <TD>java.awt.print.Pageable</TD>
|
||||
* <TD>Implementation dependent*</TD>
|
||||
* </TR>
|
||||
* </TABLE>
|
||||
* <P>
|
||||
* * In these cases the Print Service itself generates the print data sent
|
||||
* to the printer. If the Print Service supports the JobKOctets attribute, for
|
||||
* these cases the Print Service itself must calculate the size of the print
|
||||
* data, replacing any JobKOctets value the client specified.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @see JobKOctetsSupported
|
||||
* @see JobKOctetsProcessed
|
||||
* @see JobImpressions
|
||||
* @see JobMediaSheets
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobKOctets extends IntegerSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -8959710146498202869L;
|
||||
|
||||
/**
|
||||
* Construct a new job K octets attribute with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public JobKOctets(int value) {
|
||||
super (value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job K octets attribute is equivalent to the passed
|
||||
* in object. To be equivalent, all of the following conditions must be
|
||||
* true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobKOctets.
|
||||
* <LI>
|
||||
* This job K octets attribute's value and <CODE>object</CODE>'s value
|
||||
* are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job K
|
||||
* octets attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return super.equals(object) && object instanceof JobKOctets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobKOctets, the category is class JobKOctets itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobKOctets.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobKOctets, the category name is <CODE>"job-k-octets"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-k-octets";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobKOctetsProcessed is an integer valued printing attribute class that
|
||||
* specifies the total number of print data octets processed so far in K octets,
|
||||
* i.e., in units of 1024 octets. The value must be rounded up, so that a job
|
||||
* between 1 and 1024 octets inclusive must be indicated as being 1K octets,
|
||||
* 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a job with
|
||||
* multiple documents), the JobKOctetsProcessed value is computed by adding up
|
||||
* the individual documents' number of octets processed so far, then rounding up
|
||||
* to the next K octets value.
|
||||
* <P>
|
||||
* The JobKOctetsProcessed attribute describes the progress of the job. This
|
||||
* attribute is intended to be a counter. That is, the JobKOctetsProcessed value
|
||||
* for a job that has not started processing must be 0. When the job's {@link
|
||||
* JobState JobState} is PROCESSING or PROCESSING_STOPPED, the
|
||||
* JobKOctetsProcessed value is intended to increase as the job is processed; it
|
||||
* indicates the amount of the job that has been processed at the time the Print
|
||||
* Job's attribute set is queried or at the time a print job event is reported.
|
||||
* When the job enters the COMPLETED, CANCELED, or ABORTED states, the
|
||||
* JobKOctetsProcessed value is the final value for the job.
|
||||
* <P>
|
||||
* For implementations where multiple copies are produced by the interpreter
|
||||
* with only a single pass over the data, the final value of the
|
||||
* JobKOctetsProcessed attribute must be equal to the value of the {@link
|
||||
* JobKOctets JobKOctets} attribute. For implementations where multiple copies
|
||||
* are produced by the interpreter by processing the data for each copy, the
|
||||
* final value must be a multiple of the value of the {@link JobKOctets
|
||||
* JobKOctets} attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @see JobKOctets
|
||||
* @see JobKOctetsSupported
|
||||
* @see JobImpressionsCompleted
|
||||
* @see JobMediaSheetsCompleted
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobKOctetsProcessed extends IntegerSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -6265238509657881806L;
|
||||
|
||||
/**
|
||||
* Construct a new job K octets processed attribute with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public JobKOctetsProcessed(int value) {
|
||||
super (value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job K octets processed attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobKOctetsProcessed.
|
||||
* <LI>
|
||||
* This job K octets processed attribute's value and
|
||||
* <CODE>object</CODE>'s value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job K
|
||||
* octets processed attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(super.equals (object) &&
|
||||
object instanceof JobKOctetsProcessed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobKOctetsProcessed, the category is class
|
||||
* JobKOctetsProcessed itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobKOctetsProcessed.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobKOctetsProcessed, the category name is
|
||||
* <CODE>"job-k-octets-processed"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-k-octets-processed";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.SetOfIntegerSyntax;
|
||||
import javax.print.attribute.SupportedValuesAttribute;
|
||||
|
||||
/**
|
||||
* Class JobKOctetsSupported is a printing attribute class, a set of integers,
|
||||
* that gives the supported values for a {@link JobKOctets JobKOctets}
|
||||
* attribute. It is restricted to a single contiguous range of integers;
|
||||
* multiple non-overlapping ranges are not allowed. This gives the lower and
|
||||
* upper bounds of the total sizes of print jobs in units of K octets (1024
|
||||
* octets) that the printer will accept.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The JobKOctetsSupported attribute's canonical array
|
||||
* form gives the lower and upper bound for the range of values to be included
|
||||
* in an IPP "job-k-octets-supported" attribute. See class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of canonical array form. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobKOctetsSupported extends SetOfIntegerSyntax
|
||||
implements SupportedValuesAttribute {
|
||||
|
||||
private static final long serialVersionUID = -2867871140549897443L;
|
||||
|
||||
/**
|
||||
* Construct a new job K octets supported attribute containing a single
|
||||
* range of integers. That is, only those values of JobKOctets in the one
|
||||
* range are supported.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if a null range is specified or if a
|
||||
* non-null range is specified with <CODE>lowerBound</CODE> less than
|
||||
* 0.
|
||||
*/
|
||||
public JobKOctetsSupported(int lowerBound, int upperBound) {
|
||||
super (lowerBound, upperBound);
|
||||
if (lowerBound > upperBound) {
|
||||
throw new IllegalArgumentException("Null range specified");
|
||||
} else if (lowerBound < 0) {
|
||||
throw new IllegalArgumentException
|
||||
("Job K octets value < 0 specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job K octets supported attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobKOctetsSupported.
|
||||
* <LI>
|
||||
* This job K octets supported attribute's members and
|
||||
* <CODE>object</CODE>'s members are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job K
|
||||
* octets supported attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof JobKOctetsSupported);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobKOctetsSupported, the category is class
|
||||
* JobKOctetsSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobKOctetsSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobKOctetsSupported, the category name is
|
||||
* <CODE>"job-k-octets-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-k-octets-supported";
|
||||
}
|
||||
|
||||
}
|
||||
138
jdkSrc/jdk8/javax/print/attribute/standard/JobMediaSheets.java
Normal file
138
jdkSrc/jdk8/javax/print/attribute/standard/JobMediaSheets.java
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobMediaSheets is an integer valued printing attribute class that
|
||||
* specifies the total number of media sheets to be produced for this job.
|
||||
* <P>
|
||||
* The JobMediaSheets attribute describes the size of the job. This attribute is
|
||||
* not intended to be a counter; it is intended to be useful routing and
|
||||
* scheduling information if known. The printer may try to compute the
|
||||
* JobMediaSheets attribute's value if it is not supplied in the Print Request.
|
||||
* Even if the client does supply a value for the JobMediaSheets attribute in
|
||||
* the Print Request, the printer may choose to change the value if the printer
|
||||
* is able to compute a value which is more accurate than the client supplied
|
||||
* value. The printer may be able to determine the correct value for the
|
||||
* JobMediaSheets attribute either right at job submission time or at any later
|
||||
* point in time.
|
||||
* <P>
|
||||
* Unlike the {@link JobKOctets JobKOctets} and {@link JobImpressions
|
||||
* JobImpressions} attributes, the JobMediaSheets value must include the
|
||||
* multiplicative factors contributed by the number of copies specified by the
|
||||
* {@link Copies Copies} attribute and a "number of copies" instruction embedded
|
||||
* in the document data, if any. This difference allows the system administrator
|
||||
* to control the lower and upper bounds of both (1) the size of the document(s)
|
||||
* with {@link JobKOctetsSupported JobKOctetsSupported} and {@link
|
||||
* JobImpressionsSupported JobImpressionsSupported} and (2) the size of the job
|
||||
* with {@link JobMediaSheetsSupported JobMediaSheetsSupported}.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @see JobMediaSheetsSupported
|
||||
* @see JobMediaSheetsCompleted
|
||||
* @see JobKOctets
|
||||
* @see JobImpressions
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class JobMediaSheets extends IntegerSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 408871131531979741L;
|
||||
|
||||
/**
|
||||
* Construct a new job media sheets attribute with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public JobMediaSheets(int value) {
|
||||
super (value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job media sheets attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions must
|
||||
* be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobMediaSheets.
|
||||
* <LI>
|
||||
* This job media sheets attribute's value and <CODE>object</CODE>'s
|
||||
* value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job media
|
||||
* sheets attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return super.equals(object) && object instanceof JobMediaSheets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobMediaSheets and any vendor-defined subclasses, the category
|
||||
* is class JobMediaSheets itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobMediaSheets.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobMediaSheets and any vendor-defined subclasses, the
|
||||
* category name is <CODE>"job-media-sheets"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-media-sheets";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobMediaSheetsCompleted is an integer valued printing attribute class
|
||||
* that specifies the number of media sheets which have completed marking and
|
||||
* stacking for the entire job so far, whether those sheets have been processed
|
||||
* on one side or on both.
|
||||
* <P>
|
||||
* The JobMediaSheetsCompleted attribute describes the progress of the job. This
|
||||
* attribute is intended to be a counter. That is, the JobMediaSheetsCompleted
|
||||
* value for a job that has not started processing must be 0. When the job's
|
||||
* {@link JobState JobState} is PROCESSING or PROCESSING_STOPPED, the
|
||||
* JobMediaSheetsCompleted value is intended to increase as the job is
|
||||
* processed; it indicates the amount of the job that has been processed at the
|
||||
* time the Print Job's attribute set is queried or at the time a print job
|
||||
* event is reported. When the job enters the COMPLETED, CANCELED, or ABORTED
|
||||
* states, the JobMediaSheetsCompleted value is the final value for the job.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @see JobMediaSheets
|
||||
* @see JobMediaSheetsSupported
|
||||
* @see JobKOctetsProcessed
|
||||
* @see JobImpressionsCompleted
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobMediaSheetsCompleted extends IntegerSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1739595973810840475L;
|
||||
|
||||
/**
|
||||
* Construct a new job media sheets completed attribute with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public JobMediaSheetsCompleted(int value) {
|
||||
super (value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job media sheets completed attribute is equivalent
|
||||
* to the passed in object. To be equivalent, all of the following
|
||||
* conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobMediaSheetsCompleted.
|
||||
* <LI>
|
||||
* This job media sheets completed attribute's value and
|
||||
* <CODE>object</CODE>'s value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job media
|
||||
* sheets completed attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof JobMediaSheetsCompleted);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobMediaSheetsCompleted, the category is class
|
||||
* JobMediaSheetsCompleted itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobMediaSheetsCompleted.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobMediaSheetsCompleted, the category name is
|
||||
* <CODE>"job-media-sheets-completed"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-media-sheets-completed";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.SetOfIntegerSyntax;
|
||||
import javax.print.attribute.SupportedValuesAttribute;
|
||||
|
||||
/**
|
||||
* Class JobMediaSheetsSupported is a printing attribute class, a set of
|
||||
* integers, that gives the supported values for a {@link JobMediaSheets
|
||||
* JobMediaSheets} attribute. It is restricted to a single contiguous range of
|
||||
* integers; multiple non-overlapping ranges are not allowed. This gives the
|
||||
* lower and upper bounds of the total sizes of print jobs in number of media
|
||||
* sheets that the printer will accept.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The JobMediaSheetsSupported attribute's canonical
|
||||
* array form gives the lower and upper bound for the range of values to be
|
||||
* included in an IPP "job-media-sheets-supported" attribute. See class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of canonical array form. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobMediaSheetsSupported extends SetOfIntegerSyntax
|
||||
implements SupportedValuesAttribute {
|
||||
|
||||
private static final long serialVersionUID = 2953685470388672940L;
|
||||
|
||||
/**
|
||||
* Construct a new job media sheets supported attribute containing a single
|
||||
* range of integers. That is, only those values of JobMediaSheets in the
|
||||
* one range are supported.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if a null range is specified or if a
|
||||
* non-null range is specified with <CODE>lowerBound</CODE> less than
|
||||
* 0.
|
||||
*/
|
||||
public JobMediaSheetsSupported(int lowerBound, int upperBound) {
|
||||
super (lowerBound, upperBound);
|
||||
if (lowerBound > upperBound) {
|
||||
throw new IllegalArgumentException("Null range specified");
|
||||
} else if (lowerBound < 0) {
|
||||
throw new IllegalArgumentException
|
||||
("Job K octets value < 0 specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job media sheets supported attribute is equivalent
|
||||
* to the passed in object. To be equivalent, all of the following
|
||||
* conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobMediaSheetsSupported.
|
||||
* <LI>
|
||||
* This job media sheets supported attribute's members and
|
||||
* <CODE>object</CODE>'s members are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job media
|
||||
* sheets supported attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof JobMediaSheetsSupported);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobMediaSheetsSupported, the
|
||||
* category is class JobMediaSheetsSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobMediaSheetsSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobMediaSheetsSupported, the
|
||||
* category name is <CODE>"job-media-sheets-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-media-sheets-supported";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobMessageFromOperator is a printing attribute class, a text attribute,
|
||||
* that provides a message from an operator, system administrator, or
|
||||
* "intelligent" process to indicate to the end user the reasons for
|
||||
* modification or other management action taken on a job.
|
||||
* <P>
|
||||
* A Print Job's attribute set includes zero instances or one instance of a
|
||||
* JobMessageFromOperator attribute, not more than one instance. A new
|
||||
* JobMessageFromOperator attribute replaces an existing JobMessageFromOperator
|
||||
* attribute, if any. In other words, JobMessageFromOperator is not intended to
|
||||
* be a history log. If it wishes, the client can detect changes to a Print
|
||||
* Job's JobMessageFromOperator attribute and maintain the client's own history
|
||||
* log of the JobMessageFromOperator attribute values.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobMessageFromOperator extends TextSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -4620751846003142047L;
|
||||
|
||||
/**
|
||||
* Constructs a new job message from operator attribute with the given
|
||||
* message and locale.
|
||||
*
|
||||
* @param message Message.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>message</CODE> is null.
|
||||
*/
|
||||
public JobMessageFromOperator(String message, Locale locale) {
|
||||
super (message, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job message from operator attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobMessageFromOperator.
|
||||
* <LI>
|
||||
* This job message from operator attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This job message from operator attribute's locale and
|
||||
* <CODE>object</CODE>'s locale are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* message from operator attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof JobMessageFromOperator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobMessageFromOperator, the
|
||||
* category is class JobMessageFromOperator itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobMessageFromOperator.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobMessageFromOperator, the
|
||||
* category name is <CODE>"job-message-from-operator"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-message-from-operator";
|
||||
}
|
||||
|
||||
}
|
||||
125
jdkSrc/jdk8/javax/print/attribute/standard/JobName.java
Normal file
125
jdkSrc/jdk8/javax/print/attribute/standard/JobName.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobName is a printing attribute class, a text attribute, that specifies
|
||||
* the name of a print job. A job's name is an arbitrary string defined by the
|
||||
* client. It does not need to be unique between different jobs. A Print Job's
|
||||
* JobName attribute is set to the value supplied by the client in the Print
|
||||
* Request's attribute set. If, however, the client does not supply a JobName
|
||||
* attribute in the Print Request, the printer, when it creates the Print Job,
|
||||
* must generate a JobName. The printer should generate the value of the Print
|
||||
* Job's JobName attribute from the first of the following sources that produces
|
||||
* a value: (1) the {@link DocumentName DocumentName} attribute of the first (or
|
||||
* only) doc in the job, (2) the URL of the first (or only) doc in the job, if
|
||||
* the doc's print data representation object is a URL, or (3) any other piece
|
||||
* of Print Job specific and/or document content information.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobName extends TextSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 4660359192078689545L;
|
||||
|
||||
/**
|
||||
* Constructs a new job name attribute with the given job name and locale.
|
||||
*
|
||||
* @param jobName Job name.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>jobName</CODE> is null.
|
||||
*/
|
||||
public JobName(String jobName, Locale locale) {
|
||||
super (jobName, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job name attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobName.
|
||||
* <LI>
|
||||
* This job name attribute's underlying string and <CODE>object</CODE>'s
|
||||
* underlying string are equal.
|
||||
* <LI>
|
||||
* This job name attribute's locale and <CODE>object</CODE>'s locale are
|
||||
* equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job name
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof JobName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobName, the category is class JobName itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobName.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobName, the category name is <CODE>"job-name"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-name";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobOriginatingUserName is a printing attribute class, a text
|
||||
* attribute, that contains the name of the end user that submitted the
|
||||
* print job. If possible, the printer sets this attribute to the most
|
||||
* authenticated printable user name that it can obtain from the
|
||||
* authentication service that authenticated the submitted Print Request.
|
||||
* If such is not available, the printer uses the value of the
|
||||
* {@link RequestingUserName RequestingUserName}
|
||||
* attribute supplied by the client in the Print Request's attribute set.
|
||||
* If no authentication service is available, and the client did not supply
|
||||
* a {@link RequestingUserName RequestingUserName} attribute,
|
||||
* the printer sets the JobOriginatingUserName attribute to an empty
|
||||
* (zero-length) string.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobOriginatingUserName extends TextSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -8052537926362933477L;
|
||||
|
||||
/**
|
||||
* Constructs a new job originating user name attribute with the given
|
||||
* user name and locale.
|
||||
*
|
||||
* @param userName User name.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>userName</CODE> is null.
|
||||
*/
|
||||
public JobOriginatingUserName(String userName, Locale locale) {
|
||||
super (userName, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job originating user name attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobOriginatingUserName.
|
||||
* <LI>
|
||||
* This job originating user name attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This job originating user name attribute's locale and
|
||||
* <CODE>object</CODE>'s locale are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* originating user name attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof JobOriginatingUserName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobOriginatingUserName, the
|
||||
* category is class JobOriginatingUserName itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobOriginatingUserName.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobOriginatingUserName, the
|
||||
* category name is <CODE>"job-originating-user-name"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-originating-user-name";
|
||||
}
|
||||
|
||||
}
|
||||
127
jdkSrc/jdk8/javax/print/attribute/standard/JobPriority.java
Normal file
127
jdkSrc/jdk8/javax/print/attribute/standard/JobPriority.java
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobPriority is an integer valued printing attribute class that
|
||||
* specifies a print job's priority.
|
||||
* <P>
|
||||
* If a JobPriority attribute is specified for a Print Job, it specifies a
|
||||
* priority for scheduling the job. A higher value specifies a higher priority.
|
||||
* The value 1 indicates the lowest possible priority. The value 100 indicates
|
||||
* the highest possible priority. Among those jobs that are ready to print, a
|
||||
* printer must print all jobs with a priority value of <I>n</I> before printing
|
||||
* those with a priority value of <I>n</I>-1 for all <I>n.</I>
|
||||
* <P>
|
||||
* If the client does not specify a JobPriority attribute for a Print Job and
|
||||
* the printer does support the JobPriority attribute, the printer must use an
|
||||
* implementation-defined default JobPriority value.
|
||||
* <P>
|
||||
* The client can always specify any job priority value from 1 to 100 for a job.
|
||||
* However, a Print Service instance may support fewer than 100 different
|
||||
* job priority levels. If this is the case, the Print Service instance
|
||||
* automatically maps the client-specified job priority value to one of the
|
||||
* supported job priority levels, dividing the 100 job priority values equally
|
||||
* among the available job priority levels.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobPriority extends IntegerSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -4599900369040602769L;
|
||||
|
||||
/**
|
||||
* Construct a new job priority attribute with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1
|
||||
* or greater than 100.
|
||||
*/
|
||||
public JobPriority(int value) {
|
||||
super (value, 1, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job priority attribute is equivalent to the passed
|
||||
* in object. To be equivalent, all of the following conditions must be
|
||||
* true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobPriority.
|
||||
* <LI>
|
||||
* This job priority attribute's value and <CODE>object</CODE>'s value
|
||||
* are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* priority attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) && object instanceof JobPriority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobPriority, the category is class JobPriority itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobPriority.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobPriority, the category name is <CODE>"job-priority"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-priority";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.SupportedValuesAttribute;
|
||||
|
||||
/**
|
||||
* Class JobPrioritySupported is an integer valued printing attribute class
|
||||
* that specifies whether a Print Service instance supports the {@link
|
||||
* JobPriority JobPriority} attribute and the number of different job priority
|
||||
* levels supported.
|
||||
* <P>
|
||||
* The client can always specify any {@link JobPriority JobPriority} value
|
||||
* from 1 to 100 for a job. However, the Print Service instance may support
|
||||
* fewer than 100 different job priority levels. If this is the case, the
|
||||
* Print Service instance automatically maps the client-specified job priority
|
||||
* value to one of the supported job priority levels, dividing the 100 job
|
||||
* priority values equally among the available job priority levels.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value.
|
||||
* The category name returned by <CODE>getName()</CODE> gives the IPP
|
||||
* attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobPrioritySupported extends IntegerSyntax
|
||||
implements SupportedValuesAttribute {
|
||||
|
||||
private static final long serialVersionUID = 2564840378013555894L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new job priority supported attribute with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Number of different job priority levels supported.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1
|
||||
* or greater than 100.
|
||||
*/
|
||||
public JobPrioritySupported(int value) {
|
||||
super (value, 1, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this job priority supported attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class JobPrioritySupported.
|
||||
* <LI>
|
||||
* This job priority supported attribute's value and
|
||||
* <CODE>object</CODE>'s value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this job
|
||||
* priority supported attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals (Object object) {
|
||||
|
||||
return (super.equals(object) &&
|
||||
object instanceof JobPrioritySupported);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobPrioritySupported, the
|
||||
* category is class JobPrioritySupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobPrioritySupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobPrioritySupported, the
|
||||
* category name is <CODE>"job-priority-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-priority-supported";
|
||||
}
|
||||
|
||||
}
|
||||
134
jdkSrc/jdk8/javax/print/attribute/standard/JobSheets.java
Normal file
134
jdkSrc/jdk8/javax/print/attribute/standard/JobSheets.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobSheets is a printing attribute class, an enumeration, that
|
||||
* determines which job start and end sheets, if any, must be printed with a
|
||||
* job. Class JobSheets declares keywords for standard job sheets values.
|
||||
* Implementation- or site-defined names for a job sheets attribute may also be
|
||||
* created by defining a subclass of class JobSheets.
|
||||
* <P>
|
||||
* The effect of a JobSheets attribute on multidoc print jobs (jobs with
|
||||
* multiple documents) may be affected by the {@link MultipleDocumentHandling
|
||||
* MultipleDocumentHandling} job attribute, depending on the meaning of the
|
||||
* particular JobSheets value.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The
|
||||
* enumeration's integer value is the IPP enum value. The
|
||||
* <code>toString()</code> method returns the IPP string representation of
|
||||
* the attribute value. For a subclass, the attribute value must be
|
||||
* localized to give the IPP name and natural language values.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class JobSheets extends EnumSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -4735258056132519759L;
|
||||
|
||||
/**
|
||||
* No job sheets are printed.
|
||||
*/
|
||||
public static final JobSheets NONE = new JobSheets(0);
|
||||
|
||||
/**
|
||||
* One or more site specific standard job sheets are printed. e.g. a
|
||||
* single start sheet is printed, or both start and end sheets are
|
||||
* printed.
|
||||
*/
|
||||
public static final JobSheets STANDARD = new JobSheets(1);
|
||||
|
||||
/**
|
||||
* Construct a new job sheets enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected JobSheets(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"none",
|
||||
"standard"
|
||||
};
|
||||
|
||||
private static final JobSheets[] myEnumValueTable = {
|
||||
NONE,
|
||||
STANDARD
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class JobSheets.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class JobSheets.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobSheets and any vendor-defined subclasses, the category is
|
||||
* class JobSheets itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobSheets.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobSheets and any vendor-defined subclasses, the category
|
||||
* name is <CODE>"job-sheets"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-sheets";
|
||||
}
|
||||
|
||||
}
|
||||
237
jdkSrc/jdk8/javax/print/attribute/standard/JobState.java
Normal file
237
jdkSrc/jdk8/javax/print/attribute/standard/JobState.java
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* JobState is a printing attribute class, an enumeration, that identifies
|
||||
* the current state of a print job. Class JobState defines standard job state
|
||||
* values. A Print Service implementation only needs to report those job
|
||||
* states which are appropriate for the particular implementation; it does not
|
||||
* have to report every defined job state. The {@link JobStateReasons
|
||||
* JobStateReasons} attribute augments the JobState attribute to give more
|
||||
* detailed information about the job in the given job state.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
|
||||
public class JobState extends EnumSyntax implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 400465010094018920L;
|
||||
|
||||
/**
|
||||
* The job state is unknown.
|
||||
*/
|
||||
public static final JobState UNKNOWN = new JobState(0);
|
||||
|
||||
/**
|
||||
* The job is a candidate to start processing, but is not yet processing.
|
||||
*/
|
||||
public static final JobState PENDING = new JobState(3);
|
||||
|
||||
/**
|
||||
* The job is not a candidate for processing for any number of reasons but
|
||||
* will return to the PENDING state as soon as the reasons are no longer
|
||||
* present. The job's {@link JobStateReasons JobStateReasons} attribute must
|
||||
* indicate why the job is no longer a candidate for processing.
|
||||
*/
|
||||
public static final JobState PENDING_HELD = new JobState(4);
|
||||
|
||||
/**
|
||||
* The job is processing. One or more of the following activities is
|
||||
* occurring:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* The job is using, or is attempting to use, one or more purely software
|
||||
* processes that are analyzing, creating, or interpreting a PDL, etc.
|
||||
* <P>
|
||||
* <LI>
|
||||
* The job is using, or is attempting to use, one or more hardware
|
||||
* devices that are interpreting a PDL, making marks on a medium, and/or
|
||||
* performing finishing, such as stapling, etc.
|
||||
* <P>
|
||||
* <LI>
|
||||
* The printer has made the job ready for printing, but the output
|
||||
* device is not yet printing it, either because the job hasn't reached the
|
||||
* output device or because the job is queued in the output device or some
|
||||
* other spooler, awaiting the output device to print it.
|
||||
* </OL>
|
||||
* <P>
|
||||
* When the job is in the PROCESSING state, the entire job state includes
|
||||
* the detailed status represented in the printer's {@link PrinterState
|
||||
* PrinterState} and {@link PrinterStateReasons PrinterStateReasons}
|
||||
* attributes.
|
||||
* <P>
|
||||
* Implementations may, though they need not, include additional values in
|
||||
* the job's {@link JobStateReasons JobStateReasons} attribute to indicate
|
||||
* the progress of the job, such as adding the JOB_PRINTING value to
|
||||
* indicate when the output device is actually making marks on paper and/or
|
||||
* the PROCESSING_TO_STOP_POINT value to indicate that the printer is in the
|
||||
* process of canceling or aborting the job.
|
||||
*/
|
||||
public static final JobState PROCESSING = new JobState (5);
|
||||
|
||||
/**
|
||||
* The job has stopped while processing for any number of reasons and will
|
||||
* return to the PROCESSING state as soon as the reasons are no longer
|
||||
* present.
|
||||
* <P>
|
||||
* The job's {@link JobStateReasons JobStateReasons} attribute may indicate
|
||||
* why the job has stopped processing. For example, if the output device is
|
||||
* stopped, the PRINTER_STOPPED value may be included in the job's {@link
|
||||
* JobStateReasons JobStateReasons} attribute.
|
||||
* <P>
|
||||
* <I>Note:</I> When an output device is stopped, the device usually
|
||||
* indicates its condition in human readable form locally at the device. A
|
||||
* client can obtain more complete device status remotely by querying the
|
||||
* printer's {@link PrinterState PrinterState} and {@link
|
||||
* PrinterStateReasons PrinterStateReasons} attributes.
|
||||
*/
|
||||
public static final JobState PROCESSING_STOPPED = new JobState (6);
|
||||
|
||||
/**
|
||||
* The job has been canceled by some human agency, the printer has completed
|
||||
* canceling the job, and all job status attributes have reached their final
|
||||
* values for the job. While the printer is canceling the job, the job
|
||||
* remains in its current state, but the job's {@link JobStateReasons
|
||||
* JobStateReasons} attribute should contain the PROCESSING_TO_STOP_POINT
|
||||
* value and one of the CANCELED_BY_USER, CANCELED_BY_OPERATOR, or
|
||||
* CANCELED_AT_DEVICE values. When the job moves to the CANCELED state, the
|
||||
* PROCESSING_TO_STOP_POINT value, if present, must be removed, but the
|
||||
* CANCELED_BY_<I>xxx</I> value, if present, must remain.
|
||||
*/
|
||||
public static final JobState CANCELED = new JobState (7);
|
||||
|
||||
/**
|
||||
* The job has been aborted by the system (usually while the job was in the
|
||||
* PROCESSING or PROCESSING_STOPPED state), the printer has completed
|
||||
* aborting the job, and all job status attributes have reached their final
|
||||
* values for the job. While the printer is aborting the job, the job
|
||||
* remains in its current state, but the job's {@link JobStateReasons
|
||||
* JobStateReasons} attribute should contain the PROCESSING_TO_STOP_POINT
|
||||
* and ABORTED_BY_SYSTEM values. When the job moves to the ABORTED state,
|
||||
* the PROCESSING_TO_STOP_POINT value, if present, must be removed, but the
|
||||
* ABORTED_BY_SYSTEM value, if present, must remain.
|
||||
*/
|
||||
public static final JobState ABORTED = new JobState (8);
|
||||
|
||||
/**
|
||||
* The job has completed successfully or with warnings or errors after
|
||||
* processing, all of the job media sheets have been successfully stacked in
|
||||
* the appropriate output bin(s), and all job status attributes have reached
|
||||
* their final values for the job. The job's {@link JobStateReasons
|
||||
* JobStateReasons} attribute should contain one of these values:
|
||||
* COMPLETED_SUCCESSFULLY, COMPLETED_WITH_WARNINGS, or
|
||||
* COMPLETED_WITH_ERRORS.
|
||||
*/
|
||||
public static final JobState COMPLETED = new JobState (9);
|
||||
|
||||
// Hidden constructors.
|
||||
|
||||
/**
|
||||
* Construct a new job state enumeration value with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected JobState(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable =
|
||||
{"unknown",
|
||||
null,
|
||||
null,
|
||||
"pending",
|
||||
"pending-held",
|
||||
"processing",
|
||||
"processing-stopped",
|
||||
"canceled",
|
||||
"aborted",
|
||||
"completed"};
|
||||
|
||||
private static final JobState[] myEnumValueTable =
|
||||
{UNKNOWN,
|
||||
null,
|
||||
null,
|
||||
PENDING,
|
||||
PENDING_HELD,
|
||||
PROCESSING,
|
||||
PROCESSING_STOPPED,
|
||||
CANCELED,
|
||||
ABORTED,
|
||||
COMPLETED};
|
||||
|
||||
/**
|
||||
* Returns the string table for class JobState.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class JobState.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobState and any vendor-defined subclasses, the category is
|
||||
* class JobState itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobState.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobState and any vendor-defined subclasses, the category
|
||||
* name is <CODE>"job-state"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-state";
|
||||
}
|
||||
|
||||
}
|
||||
461
jdkSrc/jdk8/javax/print/attribute/standard/JobStateReason.java
Normal file
461
jdkSrc/jdk8/javax/print/attribute/standard/JobStateReason.java
Normal file
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.Attribute;
|
||||
|
||||
/**
|
||||
* Class JobStateReason is a printing attribute class, an enumeration, that
|
||||
* provides additional information about the job's current state, i.e.,
|
||||
* information that augments the value of the job's {@link JobState JobState}
|
||||
* attribute. Class JobStateReason defines standard job state reason values. A
|
||||
* Print Service implementation only needs to report those job state
|
||||
* reasons which are appropriate for the particular implementation; it does not
|
||||
* have to report every defined job state reason.
|
||||
* <P>
|
||||
* Instances of JobStateReason do not appear in a Print Job's attribute set
|
||||
* directly. Rather, a {@link JobStateReasons JobStateReasons} attribute appears
|
||||
* in the Print Job's attribute set. The {@link JobStateReasons JobStateReasons}
|
||||
* attribute contains zero, one, or more than one JobStateReason objects which
|
||||
* pertain to the Print Job's status. The printer adds a JobStateReason object
|
||||
* to the Print Job's {@link JobStateReasons JobStateReasons} attribute when the
|
||||
* corresponding condition becomes true of the Print Job, and the printer
|
||||
* removes the JobStateReason object again when the corresponding condition
|
||||
* becomes false, regardless of whether the Print Job's overall {@link JobState
|
||||
* JobState} also changed.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class JobStateReason extends EnumSyntax implements Attribute {
|
||||
|
||||
private static final long serialVersionUID = -8765894420449009168L;
|
||||
|
||||
/**
|
||||
* The printer has created the Print Job, but the printer has not finished
|
||||
* accessing or accepting all the print data yet.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_INCOMING = new JobStateReason(0);
|
||||
|
||||
/**
|
||||
* The printer has created the Print Job, but the printer is expecting
|
||||
* additional print data before it can move the job into the PROCESSING
|
||||
* state. If a printer starts processing before it has received all data,
|
||||
* the printer removes the JOB_DATA_INSUFFICIENT reason, but the
|
||||
* JOB_INCOMING reason remains. If a printer starts processing after it
|
||||
* has received all data, the printer removes the JOB_DATA_INSUFFICIENT
|
||||
* and JOB_INCOMING reasons at the same time.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_DATA_INSUFFICIENT = new JobStateReason(1);
|
||||
|
||||
/**
|
||||
* The Printer could not access one or more documents passed by reference
|
||||
* (i.e., the print data representation object is a URL). This reason is
|
||||
* intended to cover any file access problem,including file does not exist
|
||||
* and access denied because of an access control problem. Whether the
|
||||
* printer aborts the job and moves the job to the ABORTED job state or
|
||||
* prints all documents that are accessible and moves the job to the
|
||||
* COMPLETED job state and adds the COMPLETED_WITH_ERRORS reason to the
|
||||
* job's {@link JobStateReasons JobStateReasons} attribute depends on
|
||||
* implementation and/or site policy. This value should be supported if
|
||||
* the printer supports doc flavors with URL print data representation
|
||||
* objects.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
DOCUMENT_ACCESS_ERROR = new JobStateReason(2);
|
||||
|
||||
/**
|
||||
* The job was not completely submitted for some unforeseen reason.
|
||||
* Possibilities include (1) the printer has crashed before the job was
|
||||
* fully submitted by the client, (2) the printer or the document transfer
|
||||
* method has crashed in some non-recoverable way before the document data
|
||||
* was entirely transferred to the printer, (3) the client crashed before
|
||||
* the job was fully submitted.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
SUBMISSION_INTERRUPTED = new JobStateReason(3);
|
||||
|
||||
/**
|
||||
* The printer is transmitting the job to the output device.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_OUTGOING = new JobStateReason(4);
|
||||
|
||||
/**
|
||||
* The value of the job's {@link JobHoldUntil JobHoldUntil} attribute was
|
||||
* specified with a date-time that is still in the future. The job must
|
||||
* not be a candidate for processing until this reason is removed and
|
||||
* there are
|
||||
* no other reasons to hold the job. This value should be supported if the
|
||||
* {@link JobHoldUntil JobHoldUntil} job template attribute is supported.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_HOLD_UNTIL_SPECIFIED = new JobStateReason(5);
|
||||
|
||||
/**
|
||||
* At least one of the resources needed by the job, such as media, fonts,
|
||||
* resource objects, etc., is not ready on any of the physical printers
|
||||
* for which the job is a candidate. This condition may be detected
|
||||
* when the job is accepted, or subsequently while the job is pending
|
||||
* or processing, depending on implementation.
|
||||
* The job may remain in its current state or
|
||||
* be moved to the PENDING_HELD state, depending on implementation and/or
|
||||
* job scheduling policy.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
RESOURCES_ARE_NOT_READY = new JobStateReason(6);
|
||||
|
||||
/**
|
||||
* The value of the printer's {@link PrinterStateReasons
|
||||
* PrinterStateReasons} attribute contains a {@link PrinterStateReason
|
||||
* PrinterStateReason} value of STOPPED_PARTLY.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
PRINTER_STOPPED_PARTLY = new JobStateReason(7);
|
||||
|
||||
/**
|
||||
* The value of the printer's {@link PrinterState PrinterState} attribute
|
||||
* ia STOPPED.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
PRINTER_STOPPED = new JobStateReason(8);
|
||||
|
||||
/**
|
||||
* The job is in the PROCESSING state, but more specifically, the printer
|
||||
* ia interpreting the document data.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_INTERPRETING = new JobStateReason(9);
|
||||
|
||||
/**
|
||||
* The job is in the PROCESSING state, but more specifically, the printer
|
||||
* has queued the document data.
|
||||
*/
|
||||
public static final JobStateReason JOB_QUEUED = new JobStateReason(10);
|
||||
|
||||
/**
|
||||
* The job is in the PROCESSING state, but more specifically, the printer
|
||||
* is interpreting document data and producing another electronic
|
||||
* representation.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_TRANSFORMING = new JobStateReason(11);
|
||||
|
||||
/**
|
||||
* The job is in the PENDING_HELD, PENDING, or PROCESSING state, but more
|
||||
* specifically, the printer has completed enough processing of the document
|
||||
* to be able to start marking and the job is waiting for the marker.
|
||||
* Systems that require human intervention to release jobs put the job into
|
||||
* the PENDING_HELD job state. Systems that automatically select a job to
|
||||
* use the marker put the job into the PENDING job state or keep the job
|
||||
* in the PROCESSING job state while waiting for the marker, depending on
|
||||
* implementation. All implementations put the job into (or back into) the
|
||||
* PROCESSING state when marking does begin.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_QUEUED_FOR_MARKER = new JobStateReason(12);
|
||||
|
||||
/**
|
||||
* The output device is marking media. This value is useful for printers
|
||||
* which spend a great deal of time processing (1) when no marking is
|
||||
* happening and then want to show that marking is now happening or (2) when
|
||||
* the job is in the process of being canceled or aborted while the job
|
||||
* remains in the PROCESSING state, but the marking has not yet stopped so
|
||||
* that impression or sheet counts are still increasing for the job.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_PRINTING = new JobStateReason(13);
|
||||
|
||||
/**
|
||||
* The job was canceled by the owner of the job, i.e., by a user whose
|
||||
* authenticated identity is the same as the value of the originating user
|
||||
* that created the Print Job, or by some other authorized end-user, such as
|
||||
* a member of the job owner's security group. This value should be
|
||||
* supported.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_CANCELED_BY_USER = new JobStateReason(14);
|
||||
|
||||
/**
|
||||
* The job was canceled by the operator, i.e., by a user who has been
|
||||
* authenticated as having operator privileges (whether local or remote). If
|
||||
* the security policy is to allow anyone to cancel anyone's job, then this
|
||||
* value may be used when the job is canceled by someone other than the
|
||||
* owner of the job. For such a security policy, in effect, everyone is an
|
||||
* operator as far as canceling jobs is concerned. This value should be
|
||||
* supported if the implementation permits canceling by someone other than
|
||||
* the owner of the job.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_CANCELED_BY_OPERATOR = new JobStateReason(15);
|
||||
|
||||
/**
|
||||
* The job was canceled by an unidentified local user, i.e., a user at a
|
||||
* console at the device. This value should be supported if the
|
||||
* implementation supports canceling jobs at the console.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_CANCELED_AT_DEVICE = new JobStateReason(16);
|
||||
|
||||
/**
|
||||
* The job was aborted by the system. Either the job (1) is in the process
|
||||
* of being aborted, (2) has been aborted by the system and placed in the
|
||||
* ABORTED state, or (3) has been aborted by the system and placed in the
|
||||
* PENDING_HELD state, so that a user or operator can manually try the job
|
||||
* again. This value should be supported.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
ABORTED_BY_SYSTEM = new JobStateReason(17);
|
||||
|
||||
/**
|
||||
* The job was aborted by the system because the printer determined while
|
||||
* attempting to decompress the document's data that the compression is
|
||||
* actually not among those supported by the printer. This value must be
|
||||
* supported, since {@link Compression Compression} is a required doc
|
||||
* description attribute.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
UNSUPPORTED_COMPRESSION = new JobStateReason(18);
|
||||
|
||||
/**
|
||||
* The job was aborted by the system because the printer encountered an
|
||||
* error in the document data while decompressing it. If the printer posts
|
||||
* this reason, the document data has already passed any tests that would
|
||||
* have led to the UNSUPPORTED_COMPRESSION job state reason.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
COMPRESSION_ERROR = new JobStateReason(19);
|
||||
|
||||
/**
|
||||
* The job was aborted by the system because the document data's document
|
||||
* format (doc flavor) is not among those supported by the printer. If the
|
||||
* client specifies a doc flavor with a MIME type of
|
||||
* <CODE>"application/octet-stream"</CODE>, the printer may abort the job if
|
||||
* the printer cannot determine the document data's actual format through
|
||||
* auto-sensing (even if the printer supports the document format if
|
||||
* specified explicitly). This value must be supported, since a doc flavor
|
||||
* is required to be specified for each doc.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
UNSUPPORTED_DOCUMENT_FORMAT = new JobStateReason(20);
|
||||
|
||||
/**
|
||||
* The job was aborted by the system because the printer encountered an
|
||||
* error in the document data while processing it. If the printer posts this
|
||||
* reason, the document data has already passed any tests that would have
|
||||
* led to the UNSUPPORTED_DOCUMENT_FORMAT job state reason.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
DOCUMENT_FORMAT_ERROR = new JobStateReason(21);
|
||||
|
||||
/**
|
||||
* The requester has canceled the job or the printer has aborted the job,
|
||||
* but the printer is still performing some actions on the job until a
|
||||
* specified stop point occurs or job termination/cleanup is completed.
|
||||
* <P>
|
||||
* If the implementation requires some measurable time to cancel the job in
|
||||
* the PROCESSING or PROCESSING_STOPPED job states, the printer must use
|
||||
* this reason to indicate that the printer is still performing some actions
|
||||
* on the job while the job remains in the PROCESSING or PROCESSING_STOPPED
|
||||
* state. After all the job's job description attributes have stopped
|
||||
* incrementing, the printer moves the job from the PROCESSING state to the
|
||||
* CANCELED or ABORTED job states.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
PROCESSING_TO_STOP_POINT = new JobStateReason(22);
|
||||
|
||||
/**
|
||||
* The printer is off-line and accepting no jobs. All PENDING jobs are put
|
||||
* into the PENDING_HELD state. This situation could be true if the
|
||||
* service's or document transform's input is impaired or broken.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
SERVICE_OFF_LINE = new JobStateReason(23);
|
||||
|
||||
/**
|
||||
* The job completed successfully. This value should be supported.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_COMPLETED_SUCCESSFULLY = new JobStateReason(24);
|
||||
|
||||
/**
|
||||
* The job completed with warnings. This value should be supported if the
|
||||
* implementation detects warnings.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_COMPLETED_WITH_WARNINGS = new JobStateReason(25);
|
||||
|
||||
/**
|
||||
* The job completed with errors (and possibly warnings too). This value
|
||||
* should be supported if the implementation detects errors.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_COMPLETED_WITH_ERRORS = new JobStateReason(26);
|
||||
|
||||
/**
|
||||
* This job is retained and is currently able to be restarted. If
|
||||
* JOB_RESTARTABLE is contained in the job's {@link JobStateReasons
|
||||
* JobStateReasons} attribute, then the printer must accept a request to
|
||||
* restart that job. This value should be supported if restarting jobs is
|
||||
* supported. <I>[The capability for restarting jobs is not in the Java
|
||||
* Print Service API at present.]</I>
|
||||
*/
|
||||
public static final JobStateReason
|
||||
JOB_RESTARTABLE = new JobStateReason(27);
|
||||
|
||||
/**
|
||||
* The job has been forwarded to a device or print system that is unable to
|
||||
* send back status. The printer sets the job's {@link JobState JobState}
|
||||
* attribute to COMPLETED and adds the QUEUED_IN_DEVICE reason to the job's
|
||||
* {@link JobStateReasons JobStateReasons} attribute to indicate that the
|
||||
* printer has no additional information about the job and never will have
|
||||
* any better information.
|
||||
*/
|
||||
public static final JobStateReason
|
||||
QUEUED_IN_DEVICE = new JobStateReason(28);
|
||||
|
||||
/**
|
||||
* Construct a new job state reason enumeration value with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected JobStateReason(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"job-incoming",
|
||||
"job-data-insufficient",
|
||||
"document-access-error",
|
||||
"submission-interrupted",
|
||||
"job-outgoing",
|
||||
"job-hold-until-specified",
|
||||
"resources-are-not-ready",
|
||||
"printer-stopped-partly",
|
||||
"printer-stopped",
|
||||
"job-interpreting",
|
||||
"job-queued",
|
||||
"job-transforming",
|
||||
"job-queued-for-marker",
|
||||
"job-printing",
|
||||
"job-canceled-by-user",
|
||||
"job-canceled-by-operator",
|
||||
"job-canceled-at-device",
|
||||
"aborted-by-system",
|
||||
"unsupported-compression",
|
||||
"compression-error",
|
||||
"unsupported-document-format",
|
||||
"document-format-error",
|
||||
"processing-to-stop-point",
|
||||
"service-off-line",
|
||||
"job-completed-successfully",
|
||||
"job-completed-with-warnings",
|
||||
"job-completed-with-errors",
|
||||
"job-restartable",
|
||||
"queued-in-device"};
|
||||
|
||||
private static final JobStateReason[] myEnumValueTable = {
|
||||
JOB_INCOMING,
|
||||
JOB_DATA_INSUFFICIENT,
|
||||
DOCUMENT_ACCESS_ERROR,
|
||||
SUBMISSION_INTERRUPTED,
|
||||
JOB_OUTGOING,
|
||||
JOB_HOLD_UNTIL_SPECIFIED,
|
||||
RESOURCES_ARE_NOT_READY,
|
||||
PRINTER_STOPPED_PARTLY,
|
||||
PRINTER_STOPPED,
|
||||
JOB_INTERPRETING,
|
||||
JOB_QUEUED,
|
||||
JOB_TRANSFORMING,
|
||||
JOB_QUEUED_FOR_MARKER,
|
||||
JOB_PRINTING,
|
||||
JOB_CANCELED_BY_USER,
|
||||
JOB_CANCELED_BY_OPERATOR,
|
||||
JOB_CANCELED_AT_DEVICE,
|
||||
ABORTED_BY_SYSTEM,
|
||||
UNSUPPORTED_COMPRESSION,
|
||||
COMPRESSION_ERROR,
|
||||
UNSUPPORTED_DOCUMENT_FORMAT,
|
||||
DOCUMENT_FORMAT_ERROR,
|
||||
PROCESSING_TO_STOP_POINT,
|
||||
SERVICE_OFF_LINE,
|
||||
JOB_COMPLETED_SUCCESSFULLY,
|
||||
JOB_COMPLETED_WITH_WARNINGS,
|
||||
JOB_COMPLETED_WITH_ERRORS,
|
||||
JOB_RESTARTABLE,
|
||||
QUEUED_IN_DEVICE};
|
||||
|
||||
/**
|
||||
* Returns the string table for class JobStateReason.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class JobStateReason.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobStateReason and any vendor-defined subclasses, the
|
||||
* category is class JobStateReason itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobStateReason.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobStateReason and any vendor-defined subclasses, the
|
||||
* category name is <CODE>"job-state-reason"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-state-reason";
|
||||
}
|
||||
|
||||
}
|
||||
181
jdkSrc/jdk8/javax/print/attribute/standard/JobStateReasons.java
Normal file
181
jdkSrc/jdk8/javax/print/attribute/standard/JobStateReasons.java
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class JobStateReasons is a printing attribute class, a set of enumeration
|
||||
* values, that provides additional information about the job's current state,
|
||||
* i.e., information that augments the value of the job's {@link JobState
|
||||
* JobState} attribute.
|
||||
* <P>
|
||||
* Instances of {@link JobStateReason JobStateReason} do not appear in a Print
|
||||
* Job's attribute set directly. Rather, a JobStateReasons attribute appears in
|
||||
* the Print Job's attribute set. The JobStateReasons attribute contains zero,
|
||||
* one, or more than one {@link JobStateReason JobStateReason} objects which
|
||||
* pertain to the Print Job's status. The printer adds a {@link JobStateReason
|
||||
* JobStateReason} object to the Print Job's JobStateReasons attribute when the
|
||||
* corresponding condition becomes true of the Print Job, and the printer
|
||||
* removes the {@link JobStateReason JobStateReason} object again when the
|
||||
* corresponding condition becomes false, regardless of whether the Print Job's
|
||||
* overall {@link JobState JobState} also changed.
|
||||
* <P>
|
||||
* Class JobStateReasons inherits its implementation from class {@link
|
||||
* java.util.HashSet java.util.HashSet}. Unlike most printing attributes which
|
||||
* are immutable once constructed, class JobStateReasons is designed to be
|
||||
* mutable; you can add {@link JobStateReason JobStateReason} objects to an
|
||||
* existing JobStateReasons object and remove them again. However, like class
|
||||
* {@link java.util.HashSet java.util.HashSet}, class JobStateReasons is not
|
||||
* multiple thread safe. If a JobStateReasons object will be used by multiple
|
||||
* threads, be sure to synchronize its operations (e.g., using a synchronized
|
||||
* set view obtained from class {@link java.util.Collections
|
||||
* java.util.Collections}).
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value returned by each individual {@link
|
||||
* JobStateReason JobStateReason} object's <CODE>toString()</CODE> method gives
|
||||
* the IPP keyword value. The category name returned by <CODE>getName()</CODE>
|
||||
* gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class JobStateReasons
|
||||
extends HashSet<JobStateReason> implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 8849088261264331812L;
|
||||
|
||||
/**
|
||||
* Construct a new, empty job state reasons attribute; the underlying hash
|
||||
* set has the default initial capacity and load factor.
|
||||
*/
|
||||
public JobStateReasons() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new, empty job state reasons attribute; the underlying hash
|
||||
* set has the given initial capacity and the default load factor.
|
||||
*
|
||||
* @param initialCapacity Initial capacity.
|
||||
* @throws IllegalArgumentException if the initial capacity is less
|
||||
* than zero.
|
||||
*/
|
||||
public JobStateReasons(int initialCapacity) {
|
||||
super (initialCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new, empty job state reasons attribute; the underlying hash
|
||||
* set has the given initial capacity and load factor.
|
||||
*
|
||||
* @param initialCapacity Initial capacity.
|
||||
* @param loadFactor Load factor.
|
||||
* @throws IllegalArgumentException if the initial capacity is less
|
||||
* than zero.
|
||||
*/
|
||||
public JobStateReasons(int initialCapacity, float loadFactor) {
|
||||
super (initialCapacity, loadFactor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new job state reasons attribute that contains the same
|
||||
* {@link JobStateReason JobStateReason} objects as the given collection.
|
||||
* The underlying hash set's initial capacity and load factor are as
|
||||
* specified in the superclass constructor {@link
|
||||
* java.util.HashSet#HashSet(java.util.Collection)
|
||||
* HashSet(Collection)}.
|
||||
*
|
||||
* @param collection Collection to copy.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>collection</CODE> is null or
|
||||
* if any element in <CODE>collection</CODE> is null.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if any element in
|
||||
* <CODE>collection</CODE> is not an instance of class {@link
|
||||
* JobStateReason JobStateReason}.
|
||||
*/
|
||||
public JobStateReasons(Collection<JobStateReason> collection) {
|
||||
super (collection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified element to this job state reasons attribute if it is
|
||||
* not already present. The element to be added must be an instance of class
|
||||
* {@link JobStateReason JobStateReason}. If this job state reasons
|
||||
* attribute already contains the specified element, the call leaves this
|
||||
* job state reasons attribute unchanged and returns <tt>false</tt>.
|
||||
*
|
||||
* @param o Element to be added to this job state reasons attribute.
|
||||
*
|
||||
* @return <tt>true</tt> if this job state reasons attribute did not
|
||||
* already contain the specified element.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* (unchecked exception) Thrown if the specified element is null.
|
||||
* @throws ClassCastException
|
||||
* (unchecked exception) Thrown if the specified element is not an
|
||||
* instance of class {@link JobStateReason JobStateReason}.
|
||||
* @since 1.5
|
||||
*/
|
||||
public boolean add(JobStateReason o) {
|
||||
if (o == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return super.add ((JobStateReason) o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class JobStateReasons, the category is class JobStateReasons itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return JobStateReasons.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class JobStateReasons, the category
|
||||
* name is <CODE>"job-state-reasons"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "job-state-reasons";
|
||||
}
|
||||
|
||||
}
|
||||
123
jdkSrc/jdk8/javax/print/attribute/standard/Media.java
Normal file
123
jdkSrc/jdk8/javax/print/attribute/standard/Media.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class Media is a printing attribute class that specifies the
|
||||
* medium on which to print.
|
||||
* <p>
|
||||
* Media may be specified in different ways.
|
||||
* <ul>
|
||||
* <li> it may be specified by paper source - eg paper tray
|
||||
* <li> it may be specified by a standard size - eg "A4"
|
||||
* <li> it may be specified by a name - eg "letterhead"
|
||||
* </ul>
|
||||
* Each of these corresponds to the IPP "media" attribute.
|
||||
* The current API does not support describing media by characteristics
|
||||
* (eg colour, opacity).
|
||||
* This may be supported in a later revision of the specification.
|
||||
* <p>
|
||||
* A Media object is constructed with a value which represents
|
||||
* one of the ways in which the Media attribute can be specified.
|
||||
* <p>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Phil Race
|
||||
*/
|
||||
public abstract class Media extends EnumSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -2823970704630722439L;
|
||||
|
||||
/**
|
||||
* Constructs a new media attribute specified by name.
|
||||
*
|
||||
* @param value a value
|
||||
*/
|
||||
protected Media(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this media attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is of the same subclass of Media as this object.
|
||||
* <LI>
|
||||
* The values are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this media
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return(object != null && object instanceof Media &&
|
||||
object.getClass() == this.getClass() &&
|
||||
((Media)object).getValue() == this.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class Media and any vendor-defined subclasses, the category is
|
||||
* class Media itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return Media.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class Media and any vendor-defined subclasses, the category name is
|
||||
* <CODE>"media"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "media";
|
||||
}
|
||||
|
||||
}
|
||||
113
jdkSrc/jdk8/javax/print/attribute/standard/MediaName.java
Normal file
113
jdkSrc/jdk8/javax/print/attribute/standard/MediaName.java
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
|
||||
/**
|
||||
* Class MediaName is a subclass of Media, a printing attribute class (an
|
||||
* enumeration) that specifies the media for a print job as a name.
|
||||
* <P>
|
||||
* This attribute can be used instead of specifying MediaSize or MediaTray.
|
||||
* <p>
|
||||
* Class MediaName currently declares a few standard media names.
|
||||
* Implementation- or site-defined names for a media name attribute may also
|
||||
* be created by defining a subclass of class MediaName.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> MediaName is a representation class for
|
||||
* values of the IPP "media" attribute which names media.
|
||||
* <P>
|
||||
*
|
||||
*/
|
||||
public class MediaName extends Media implements Attribute {
|
||||
|
||||
private static final long serialVersionUID = 4653117714524155448L;
|
||||
|
||||
/**
|
||||
* white letter paper.
|
||||
*/
|
||||
public static final MediaName NA_LETTER_WHITE = new MediaName(0);
|
||||
|
||||
/**
|
||||
* letter transparency.
|
||||
*/
|
||||
public static final MediaName NA_LETTER_TRANSPARENT = new MediaName(1);
|
||||
|
||||
/**
|
||||
* white A4 paper.
|
||||
*/
|
||||
public static final MediaName ISO_A4_WHITE = new MediaName(2);
|
||||
|
||||
|
||||
/**
|
||||
* A4 transparency.
|
||||
*/
|
||||
public static final MediaName ISO_A4_TRANSPARENT= new MediaName(3);
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new media name enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected MediaName(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"na-letter-white",
|
||||
"na-letter-transparent",
|
||||
"iso-a4-white",
|
||||
"iso-a4-transparent"
|
||||
};
|
||||
|
||||
private static final MediaName[] myEnumValueTable = {
|
||||
NA_LETTER_WHITE,
|
||||
NA_LETTER_TRANSPARENT,
|
||||
ISO_A4_WHITE,
|
||||
ISO_A4_TRANSPARENT
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class MediaTray.
|
||||
* @return the String table.
|
||||
*/
|
||||
protected String[] getStringTable()
|
||||
{
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class MediaTray.
|
||||
* @return the enumeration value table.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
|
||||
/**
|
||||
* Class MediaPrintableArea is a printing attribute used to distinguish
|
||||
* the printable and non-printable areas of media.
|
||||
* <p>
|
||||
* The printable area is specified to be a rectangle, within the overall
|
||||
* dimensions of a media.
|
||||
* <p>
|
||||
* Most printers cannot print on the entire surface of the media, due
|
||||
* to printer hardware limitations. This class can be used to query
|
||||
* the acceptable values for a supposed print job, and to request an area
|
||||
* within the constraints of the printable area to be used in a print job.
|
||||
* <p>
|
||||
* To query for the printable area, a client must supply a suitable context.
|
||||
* Without specifying at the very least the size of the media being used
|
||||
* no meaningful value for printable area can be obtained.
|
||||
* <p>
|
||||
* The attribute is not described in terms of the distance from the edge
|
||||
* of the paper, in part to emphasise that this attribute is not independent
|
||||
* of a particular media, but must be described within the context of a
|
||||
* choice of other attributes. Additionally it is usually more convenient
|
||||
* for a client to use the printable area.
|
||||
* <p>
|
||||
* The hardware's minimum margins is not just a property of the printer,
|
||||
* but may be a function of the media size, orientation, media type, and
|
||||
* any specified finishings.
|
||||
* <code>PrintService</code> provides the method to query the supported
|
||||
* values of an attribute in a suitable context :
|
||||
* See {@link javax.print.PrintService#getSupportedAttributeValues(Class,DocFlavor, AttributeSet) PrintService.getSupportedAttributeValues()}
|
||||
* <p>
|
||||
* The rectangular printable area is defined thus:
|
||||
* The (x,y) origin is positioned at the top-left of the paper in portrait
|
||||
* mode regardless of the orientation specified in the requesting context.
|
||||
* For example a printable area for A4 paper in portrait or landscape
|
||||
* orientation will have height {@literal >} width.
|
||||
* <p>
|
||||
* A printable area attribute's values are stored
|
||||
* internally as integers in units of micrometers (µm), where 1 micrometer
|
||||
* = 10<SUP>-6</SUP> meter = 1/1000 millimeter = 1/25400 inch. This permits
|
||||
* dimensions to be represented exactly to a precision of 1/1000 mm (= 1
|
||||
* µm) or 1/100 inch (= 254 µm). If fractional inches are expressed in
|
||||
|
||||
* negative powers of two, this permits dimensions to be represented exactly to
|
||||
* a precision of 1/8 inch (= 3175 µm) but not 1/16 inch (because 1/16 inch
|
||||
|
||||
* does not equal an integral number of µm).
|
||||
* <p>
|
||||
* <B>IPP Compatibility:</B> MediaPrintableArea is not an IPP attribute.
|
||||
*/
|
||||
|
||||
public final class MediaPrintableArea
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private int x, y, w, h;
|
||||
private int units;
|
||||
|
||||
private static final long serialVersionUID = -1597171464050795793L;
|
||||
|
||||
/**
|
||||
* Value to indicate units of inches (in). It is actually the conversion
|
||||
* factor by which to multiply inches to yield µm (25400).
|
||||
*/
|
||||
public static final int INCH = 25400;
|
||||
|
||||
/**
|
||||
* Value to indicate units of millimeters (mm). It is actually the
|
||||
* conversion factor by which to multiply mm to yield µm (1000).
|
||||
*/
|
||||
public static final int MM = 1000;
|
||||
|
||||
/**
|
||||
* Constructs a MediaPrintableArea object from floating point values.
|
||||
* @param x printable x
|
||||
* @param y printable y
|
||||
* @param w printable width
|
||||
* @param h printable height
|
||||
* @param units in which the values are expressed.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* Thrown if {@code x < 0} or {@code y < 0}
|
||||
* or {@code w <= 0} or {@code h <= 0} or
|
||||
* {@code units < 1}.
|
||||
*/
|
||||
public MediaPrintableArea(float x, float y, float w, float h, int units) {
|
||||
if ((x < 0.0) || (y < 0.0) || (w <= 0.0) || (h <= 0.0) ||
|
||||
(units < 1)) {
|
||||
throw new IllegalArgumentException("0 or negative value argument");
|
||||
}
|
||||
|
||||
this.x = (int) (x * units + 0.5f);
|
||||
this.y = (int) (y * units + 0.5f);
|
||||
this.w = (int) (w * units + 0.5f);
|
||||
this.h = (int) (h * units + 0.5f);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a MediaPrintableArea object from integer values.
|
||||
* @param x printable x
|
||||
* @param y printable y
|
||||
* @param w printable width
|
||||
* @param h printable height
|
||||
* @param units in which the values are expressed.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* Thrown if {@code x < 0} or {@code y < 0}
|
||||
* or {@code w <= 0} or {@code h <= 0} or
|
||||
* {@code units < 1}.
|
||||
*/
|
||||
public MediaPrintableArea(int x, int y, int w, int h, int units) {
|
||||
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) ||
|
||||
(units < 1)) {
|
||||
throw new IllegalArgumentException("0 or negative value argument");
|
||||
}
|
||||
this.x = x * units;
|
||||
this.y = y * units;
|
||||
this.w = w * units;
|
||||
this.h = h * units;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printable area as an array of 4 values in the order
|
||||
* x, y, w, h. The values returned are in the given units.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @return printable area as array of x, y, w, h in the specified units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float[] getPrintableArea(int units) {
|
||||
return new float[] { getX(units), getY(units),
|
||||
getWidth(units), getHeight(units) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x location of the origin of the printable area in the
|
||||
* specified units.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @return x location of the origin of the printable area in the
|
||||
* specified units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float getX(int units) {
|
||||
return convertFromMicrometers(x, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the y location of the origin of the printable area in the
|
||||
* specified units.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @return y location of the origin of the printable area in the
|
||||
* specified units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float getY(int units) {
|
||||
return convertFromMicrometers(y, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of the printable area in the specified units.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @return width of the printable area in the specified units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float getWidth(int units) {
|
||||
return convertFromMicrometers(w, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of the printable area in the specified units.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
*
|
||||
* @return height of the printable area in the specified units.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public float getHeight(int units) {
|
||||
return convertFromMicrometers(h, units);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this media margins attribute is equivalent to the passed
|
||||
* in object.
|
||||
* To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class MediaPrintableArea.
|
||||
* <LI>
|
||||
* The origin and dimensions are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this media margins
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
boolean ret = false;
|
||||
if (object instanceof MediaPrintableArea) {
|
||||
MediaPrintableArea mm = (MediaPrintableArea)object;
|
||||
if (x == mm.x && y == mm.y && w == mm.w && h == mm.h) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class MediaPrintableArea, the category is
|
||||
* class MediaPrintableArea itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return MediaPrintableArea.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class MediaPrintableArea,
|
||||
* the category name is <CODE>"media-printable-area"</CODE>.
|
||||
* <p>This is not an IPP V1.1 attribute.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "media-printable-area";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string version of this rectangular size attribute in the
|
||||
* given units.
|
||||
*
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. {@link #INCH INCH} or
|
||||
* {@link #MM MM}.
|
||||
* @param unitsName
|
||||
* Units name string, e.g. <CODE>"in"</CODE> or <CODE>"mm"</CODE>. If
|
||||
* null, no units name is appended to the result.
|
||||
*
|
||||
* @return String version of this two-dimensional size attribute.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if {@code units < 1}.
|
||||
*/
|
||||
public String toString(int units, String unitsName) {
|
||||
if (unitsName == null) {
|
||||
unitsName = "";
|
||||
}
|
||||
float []vals = getPrintableArea(units);
|
||||
String str = "("+vals[0]+","+vals[1]+")->("+vals[2]+","+vals[3]+")";
|
||||
return str + unitsName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string version of this rectangular size attribute in mm.
|
||||
*/
|
||||
public String toString() {
|
||||
return(toString(MM, "mm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for this attribute.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return x + 37*y + 43*w + 47*h;
|
||||
}
|
||||
|
||||
private static float convertFromMicrometers(int x, int units) {
|
||||
if (units < 1) {
|
||||
throw new IllegalArgumentException("units is < 1");
|
||||
}
|
||||
return ((float)x) / ((float)units);
|
||||
}
|
||||
}
|
||||
856
jdkSrc/jdk8/javax/print/attribute/standard/MediaSize.java
Normal file
856
jdkSrc/jdk8/javax/print/attribute/standard/MediaSize.java
Normal file
@@ -0,0 +1,856 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.print.attribute.Size2DSyntax;
|
||||
import javax.print.attribute.Attribute;
|
||||
|
||||
/**
|
||||
* Class MediaSize is a two-dimensional size valued printing attribute class
|
||||
* that indicates the dimensions of the medium in a portrait orientation, with
|
||||
* the X dimension running along the bottom edge and the Y dimension running
|
||||
* along the left edge. Thus, the Y dimension must be greater than or equal to
|
||||
* the X dimension. Class MediaSize declares many standard media size
|
||||
* values, organized into nested classes for ISO, JIS, North American,
|
||||
* engineering, and other media.
|
||||
* <P>
|
||||
* MediaSize is not yet used to specify media. Its current role is
|
||||
* as a mapping for named media (see {@link MediaSizeName MediaSizeName}).
|
||||
* Clients can use the mapping method
|
||||
* <code>MediaSize.getMediaSizeForName(MediaSizeName)</code>
|
||||
* to find the physical dimensions of the MediaSizeName instances
|
||||
* enumerated in this API. This is useful for clients which need this
|
||||
* information to format {@literal &} paginate printing.
|
||||
* <P>
|
||||
*
|
||||
* @author Phil Race, Alan Kaminsky
|
||||
*/
|
||||
public class MediaSize extends Size2DSyntax implements Attribute {
|
||||
|
||||
private static final long serialVersionUID = -1967958664615414771L;
|
||||
|
||||
private MediaSizeName mediaName;
|
||||
|
||||
private static HashMap mediaMap = new HashMap(100, 10);
|
||||
|
||||
private static Vector sizeVector = new Vector(100, 10);
|
||||
|
||||
/**
|
||||
* Construct a new media size attribute from the given floating-point
|
||||
* values.
|
||||
*
|
||||
* @param x X dimension.
|
||||
* @param y Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
|
||||
* <CODE>Size2DSyntax.MM</CODE>.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
|
||||
* {@code units < 1} or {@code x > y}.
|
||||
*/
|
||||
public MediaSize(float x, float y,int units) {
|
||||
super (x, y, units);
|
||||
if (x > y) {
|
||||
throw new IllegalArgumentException("X dimension > Y dimension");
|
||||
}
|
||||
sizeVector.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new media size attribute from the given integer values.
|
||||
*
|
||||
* @param x X dimension.
|
||||
* @param y Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
|
||||
* <CODE>Size2DSyntax.MM</CODE>.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
|
||||
* {@code units < 1} or {@code x > y}.
|
||||
*/
|
||||
public MediaSize(int x, int y,int units) {
|
||||
super (x, y, units);
|
||||
if (x > y) {
|
||||
throw new IllegalArgumentException("X dimension > Y dimension");
|
||||
}
|
||||
sizeVector.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new media size attribute from the given floating-point
|
||||
* values.
|
||||
*
|
||||
* @param x X dimension.
|
||||
* @param y Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
|
||||
* <CODE>Size2DSyntax.MM</CODE>.
|
||||
* @param media a media name to associate with this MediaSize
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
|
||||
* {@code units < 1} or {@code x > y}.
|
||||
*/
|
||||
public MediaSize(float x, float y,int units, MediaSizeName media) {
|
||||
super (x, y, units);
|
||||
if (x > y) {
|
||||
throw new IllegalArgumentException("X dimension > Y dimension");
|
||||
}
|
||||
if (media != null && mediaMap.get(media) == null) {
|
||||
mediaName = media;
|
||||
mediaMap.put(mediaName, this);
|
||||
}
|
||||
sizeVector.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new media size attribute from the given integer values.
|
||||
*
|
||||
* @param x X dimension.
|
||||
* @param y Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
|
||||
* <CODE>Size2DSyntax.MM</CODE>.
|
||||
* @param media a media name to associate with this MediaSize
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or
|
||||
* {@code units < 1} or {@code x > y}.
|
||||
*/
|
||||
public MediaSize(int x, int y,int units, MediaSizeName media) {
|
||||
super (x, y, units);
|
||||
if (x > y) {
|
||||
throw new IllegalArgumentException("X dimension > Y dimension");
|
||||
}
|
||||
if (media != null && mediaMap.get(media) == null) {
|
||||
mediaName = media;
|
||||
mediaMap.put(mediaName, this);
|
||||
}
|
||||
sizeVector.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the media name, if any, for this size.
|
||||
*
|
||||
* @return the name for this media size, or null if no name was
|
||||
* associated with this size (an anonymous size).
|
||||
*/
|
||||
public MediaSizeName getMediaSizeName() {
|
||||
return mediaName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MediaSize for the specified named media.
|
||||
*
|
||||
* @param media - the name of the media for which the size is sought
|
||||
* @return size of the media, or null if this media is not associated
|
||||
* with any size.
|
||||
*/
|
||||
public static MediaSize getMediaSizeForName(MediaSizeName media) {
|
||||
return (MediaSize)mediaMap.get(media);
|
||||
}
|
||||
|
||||
/**
|
||||
* The specified dimensions are used to locate a matching MediaSize
|
||||
* instance from amongst all the standard MediaSize instances.
|
||||
* If there is no exact match, the closest match is used.
|
||||
* <p>
|
||||
* The MediaSize is in turn used to locate the MediaSizeName object.
|
||||
* This method may return null if the closest matching MediaSize
|
||||
* has no corresponding Media instance.
|
||||
* <p>
|
||||
* This method is useful for clients which have only dimensions and
|
||||
* want to find a Media which corresponds to the dimensions.
|
||||
* @param x - X dimension
|
||||
* @param y - Y dimension.
|
||||
* @param units
|
||||
* Unit conversion factor, e.g. <CODE>Size2DSyntax.INCH</CODE> or
|
||||
* <CODE>Size2DSyntax.MM</CODE>
|
||||
* @return MediaSizeName matching these dimensions, or null.
|
||||
* @exception IllegalArgumentException if {@code x <= 0},
|
||||
* {@code y <= 0}, or {@code units < 1}.
|
||||
*
|
||||
*/
|
||||
public static MediaSizeName findMedia(float x, float y, int units) {
|
||||
|
||||
MediaSize match = MediaSize.ISO.A4;
|
||||
|
||||
if (x <= 0.0f || y <= 0.0f || units < 1) {
|
||||
throw new IllegalArgumentException("args must be +ve values");
|
||||
}
|
||||
|
||||
double ls = x * x + y * y;
|
||||
double tmp_ls;
|
||||
float []dim;
|
||||
float diffx = x;
|
||||
float diffy = y;
|
||||
|
||||
for (int i=0; i < sizeVector.size() ; i++) {
|
||||
MediaSize mediaSize = (MediaSize)sizeVector.elementAt(i);
|
||||
dim = mediaSize.getSize(units);
|
||||
if (x == dim[0] && y == dim[1]) {
|
||||
match = mediaSize;
|
||||
break;
|
||||
} else {
|
||||
diffx = x - dim[0];
|
||||
diffy = y - dim[1];
|
||||
tmp_ls = diffx * diffx + diffy * diffy;
|
||||
if (tmp_ls < ls) {
|
||||
ls = tmp_ls;
|
||||
match = mediaSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match.getMediaSizeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this media size attribute is equivalent to the passed
|
||||
* in object.
|
||||
* To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class MediaSize.
|
||||
* <LI>
|
||||
* This media size attribute's X dimension is equal to
|
||||
* <CODE>object</CODE>'s X dimension.
|
||||
* <LI>
|
||||
* This media size attribute's Y dimension is equal to
|
||||
* <CODE>object</CODE>'s Y dimension.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this media size
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof MediaSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class MediaSize and any vendor-defined subclasses, the category is
|
||||
* class MediaSize itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return MediaSize.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class MediaSize and any vendor-defined subclasses, the category
|
||||
* name is <CODE>"media-size"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "media-size";
|
||||
}
|
||||
|
||||
/**
|
||||
* Class MediaSize.ISO includes {@link MediaSize MediaSize} values for ISO
|
||||
* media.
|
||||
* <P>
|
||||
*/
|
||||
public final static class ISO {
|
||||
/**
|
||||
* Specifies the ISO A0 size, 841 mm by 1189 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A0 = new MediaSize(841, 1189, Size2DSyntax.MM, MediaSizeName.ISO_A0);
|
||||
/**
|
||||
* Specifies the ISO A1 size, 594 mm by 841 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A1 = new MediaSize(594, 841, Size2DSyntax.MM, MediaSizeName.ISO_A1);
|
||||
/**
|
||||
* Specifies the ISO A2 size, 420 mm by 594 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A2 = new MediaSize(420, 594, Size2DSyntax.MM, MediaSizeName.ISO_A2);
|
||||
/**
|
||||
* Specifies the ISO A3 size, 297 mm by 420 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A3 = new MediaSize(297, 420, Size2DSyntax.MM, MediaSizeName.ISO_A3);
|
||||
/**
|
||||
* Specifies the ISO A4 size, 210 mm by 297 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A4 = new MediaSize(210, 297, Size2DSyntax.MM, MediaSizeName.ISO_A4);
|
||||
/**
|
||||
* Specifies the ISO A5 size, 148 mm by 210 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A5 = new MediaSize(148, 210, Size2DSyntax.MM, MediaSizeName.ISO_A5);
|
||||
/**
|
||||
* Specifies the ISO A6 size, 105 mm by 148 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A6 = new MediaSize(105, 148, Size2DSyntax.MM, MediaSizeName.ISO_A6);
|
||||
/**
|
||||
* Specifies the ISO A7 size, 74 mm by 105 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A7 = new MediaSize(74, 105, Size2DSyntax.MM, MediaSizeName.ISO_A7);
|
||||
/**
|
||||
* Specifies the ISO A8 size, 52 mm by 74 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A8 = new MediaSize(52, 74, Size2DSyntax.MM, MediaSizeName.ISO_A8);
|
||||
/**
|
||||
* Specifies the ISO A9 size, 37 mm by 52 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A9 = new MediaSize(37, 52, Size2DSyntax.MM, MediaSizeName.ISO_A9);
|
||||
/**
|
||||
* Specifies the ISO A10 size, 26 mm by 37 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A10 = new MediaSize(26, 37, Size2DSyntax.MM, MediaSizeName.ISO_A10);
|
||||
/**
|
||||
* Specifies the ISO B0 size, 1000 mm by 1414 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B0 = new MediaSize(1000, 1414, Size2DSyntax.MM, MediaSizeName.ISO_B0);
|
||||
/**
|
||||
* Specifies the ISO B1 size, 707 mm by 1000 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B1 = new MediaSize(707, 1000, Size2DSyntax.MM, MediaSizeName.ISO_B1);
|
||||
/**
|
||||
* Specifies the ISO B2 size, 500 mm by 707 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B2 = new MediaSize(500, 707, Size2DSyntax.MM, MediaSizeName.ISO_B2);
|
||||
/**
|
||||
* Specifies the ISO B3 size, 353 mm by 500 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B3 = new MediaSize(353, 500, Size2DSyntax.MM, MediaSizeName.ISO_B3);
|
||||
/**
|
||||
* Specifies the ISO B4 size, 250 mm by 353 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B4 = new MediaSize(250, 353, Size2DSyntax.MM, MediaSizeName.ISO_B4);
|
||||
/**
|
||||
* Specifies the ISO B5 size, 176 mm by 250 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B5 = new MediaSize(176, 250, Size2DSyntax.MM, MediaSizeName.ISO_B5);
|
||||
/**
|
||||
* Specifies the ISO B6 size, 125 mm by 176 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B6 = new MediaSize(125, 176, Size2DSyntax.MM, MediaSizeName.ISO_B6);
|
||||
/**
|
||||
* Specifies the ISO B7 size, 88 mm by 125 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B7 = new MediaSize(88, 125, Size2DSyntax.MM, MediaSizeName.ISO_B7);
|
||||
/**
|
||||
* Specifies the ISO B8 size, 62 mm by 88 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B8 = new MediaSize(62, 88, Size2DSyntax.MM, MediaSizeName.ISO_B8);
|
||||
/**
|
||||
* Specifies the ISO B9 size, 44 mm by 62 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B9 = new MediaSize(44, 62, Size2DSyntax.MM, MediaSizeName.ISO_B9);
|
||||
/**
|
||||
* Specifies the ISO B10 size, 31 mm by 44 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B10 = new MediaSize(31, 44, Size2DSyntax.MM, MediaSizeName.ISO_B10);
|
||||
/**
|
||||
* Specifies the ISO C3 size, 324 mm by 458 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
C3 = new MediaSize(324, 458, Size2DSyntax.MM, MediaSizeName.ISO_C3);
|
||||
/**
|
||||
* Specifies the ISO C4 size, 229 mm by 324 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
C4 = new MediaSize(229, 324, Size2DSyntax.MM, MediaSizeName.ISO_C4);
|
||||
/**
|
||||
* Specifies the ISO C5 size, 162 mm by 229 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
C5 = new MediaSize(162, 229, Size2DSyntax.MM, MediaSizeName.ISO_C5);
|
||||
/**
|
||||
* Specifies the ISO C6 size, 114 mm by 162 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
C6 = new MediaSize(114, 162, Size2DSyntax.MM, MediaSizeName.ISO_C6);
|
||||
/**
|
||||
* Specifies the ISO Designated Long size, 110 mm by 220 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
DESIGNATED_LONG = new MediaSize(110, 220, Size2DSyntax.MM,
|
||||
MediaSizeName.ISO_DESIGNATED_LONG);
|
||||
|
||||
/**
|
||||
* Hide all constructors.
|
||||
*/
|
||||
private ISO() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class MediaSize.JIS includes {@link MediaSize MediaSize} values for JIS
|
||||
* (Japanese) media. *
|
||||
*/
|
||||
public final static class JIS {
|
||||
|
||||
/**
|
||||
* Specifies the JIS B0 size, 1030 mm by 1456 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B0 = new MediaSize(1030, 1456, Size2DSyntax.MM, MediaSizeName.JIS_B0);
|
||||
/**
|
||||
* Specifies the JIS B1 size, 728 mm by 1030 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B1 = new MediaSize(728, 1030, Size2DSyntax.MM, MediaSizeName.JIS_B1);
|
||||
/**
|
||||
* Specifies the JIS B2 size, 515 mm by 728 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B2 = new MediaSize(515, 728, Size2DSyntax.MM, MediaSizeName.JIS_B2);
|
||||
/**
|
||||
* Specifies the JIS B3 size, 364 mm by 515 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B3 = new MediaSize(364, 515, Size2DSyntax.MM, MediaSizeName.JIS_B3);
|
||||
/**
|
||||
* Specifies the JIS B4 size, 257 mm by 364 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B4 = new MediaSize(257, 364, Size2DSyntax.MM, MediaSizeName.JIS_B4);
|
||||
/**
|
||||
* Specifies the JIS B5 size, 182 mm by 257 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B5 = new MediaSize(182, 257, Size2DSyntax.MM, MediaSizeName.JIS_B5);
|
||||
/**
|
||||
* Specifies the JIS B6 size, 128 mm by 182 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B6 = new MediaSize(128, 182, Size2DSyntax.MM, MediaSizeName.JIS_B6);
|
||||
/**
|
||||
* Specifies the JIS B7 size, 91 mm by 128 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B7 = new MediaSize(91, 128, Size2DSyntax.MM, MediaSizeName.JIS_B7);
|
||||
/**
|
||||
* Specifies the JIS B8 size, 64 mm by 91 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B8 = new MediaSize(64, 91, Size2DSyntax.MM, MediaSizeName.JIS_B8);
|
||||
/**
|
||||
* Specifies the JIS B9 size, 45 mm by 64 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B9 = new MediaSize(45, 64, Size2DSyntax.MM, MediaSizeName.JIS_B9);
|
||||
/**
|
||||
* Specifies the JIS B10 size, 32 mm by 45 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B10 = new MediaSize(32, 45, Size2DSyntax.MM, MediaSizeName.JIS_B10);
|
||||
/**
|
||||
* Specifies the JIS Chou ("long") #1 envelope size, 142 mm by 332 mm.
|
||||
*/
|
||||
public static final MediaSize CHOU_1 = new MediaSize(142, 332, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Chou ("long") #2 envelope size, 119 mm by 277 mm.
|
||||
*/
|
||||
public static final MediaSize CHOU_2 = new MediaSize(119, 277, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Chou ("long") #3 envelope size, 120 mm by 235 mm.
|
||||
*/
|
||||
public static final MediaSize CHOU_3 = new MediaSize(120, 235, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Chou ("long") #4 envelope size, 90 mm by 205 mm.
|
||||
*/
|
||||
public static final MediaSize CHOU_4 = new MediaSize(90, 205, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Chou ("long") #30 envelope size, 92 mm by 235 mm.
|
||||
*/
|
||||
public static final MediaSize CHOU_30 = new MediaSize(92, 235, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Chou ("long") #40 envelope size, 90 mm by 225 mm.
|
||||
*/
|
||||
public static final MediaSize CHOU_40 = new MediaSize(90, 225, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #0 envelope size, 287 mm by 382 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_0 = new MediaSize(287, 382, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #1 envelope size, 270 mm by 382 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_1 = new MediaSize(270, 382, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #2 envelope size, 240 mm by 332 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_2 = new MediaSize(240, 332, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #3 envelope size, 216 mm by 277 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_3 = new MediaSize(216, 277, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #4 envelope size, 197 mm by 267 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_4 = new MediaSize(197, 267, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #5 envelope size, 190 mm by 240 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_5 = new MediaSize(190, 240, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #6 envelope size, 162 mm by 229 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_6 = new MediaSize(162, 229, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #7 envelope size, 142 mm by 205 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_7 = new MediaSize(142, 205, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #8 envelope size, 119 mm by 197 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_8 = new MediaSize(119, 197, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_20 = new MediaSize(229, 324, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS Kaku ("square") A4 envelope size, 228 mm by 312 mm.
|
||||
*/
|
||||
public static final MediaSize KAKU_A4 = new MediaSize(228, 312, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #1 envelope size, 120 mm by 176 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_1 = new MediaSize(120, 176, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #2 envelope size, 114 mm by 162 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_2 = new MediaSize(114, 162, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #3 envelope size, 98 mm by 148 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_3 = new MediaSize(98, 148, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #4 envelope size, 105 mm by 235 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_4 = new MediaSize(105, 235, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #5 envelope size, 95 mm by 217 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_5 = new MediaSize(95, 217, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #6 envelope size, 98 mm by 190 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_6 = new MediaSize(98, 190, Size2DSyntax.MM);
|
||||
/**
|
||||
* Specifies the JIS You ("Western") #7 envelope size, 92 mm by 165 mm.
|
||||
*/
|
||||
public static final MediaSize YOU_7 = new MediaSize(92, 165, Size2DSyntax.MM);
|
||||
/**
|
||||
* Hide all constructors.
|
||||
*/
|
||||
private JIS() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class MediaSize.NA includes {@link MediaSize MediaSize} values for North
|
||||
* American media.
|
||||
*/
|
||||
public final static class NA {
|
||||
|
||||
/**
|
||||
* Specifies the North American letter size, 8.5 inches by 11 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
LETTER = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_LETTER);
|
||||
/**
|
||||
* Specifies the North American legal size, 8.5 inches by 14 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
LEGAL = new MediaSize(8.5f, 14.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_LEGAL);
|
||||
/**
|
||||
* Specifies the North American 5 inch by 7 inch paper.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_5X7 = new MediaSize(5, 7, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_5X7);
|
||||
/**
|
||||
* Specifies the North American 8 inch by 10 inch paper.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_8X10 = new MediaSize(8, 10, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_8X10);
|
||||
/**
|
||||
* Specifies the North American Number 9 business envelope size,
|
||||
* 3.875 inches by 8.875 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_NUMBER_9_ENVELOPE =
|
||||
new MediaSize(3.875f, 8.875f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_NUMBER_9_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American Number 10 business envelope size,
|
||||
* 4.125 inches by 9.5 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_NUMBER_10_ENVELOPE =
|
||||
new MediaSize(4.125f, 9.5f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_NUMBER_10_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American Number 11 business envelope size,
|
||||
* 4.5 inches by 10.375 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_NUMBER_11_ENVELOPE =
|
||||
new MediaSize(4.5f, 10.375f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_NUMBER_11_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American Number 12 business envelope size,
|
||||
* 4.75 inches by 11 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_NUMBER_12_ENVELOPE =
|
||||
new MediaSize(4.75f, 11.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_NUMBER_12_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American Number 14 business envelope size,
|
||||
* 5 inches by 11.5 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_NUMBER_14_ENVELOPE =
|
||||
new MediaSize(5.0f, 11.5f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_NUMBER_14_ENVELOPE);
|
||||
|
||||
/**
|
||||
* Specifies the North American 6 inch by 9 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_6X9_ENVELOPE = new MediaSize(6.0f, 9.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_6X9_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American 7 inch by 9 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_7X9_ENVELOPE = new MediaSize(7.0f, 9.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_7X9_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American 9 inch by 11 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_9x11_ENVELOPE = new MediaSize(9.0f, 11.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_9X11_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American 9 inch by 12 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_9x12_ENVELOPE = new MediaSize(9.0f, 12.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_9X12_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American 10 inch by 13 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_10x13_ENVELOPE = new MediaSize(10.0f, 13.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_10X13_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American 10 inch by 14 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_10x14_ENVELOPE = new MediaSize(10.0f, 14.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_10X14_ENVELOPE);
|
||||
/**
|
||||
* Specifies the North American 10 inch by 15 inch envelope size.
|
||||
*/
|
||||
public static final MediaSize
|
||||
NA_10X15_ENVELOPE = new MediaSize(10.0f, 15.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.NA_10X15_ENVELOPE);
|
||||
/**
|
||||
* Hide all constructors.
|
||||
*/
|
||||
private NA() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class MediaSize.Engineering includes {@link MediaSize MediaSize} values
|
||||
* for engineering media.
|
||||
*/
|
||||
public final static class Engineering {
|
||||
|
||||
/**
|
||||
* Specifies the engineering A size, 8.5 inch by 11 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
A = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.A);
|
||||
/**
|
||||
* Specifies the engineering B size, 11 inch by 17 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
B = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.B);
|
||||
/**
|
||||
* Specifies the engineering C size, 17 inch by 22 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
C = new MediaSize(17.0f, 22.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.C);
|
||||
/**
|
||||
* Specifies the engineering D size, 22 inch by 34 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
D = new MediaSize(22.0f, 34.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.D);
|
||||
/**
|
||||
* Specifies the engineering E size, 34 inch by 44 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
E = new MediaSize(34.0f, 44.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.E);
|
||||
/**
|
||||
* Hide all constructors.
|
||||
*/
|
||||
private Engineering() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class MediaSize.Other includes {@link MediaSize MediaSize} values for
|
||||
* miscellaneous media.
|
||||
*/
|
||||
public final static class Other {
|
||||
/**
|
||||
* Specifies the executive size, 7.25 inches by 10.5 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
EXECUTIVE = new MediaSize(7.25f, 10.5f, Size2DSyntax.INCH,
|
||||
MediaSizeName.EXECUTIVE);
|
||||
/**
|
||||
* Specifies the ledger size, 11 inches by 17 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
LEDGER = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.LEDGER);
|
||||
|
||||
/**
|
||||
* Specifies the tabloid size, 11 inches by 17 inches.
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final MediaSize
|
||||
TABLOID = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.TABLOID);
|
||||
|
||||
/**
|
||||
* Specifies the invoice size, 5.5 inches by 8.5 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
INVOICE = new MediaSize(5.5f, 8.5f, Size2DSyntax.INCH,
|
||||
MediaSizeName.INVOICE);
|
||||
/**
|
||||
* Specifies the folio size, 8.5 inches by 13 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
FOLIO = new MediaSize(8.5f, 13.0f, Size2DSyntax.INCH,
|
||||
MediaSizeName.FOLIO);
|
||||
/**
|
||||
* Specifies the quarto size, 8.5 inches by 10.83 inches.
|
||||
*/
|
||||
public static final MediaSize
|
||||
QUARTO = new MediaSize(8.5f, 10.83f, Size2DSyntax.INCH,
|
||||
MediaSizeName.QUARTO);
|
||||
/**
|
||||
* Specifies the Italy envelope size, 110 mm by 230 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
ITALY_ENVELOPE = new MediaSize(110, 230, Size2DSyntax.MM,
|
||||
MediaSizeName.ITALY_ENVELOPE);
|
||||
/**
|
||||
* Specifies the Monarch envelope size, 3.87 inch by 7.5 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, Size2DSyntax.INCH,
|
||||
MediaSizeName.MONARCH_ENVELOPE);
|
||||
/**
|
||||
* Specifies the Personal envelope size, 3.625 inch by 6.5 inch.
|
||||
*/
|
||||
public static final MediaSize
|
||||
PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, Size2DSyntax.INCH,
|
||||
MediaSizeName.PERSONAL_ENVELOPE);
|
||||
/**
|
||||
* Specifies the Japanese postcard size, 100 mm by 148 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
JAPANESE_POSTCARD = new MediaSize(100, 148, Size2DSyntax.MM,
|
||||
MediaSizeName.JAPANESE_POSTCARD);
|
||||
/**
|
||||
* Specifies the Japanese Double postcard size, 148 mm by 200 mm.
|
||||
*/
|
||||
public static final MediaSize
|
||||
JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, Size2DSyntax.MM,
|
||||
MediaSizeName.JAPANESE_DOUBLE_POSTCARD);
|
||||
/**
|
||||
* Hide all constructors.
|
||||
*/
|
||||
private Other() {
|
||||
}
|
||||
}
|
||||
|
||||
/* force loading of all the subclasses so that the instances
|
||||
* are created and inserted into the hashmap.
|
||||
*/
|
||||
static {
|
||||
MediaSize ISOA4 = ISO.A4;
|
||||
MediaSize JISB5 = JIS.B5;
|
||||
MediaSize NALETTER = NA.LETTER;
|
||||
MediaSize EngineeringC = Engineering.C;
|
||||
MediaSize OtherEXECUTIVE = Other.EXECUTIVE;
|
||||
}
|
||||
}
|
||||
565
jdkSrc/jdk8/javax/print/attribute/standard/MediaSizeName.java
Normal file
565
jdkSrc/jdk8/javax/print/attribute/standard/MediaSizeName.java
Normal file
@@ -0,0 +1,565 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.Attribute;
|
||||
|
||||
/**
|
||||
* Class MediaSizeName is a subclass of Media.
|
||||
* <P>
|
||||
* This attribute can be used instead of specifying MediaName or MediaTray.
|
||||
* <p>
|
||||
* Class MediaSizeName currently declares a few standard media
|
||||
* name values.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> MediaSizeName is a representation class for
|
||||
* values of the IPP "media" attribute which names media sizes.
|
||||
* The names of the media sizes correspond to those in the IPP 1.1 RFC
|
||||
* <a HREF="http://www.ietf.org/rfc/rfc2911.txt">RFC 2911</a>
|
||||
* <P>
|
||||
*
|
||||
*/
|
||||
public class MediaSizeName extends Media {
|
||||
|
||||
private static final long serialVersionUID = 2778798329756942747L;
|
||||
|
||||
/**
|
||||
* A0 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A0 = new MediaSizeName(0);
|
||||
/**
|
||||
* A1 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A1 = new MediaSizeName(1);
|
||||
/**
|
||||
* A2 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A2 = new MediaSizeName(2);
|
||||
/**
|
||||
* A3 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A3 = new MediaSizeName(3);
|
||||
/**
|
||||
* A4 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A4 = new MediaSizeName(4);
|
||||
/**
|
||||
* A5 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A5 = new MediaSizeName(5);
|
||||
/**
|
||||
* A6 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A6 = new MediaSizeName(6);
|
||||
/**
|
||||
* A7 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A7 = new MediaSizeName(7);
|
||||
/**
|
||||
* A8 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A8 = new MediaSizeName(8);
|
||||
/**
|
||||
* A9 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A9 = new MediaSizeName(9);
|
||||
/**
|
||||
* A10 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_A10 = new MediaSizeName(10);
|
||||
|
||||
/**
|
||||
* ISO B0 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B0 = new MediaSizeName(11);
|
||||
/**
|
||||
* ISO B1 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B1 = new MediaSizeName(12);
|
||||
/**
|
||||
* ISO B2 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B2 = new MediaSizeName(13);
|
||||
/**
|
||||
* ISO B3 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B3 = new MediaSizeName(14);
|
||||
/**
|
||||
* ISO B4 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B4 = new MediaSizeName(15);
|
||||
/**
|
||||
* ISO B5 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B5 = new MediaSizeName(16);
|
||||
/**
|
||||
* ISO B6 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B6 = new MediaSizeName(17);
|
||||
/**
|
||||
* ISO B7 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B7 = new MediaSizeName(18);
|
||||
/**
|
||||
* ISO B8 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B8 = new MediaSizeName(19);
|
||||
/**
|
||||
* ISO B9 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B9 = new MediaSizeName(20);
|
||||
/**
|
||||
* ISO B10 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_B10 = new MediaSizeName(21);
|
||||
|
||||
/**
|
||||
* JIS B0 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B0 = new MediaSizeName(22);
|
||||
/**
|
||||
* JIS B1 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B1 = new MediaSizeName(23);
|
||||
/**
|
||||
* JIS B2 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B2 = new MediaSizeName(24);
|
||||
/**
|
||||
* JIS B3 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B3 = new MediaSizeName(25);
|
||||
/**
|
||||
* JIS B4 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B4 = new MediaSizeName(26);
|
||||
/**
|
||||
* JIS B5 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B5 = new MediaSizeName(27);
|
||||
/**
|
||||
* JIS B6 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B6 = new MediaSizeName(28);
|
||||
/**
|
||||
* JIS B7 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B7 = new MediaSizeName(29);
|
||||
/**
|
||||
* JIS B8 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B8 = new MediaSizeName(30);
|
||||
/**
|
||||
* JIS B9 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B9 = new MediaSizeName(31);
|
||||
/**
|
||||
* JIS B10 size.
|
||||
*/
|
||||
public static final MediaSizeName JIS_B10 = new MediaSizeName(32);
|
||||
|
||||
/**
|
||||
* ISO C0 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C0 = new MediaSizeName(33);
|
||||
/**
|
||||
* ISO C1 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C1 = new MediaSizeName(34);
|
||||
/**
|
||||
* ISO C2 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C2 = new MediaSizeName(35);
|
||||
/**
|
||||
* ISO C3 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C3 = new MediaSizeName(36);
|
||||
/**
|
||||
* ISO C4 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C4 = new MediaSizeName(37);
|
||||
/**
|
||||
* ISO C5 size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C5 = new MediaSizeName(38);
|
||||
/**
|
||||
* letter size.
|
||||
*/
|
||||
public static final MediaSizeName ISO_C6 = new MediaSizeName(39);
|
||||
/**
|
||||
* letter size.
|
||||
*/
|
||||
public static final MediaSizeName NA_LETTER = new MediaSizeName(40);
|
||||
|
||||
/**
|
||||
* legal size .
|
||||
*/
|
||||
public static final MediaSizeName NA_LEGAL = new MediaSizeName(41);
|
||||
|
||||
/**
|
||||
* executive size .
|
||||
*/
|
||||
public static final MediaSizeName EXECUTIVE = new MediaSizeName(42);
|
||||
|
||||
/**
|
||||
* ledger size .
|
||||
*/
|
||||
public static final MediaSizeName LEDGER = new MediaSizeName(43);
|
||||
|
||||
/**
|
||||
* tabloid size .
|
||||
*/
|
||||
public static final MediaSizeName TABLOID = new MediaSizeName(44);
|
||||
|
||||
/**
|
||||
* invoice size .
|
||||
*/
|
||||
public static final MediaSizeName INVOICE = new MediaSizeName(45);
|
||||
|
||||
/**
|
||||
* folio size .
|
||||
*/
|
||||
public static final MediaSizeName FOLIO = new MediaSizeName(46);
|
||||
|
||||
/**
|
||||
* quarto size .
|
||||
*/
|
||||
public static final MediaSizeName QUARTO = new MediaSizeName(47);
|
||||
|
||||
/**
|
||||
* Japanese Postcard size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
JAPANESE_POSTCARD = new MediaSizeName(48);
|
||||
/**
|
||||
* Japanese Double Postcard size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
JAPANESE_DOUBLE_POSTCARD = new MediaSizeName(49);
|
||||
|
||||
/**
|
||||
* A size .
|
||||
*/
|
||||
public static final MediaSizeName A = new MediaSizeName(50);
|
||||
|
||||
/**
|
||||
* B size .
|
||||
*/
|
||||
public static final MediaSizeName B = new MediaSizeName(51);
|
||||
|
||||
/**
|
||||
* C size .
|
||||
*/
|
||||
public static final MediaSizeName C = new MediaSizeName(52);
|
||||
|
||||
/**
|
||||
* D size .
|
||||
*/
|
||||
public static final MediaSizeName D = new MediaSizeName(53);
|
||||
|
||||
/**
|
||||
* E size .
|
||||
*/
|
||||
public static final MediaSizeName E = new MediaSizeName(54);
|
||||
|
||||
/**
|
||||
* ISO designated long size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
ISO_DESIGNATED_LONG = new MediaSizeName(55);
|
||||
|
||||
/**
|
||||
* Italy envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
ITALY_ENVELOPE = new MediaSizeName(56); // DESIGNATED_LONG?
|
||||
|
||||
/**
|
||||
* monarch envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
MONARCH_ENVELOPE = new MediaSizeName(57);
|
||||
/**
|
||||
* personal envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
PERSONAL_ENVELOPE = new MediaSizeName(58);
|
||||
/**
|
||||
* number 9 envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_NUMBER_9_ENVELOPE = new MediaSizeName(59);
|
||||
/**
|
||||
* number 10 envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_NUMBER_10_ENVELOPE = new MediaSizeName(60);
|
||||
/**
|
||||
* number 11 envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_NUMBER_11_ENVELOPE = new MediaSizeName(61);
|
||||
/**
|
||||
* number 12 envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_NUMBER_12_ENVELOPE = new MediaSizeName(62);
|
||||
/**
|
||||
* number 14 envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_NUMBER_14_ENVELOPE = new MediaSizeName(63);
|
||||
/**
|
||||
* 6x9 North American envelope size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_6X9_ENVELOPE = new MediaSizeName(64);
|
||||
/**
|
||||
* 7x9 North American envelope size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_7X9_ENVELOPE = new MediaSizeName(65);
|
||||
/**
|
||||
* 9x11 North American envelope size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_9X11_ENVELOPE = new MediaSizeName(66);
|
||||
/**
|
||||
* 9x12 North American envelope size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_9X12_ENVELOPE = new MediaSizeName(67);
|
||||
|
||||
/**
|
||||
* 10x13 North American envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_10X13_ENVELOPE = new MediaSizeName(68);
|
||||
/**
|
||||
* 10x14North American envelope size .
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_10X14_ENVELOPE = new MediaSizeName(69);
|
||||
/**
|
||||
* 10x15 North American envelope size.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_10X15_ENVELOPE = new MediaSizeName(70);
|
||||
|
||||
/**
|
||||
* 5x7 North American paper.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_5X7 = new MediaSizeName(71);
|
||||
|
||||
/**
|
||||
* 8x10 North American paper.
|
||||
*/
|
||||
public static final MediaSizeName
|
||||
NA_8X10 = new MediaSizeName(72);
|
||||
|
||||
/**
|
||||
* Construct a new media size enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected MediaSizeName(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"iso-a0",
|
||||
"iso-a1",
|
||||
"iso-a2",
|
||||
"iso-a3",
|
||||
"iso-a4",
|
||||
"iso-a5",
|
||||
"iso-a6",
|
||||
"iso-a7",
|
||||
"iso-a8",
|
||||
"iso-a9",
|
||||
"iso-a10",
|
||||
"iso-b0",
|
||||
"iso-b1",
|
||||
"iso-b2",
|
||||
"iso-b3",
|
||||
"iso-b4",
|
||||
"iso-b5",
|
||||
"iso-b6",
|
||||
"iso-b7",
|
||||
"iso-b8",
|
||||
"iso-b9",
|
||||
"iso-b10",
|
||||
"jis-b0",
|
||||
"jis-b1",
|
||||
"jis-b2",
|
||||
"jis-b3",
|
||||
"jis-b4",
|
||||
"jis-b5",
|
||||
"jis-b6",
|
||||
"jis-b7",
|
||||
"jis-b8",
|
||||
"jis-b9",
|
||||
"jis-b10",
|
||||
"iso-c0",
|
||||
"iso-c1",
|
||||
"iso-c2",
|
||||
"iso-c3",
|
||||
"iso-c4",
|
||||
"iso-c5",
|
||||
"iso-c6",
|
||||
"na-letter",
|
||||
"na-legal",
|
||||
"executive",
|
||||
"ledger",
|
||||
"tabloid",
|
||||
"invoice",
|
||||
"folio",
|
||||
"quarto",
|
||||
"japanese-postcard",
|
||||
"oufuko-postcard",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"d",
|
||||
"e",
|
||||
"iso-designated-long",
|
||||
"italian-envelope",
|
||||
"monarch-envelope",
|
||||
"personal-envelope",
|
||||
"na-number-9-envelope",
|
||||
"na-number-10-envelope",
|
||||
"na-number-11-envelope",
|
||||
"na-number-12-envelope",
|
||||
"na-number-14-envelope",
|
||||
"na-6x9-envelope",
|
||||
"na-7x9-envelope",
|
||||
"na-9x11-envelope",
|
||||
"na-9x12-envelope",
|
||||
"na-10x13-envelope",
|
||||
"na-10x14-envelope",
|
||||
"na-10x15-envelope",
|
||||
"na-5x7",
|
||||
"na-8x10",
|
||||
};
|
||||
|
||||
private static final MediaSizeName[] myEnumValueTable = {
|
||||
ISO_A0,
|
||||
ISO_A1,
|
||||
ISO_A2,
|
||||
ISO_A3,
|
||||
ISO_A4,
|
||||
ISO_A5,
|
||||
ISO_A6,
|
||||
ISO_A7,
|
||||
ISO_A8,
|
||||
ISO_A9,
|
||||
ISO_A10,
|
||||
ISO_B0,
|
||||
ISO_B1,
|
||||
ISO_B2,
|
||||
ISO_B3,
|
||||
ISO_B4,
|
||||
ISO_B5,
|
||||
ISO_B6,
|
||||
ISO_B7,
|
||||
ISO_B8,
|
||||
ISO_B9,
|
||||
ISO_B10,
|
||||
JIS_B0,
|
||||
JIS_B1,
|
||||
JIS_B2,
|
||||
JIS_B3,
|
||||
JIS_B4,
|
||||
JIS_B5,
|
||||
JIS_B6,
|
||||
JIS_B7,
|
||||
JIS_B8,
|
||||
JIS_B9,
|
||||
JIS_B10,
|
||||
ISO_C0,
|
||||
ISO_C1,
|
||||
ISO_C2,
|
||||
ISO_C3,
|
||||
ISO_C4,
|
||||
ISO_C5,
|
||||
ISO_C6,
|
||||
NA_LETTER,
|
||||
NA_LEGAL,
|
||||
EXECUTIVE,
|
||||
LEDGER,
|
||||
TABLOID,
|
||||
INVOICE,
|
||||
FOLIO,
|
||||
QUARTO,
|
||||
JAPANESE_POSTCARD,
|
||||
JAPANESE_DOUBLE_POSTCARD,
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
E,
|
||||
ISO_DESIGNATED_LONG,
|
||||
ITALY_ENVELOPE,
|
||||
MONARCH_ENVELOPE,
|
||||
PERSONAL_ENVELOPE,
|
||||
NA_NUMBER_9_ENVELOPE,
|
||||
NA_NUMBER_10_ENVELOPE,
|
||||
NA_NUMBER_11_ENVELOPE,
|
||||
NA_NUMBER_12_ENVELOPE,
|
||||
NA_NUMBER_14_ENVELOPE,
|
||||
NA_6X9_ENVELOPE,
|
||||
NA_7X9_ENVELOPE,
|
||||
NA_9X11_ENVELOPE,
|
||||
NA_9X12_ENVELOPE,
|
||||
NA_10X13_ENVELOPE,
|
||||
NA_10X14_ENVELOPE,
|
||||
NA_10X15_ENVELOPE,
|
||||
NA_5X7,
|
||||
NA_8X10,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the string table for class MediaSizeName.
|
||||
*/
|
||||
protected String[] getStringTable()
|
||||
{
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class MediaSizeName.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
140
jdkSrc/jdk8/javax/print/attribute/standard/MediaTray.java
Normal file
140
jdkSrc/jdk8/javax/print/attribute/standard/MediaTray.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
|
||||
|
||||
/**
|
||||
* Class MediaTray is a subclass of Media.
|
||||
* Class MediaTray is a printing attribute class, an enumeration, that
|
||||
* specifies the media tray or bin for the job.
|
||||
* This attribute can be used instead of specifying MediaSize or MediaName.
|
||||
* <p>
|
||||
* Class MediaTray declares keywords for standard media kind values.
|
||||
* Implementation- or site-defined names for a media kind attribute may also
|
||||
* be created by defining a subclass of class MediaTray.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> MediaTray is a representation class for
|
||||
* values of the IPP "media" attribute which name paper trays.
|
||||
* <P>
|
||||
*
|
||||
*/
|
||||
public class MediaTray extends Media implements Attribute {
|
||||
|
||||
private static final long serialVersionUID = -982503611095214703L;
|
||||
|
||||
/**
|
||||
* The top input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray TOP = new MediaTray(0);
|
||||
|
||||
/**
|
||||
* The middle input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray MIDDLE = new MediaTray(1);
|
||||
|
||||
/**
|
||||
* The bottom input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray BOTTOM = new MediaTray(2);
|
||||
|
||||
/**
|
||||
* The envelope input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray ENVELOPE = new MediaTray(3);
|
||||
|
||||
/**
|
||||
* The manual feed input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray MANUAL = new MediaTray(4);
|
||||
|
||||
/**
|
||||
* The large capacity input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray LARGE_CAPACITY = new MediaTray(5);
|
||||
|
||||
/**
|
||||
* The main input tray in the printer.
|
||||
*/
|
||||
public static final MediaTray MAIN = new MediaTray(6);
|
||||
|
||||
/**
|
||||
* The side input tray.
|
||||
*/
|
||||
public static final MediaTray SIDE = new MediaTray(7);
|
||||
|
||||
/**
|
||||
* Construct a new media tray enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected MediaTray(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable ={
|
||||
"top",
|
||||
"middle",
|
||||
"bottom",
|
||||
"envelope",
|
||||
"manual",
|
||||
"large-capacity",
|
||||
"main",
|
||||
"side"
|
||||
};
|
||||
|
||||
private static final MediaTray[] myEnumValueTable = {
|
||||
TOP,
|
||||
MIDDLE,
|
||||
BOTTOM,
|
||||
ENVELOPE,
|
||||
MANUAL,
|
||||
LARGE_CAPACITY,
|
||||
MAIN,
|
||||
SIDE
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class MediaTray.
|
||||
*/
|
||||
protected String[] getStringTable()
|
||||
{
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class MediaTray.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class MultipleDocumentHandling is a printing attribute class, an enumeration,
|
||||
* that controls finishing operations and the placement of one or more
|
||||
* print-stream pages into impressions and onto media sheets. When the value of
|
||||
* the {@link Copies Copies} attribute exceeds 1, MultipleDocumentHandling also
|
||||
* controls the order in which the copies that result from processing the
|
||||
* documents are produced. This attribute is relevant only for a multidoc print
|
||||
* job consisting of two or more individual docs.
|
||||
* <P>
|
||||
* Briefly, MultipleDocumentHandling determines the relationship between the
|
||||
* multiple input (electronic) documents fed into a multidoc print job and the
|
||||
* output (physical) document or documents produced by the multidoc print job.
|
||||
* There are two possibilities:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* The multiple input documents are combined into a single output document.
|
||||
* Finishing operations ({@link Finishings Finishings}),
|
||||
* are performed on this single output
|
||||
* document. The {@link Copies Copies} attribute tells how many copies of this
|
||||
* single output document to produce. The MultipleDocumentHandling values
|
||||
* SINGLE_DOCUMENT and SINGLE_DOCUMENT_NEW_SHEET specify two variations of
|
||||
* this possibility.
|
||||
* <P>
|
||||
* <LI>
|
||||
* The multiple input documents remain separate output documents. Finishing
|
||||
* operations ({@link Finishings Finishings}),
|
||||
* are performed on each output document
|
||||
* separately. The {@link Copies Copies} attribute tells how many copies of each
|
||||
* separate output document to produce. The MultipleDocumentHandling values
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES and SEPARATE_DOCUMENTS_COLLATED_COPIES
|
||||
* specify two variations of this possibility.
|
||||
* </UL>
|
||||
* <P>
|
||||
* In the detailed explanations below, if "<CODE>a</CODE>" represents an
|
||||
* instance of document data, then the result of processing the data in
|
||||
* document "<CODE>a</CODE>" is a sequence of media sheets represented by
|
||||
* "<CODE>a(*)</CODE>".
|
||||
* <P>
|
||||
* The standard MultipleDocumentHandling values are:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* <A NAME="sdfi">{@link #SINGLE_DOCUMENT
|
||||
* <B>SINGLE_DOCUMENT</B>}</A>. If a print job has multiple
|
||||
* documents -- say, the document data is called <CODE>a</CODE> and
|
||||
* <CODE>b</CODE> -- then the result of processing all the document data
|
||||
* (<CODE>a</CODE> and then <CODE>b</CODE>) must be treated as a single sequence
|
||||
* of media sheets for finishing operations; that is, finishing would be
|
||||
* performed on the concatenation of the sequences <CODE>a(*),b(*)</CODE>. The
|
||||
* printer must not force the data in each document instance to be formatted
|
||||
* onto a new print-stream page, nor to start a new impression on a new media
|
||||
* sheet. If more than one copy is made, the ordering of the sets of media
|
||||
* sheets resulting from processing the document data must be
|
||||
* <CODE>a(*),b(*),a(*),b(*),...</CODE>, and the printer object must force
|
||||
* each copy (<CODE>a(*),b(*)</CODE>) to start on a new media sheet.
|
||||
* <P>
|
||||
* <LI>
|
||||
* <A NAME="sducfi">{@link #SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
|
||||
* <B>SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</B>}</A>. If a print job
|
||||
* has multiple documents -- say, the document data is called <CODE>a</CODE> and
|
||||
* <CODE>b</CODE> -- then the result of processing the data in each document
|
||||
* instance must be treated as a single sequence of media sheets for finishing
|
||||
* operations; that is, the sets <CODE>a(*)</CODE> and <CODE>b(*)</CODE> would
|
||||
* each be finished separately. The printer must force each copy of the result
|
||||
* of processing the data in a single document to start on a new media sheet.
|
||||
* If more than one copy is made, the ordering of the sets of media sheets
|
||||
* resulting from processing the document data must be
|
||||
* <CODE>a(*),a(*),...,b(*),b(*)...</CODE>.
|
||||
* <P>
|
||||
* <LI>
|
||||
* <A NAME="sdccfi">{@link #SEPARATE_DOCUMENTS_COLLATED_COPIES
|
||||
* <B>SEPARATE_DOCUMENTS_COLLATED_COPIES</B>}</A>. If a print job
|
||||
* has multiple documents -- say, the document data is called <CODE>a</CODE> and
|
||||
* <CODE>b</CODE> -- then the result of processing the data in each document
|
||||
* instance must be treated as a single sequence of media sheets for finishing
|
||||
* operations; that is, the sets <CODE>a(*)</CODE> and <CODE>b(*)</CODE> would
|
||||
* each be finished separately. The printer must force each copy of the result
|
||||
* of processing the data in a single document to start on a new media sheet.
|
||||
* If more than one copy is made, the ordering of the sets of media sheets
|
||||
* resulting from processing the document data must be
|
||||
* <CODE>a(*),b(*),a(*),b(*),...</CODE>.
|
||||
* <P>
|
||||
* <LI>
|
||||
* <A NAME="sdnsfi">{@link #SINGLE_DOCUMENT_NEW_SHEET
|
||||
* <B>SINGLE_DOCUMENT_NEW_SHEET</B>}</A>. Same as SINGLE_DOCUMENT,
|
||||
* except that the printer must ensure that the first impression of each
|
||||
* document instance in the job is placed on a new media sheet. This value
|
||||
* allows multiple documents to be stapled together with a single staple where
|
||||
* each document starts on a new sheet.
|
||||
* </UL>
|
||||
* <P>
|
||||
* SINGLE_DOCUMENT is the same as SEPARATE_DOCUMENTS_COLLATED_COPIES with
|
||||
* respect to ordering of print-stream pages, but not media sheet generation,
|
||||
* since SINGLE_DOCUMENT will put the first page of the next document on the
|
||||
* back side of a sheet if an odd number of pages have been produced so far
|
||||
* for the job, while SEPARATE_DOCUMENTS_COLLATED_COPIES always forces the
|
||||
* next document or document copy on to a new sheet.
|
||||
* <P>
|
||||
* In addition, if a {@link Finishings Finishings} attribute of
|
||||
* {@link Finishings#STAPLE STAPLE} is specified, then:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* With SINGLE_DOCUMENT, documents <CODE>a</CODE> and <CODE>b</CODE> are
|
||||
* stapled together as a single document with no regard to new sheets.
|
||||
* <P>
|
||||
* <LI>
|
||||
* With SINGLE_DOCUMENT_NEW_SHEET, documents <CODE>a</CODE> and <CODE>b</CODE>
|
||||
* are stapled together as a single document, but document <CODE>b</CODE>
|
||||
* starts on a new sheet.
|
||||
* <P>
|
||||
* <LI>
|
||||
* With SEPARATE_DOCUMENTS_UNCOLLATED_COPIES and
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES, documents <CODE>a</CODE> and
|
||||
* <CODE>b</CODE> are stapled separately.
|
||||
* </UL>
|
||||
* <P>
|
||||
* <I>Note:</I> None of these values provide means to produce uncollated
|
||||
* sheets within a document, i.e., where multiple copies of sheet <I>n</I>
|
||||
* are produced before sheet <I>n</I>+1 of the same document.
|
||||
* To specify that, see the {@link SheetCollate SheetCollate} attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @see Copies
|
||||
* @see Finishings
|
||||
* @see NumberUp
|
||||
* @see PageRanges
|
||||
* @see SheetCollate
|
||||
* @see Sides
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class MultipleDocumentHandling extends EnumSyntax
|
||||
implements PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 8098326460746413466L;
|
||||
|
||||
|
||||
/**
|
||||
* Single document -- see above for <A HREF="#sdfi">further
|
||||
* information</A>.
|
||||
*/
|
||||
public static final MultipleDocumentHandling
|
||||
SINGLE_DOCUMENT = new MultipleDocumentHandling (0);
|
||||
|
||||
/**
|
||||
* Separate documents uncollated copies -- see above for
|
||||
* <A HREF="#sducfi">further information</A>.
|
||||
*/
|
||||
public static final MultipleDocumentHandling
|
||||
SEPARATE_DOCUMENTS_UNCOLLATED_COPIES = new MultipleDocumentHandling (1);
|
||||
|
||||
/**
|
||||
* Separate documents collated copies -- see above for
|
||||
* <A HREF="#sdccfi">further information</A>.
|
||||
*/
|
||||
public static final MultipleDocumentHandling
|
||||
SEPARATE_DOCUMENTS_COLLATED_COPIES = new MultipleDocumentHandling (2);
|
||||
|
||||
/**
|
||||
* Single document new sheet -- see above for
|
||||
* <A HREF="#sdnsfi">further information</A>.
|
||||
*/
|
||||
public static final MultipleDocumentHandling
|
||||
SINGLE_DOCUMENT_NEW_SHEET = new MultipleDocumentHandling (3);
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new multiple document handling enumeration value with the
|
||||
* given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected MultipleDocumentHandling(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"single-document",
|
||||
"separate-documents-uncollated-copies",
|
||||
"separate-documents-collated-copies",
|
||||
"single-document-new-sheet"
|
||||
};
|
||||
|
||||
private static final MultipleDocumentHandling[] myEnumValueTable = {
|
||||
SINGLE_DOCUMENT,
|
||||
SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
|
||||
SEPARATE_DOCUMENTS_COLLATED_COPIES,
|
||||
SINGLE_DOCUMENT_NEW_SHEET
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class MultipleDocumentHandling.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class MultipleDocumentHandling.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class MultipleDocumentHandling and any vendor-defined subclasses,
|
||||
* the category is class MultipleDocumentHandling itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return MultipleDocumentHandling.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class MultipleDocumentHandling and any vendor-defined subclasses,
|
||||
* the category name is <CODE>"multiple-document-handling"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "multiple-document-handling";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class NumberOfDocuments is an integer valued printing attribute that
|
||||
* indicates the number of individual docs the printer has accepted for this
|
||||
* job, regardless of whether the docs' print data has reached the printer or
|
||||
* not.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class NumberOfDocuments extends IntegerSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 7891881310684461097L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new number of documents attribute with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public NumberOfDocuments(int value) {
|
||||
super (value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this number of documents attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class NumberOfDocuments.
|
||||
* <LI>
|
||||
* This number of documents attribute's value and <CODE>object</CODE>'s
|
||||
* value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this number of
|
||||
* documents attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof NumberOfDocuments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class NumberOfDocuments, the
|
||||
* category is class NumberOfDocuments itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return NumberOfDocuments.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class NumberOfDocuments, the
|
||||
* category name is <CODE>"number-of-documents"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "number-of-documents";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class NumberOfInterveningJobs is an integer valued printing attribute that
|
||||
* indicates the number of jobs that are ahead of this job in the relative
|
||||
* chronological order of expected time to complete (i.e., the current
|
||||
* scheduled order).
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value.
|
||||
* The category name returned by <CODE>getName()</CODE> gives the IPP
|
||||
* attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class NumberOfInterveningJobs extends IntegerSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 2568141124844982746L;
|
||||
|
||||
/**
|
||||
* Construct a new number of intervening jobs attribute with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public NumberOfInterveningJobs(int value) {
|
||||
super(value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this number of intervening jobs attribute is equivalent
|
||||
* to the passed in object. To be equivalent, all of the following
|
||||
* conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class NumberOfInterveningJobs.
|
||||
* <LI>
|
||||
* This number of intervening jobs attribute's value and
|
||||
* <CODE>object</CODE>'s value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this number of
|
||||
* intervening jobs attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof NumberOfInterveningJobs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class NumberOfInterveningJobs, the
|
||||
* category is class NumberOfInterveningJobs itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return NumberOfInterveningJobs.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class NumberOfInterveningJobs, the
|
||||
* category name is <CODE>"number-of-intervening-jobs"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "number-of-intervening-jobs";
|
||||
}
|
||||
|
||||
}
|
||||
192
jdkSrc/jdk8/javax/print/attribute/standard/NumberUp.java
Normal file
192
jdkSrc/jdk8/javax/print/attribute/standard/NumberUp.java
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class NumberUp is an integer valued printing attribute class that specifies
|
||||
* the number of print-stream pages to impose upon a single side of an
|
||||
* instance of a selected medium. That is, if the NumberUp value is <I>n,</I>
|
||||
* the printer must place <I>n</I> print-stream pages on a single side of
|
||||
* an instance of the
|
||||
* selected medium. To accomplish this, the printer may add some sort of
|
||||
* translation, scaling, or rotation. This attribute primarily controls the
|
||||
* translation, scaling and rotation of print-stream pages.
|
||||
* <P>
|
||||
* The effect of a NumberUp attribute on a multidoc print job (a job with
|
||||
* multiple documents) depends on whether all the docs have the same number up
|
||||
* values specified or whether different docs have different number up values
|
||||
* specified, and on the (perhaps defaulted) value of the {@link
|
||||
* MultipleDocumentHandling MultipleDocumentHandling} attribute.
|
||||
* <UL>
|
||||
* <LI>
|
||||
* If all the docs have the same number up value <I>n</I> specified, then any
|
||||
* value of {@link MultipleDocumentHandling MultipleDocumentHandling} makes
|
||||
* sense, and the printer's processing depends on the {@link
|
||||
* MultipleDocumentHandling MultipleDocumentHandling} value:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT -- All the input docs will be combined together into one
|
||||
* output document. Each media impression will consist of <I>n</I>m
|
||||
* print-stream pages from the output document.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
|
||||
* into one output document. Each media impression will consist of <I>n</I>
|
||||
* print-stream pages from the output document. However, the first impression of
|
||||
* each input doc will always start on a new media sheet; this means the last
|
||||
* impression of an input doc may have fewer than <I>n</I> print-stream pages
|
||||
* on it.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
|
||||
* Each media impression will consist of <I>n</I> print-stream pages from the
|
||||
* input doc. Since the input docs are separate, the first impression of each
|
||||
* input doc will always start on a new media sheet; this means the last
|
||||
* impression of an input doc may have fewer than <I>n</I> print-stream pages on
|
||||
* it.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
|
||||
* Each media impression will consist of <I>n</I> print-stream pages from the
|
||||
* input doc. Since the input docs are separate, the first impression of each
|
||||
* input doc will always start on a new media sheet; this means the last
|
||||
* impression of an input doc may have fewer than <I>n</I> print-stream pages
|
||||
* on it.
|
||||
* </UL>
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT -- All the input docs will be combined together into one
|
||||
* output document. Each media impression will consist of <I>n<SUB>i</SUB></I>
|
||||
* print-stream pages from the output document, where <I>i</I> is the number of
|
||||
* the input doc corresponding to that point in the output document. When the
|
||||
* next input doc has a different number up value from the previous input doc,
|
||||
* the first print-stream page of the next input doc goes at the start of the
|
||||
* next media impression, possibly leaving fewer than the full number of
|
||||
* print-stream pages on the previous media impression.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
|
||||
* into one output document. Each media impression will consist of <I>n</I>
|
||||
* print-stream pages from the output document. However, the first impression of
|
||||
* each input doc will always start on a new media sheet; this means the last
|
||||
* impression of an input doc may have fewer than <I>n</I> print-stream pages
|
||||
* on it.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate.
|
||||
* For input doc <I>i,</I> each media impression will consist of
|
||||
* <I>n<SUB>i</SUB></I> print-stream pages from the input doc. Since the input
|
||||
* docs are separate, the first impression of each input doc will always start
|
||||
* on a new media sheet; this means the last impression of an input doc may have
|
||||
* fewer than <I>n<SUB>i</SUB></I> print-stream pages on it.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate.
|
||||
* For input doc <I>i,</I> each media impression will consist of
|
||||
* <I>n<SUB>i</SUB></I> print-stream pages from the input doc. Since the input
|
||||
* docs are separate, the first impression of each input doc will always start
|
||||
* on a new media sheet; this means the last impression of an input doc may
|
||||
* have fewer than <I>n<SUB>i</SUB></I> print-stream pages on it.
|
||||
* </UL>
|
||||
* </UL>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value.
|
||||
* The category name returned by <CODE>getName()</CODE> gives the IPP
|
||||
* attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class NumberUp extends IntegerSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -3040436486786527811L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new number up attribute with the given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 1.
|
||||
*/
|
||||
public NumberUp(int value) {
|
||||
super (value, 1, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this number up attribute is equivalent to the passed in
|
||||
* object. To be equivalent, all of the following conditions must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class NumberUp.
|
||||
* <LI>
|
||||
* This number up attribute's value and <CODE>object</CODE>'s value are
|
||||
* equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this number up
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof NumberUp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class NumberUp, the category is class NumberUp itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return NumberUp.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class NumberUp, the category name is <CODE>"number-up"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "number-up";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.SetOfIntegerSyntax;
|
||||
import javax.print.attribute.SupportedValuesAttribute;
|
||||
|
||||
/**
|
||||
* Class NumberUpSupported is a printing attribute class, a set of integers,
|
||||
* that gives the supported values for a {@link NumberUp NumberUp} attribute.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The NumberUpSupported attribute's canonical array
|
||||
* form gives the lower and upper bound for each range of number-up to be
|
||||
* included in an IPP "number-up-supported" attribute. See class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of canonical array form. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class NumberUpSupported extends SetOfIntegerSyntax
|
||||
implements SupportedValuesAttribute {
|
||||
|
||||
private static final long serialVersionUID = -1041573395759141805L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new number up supported attribute with the given members.
|
||||
* The supported values for NumberUp are specified in "array form;" see
|
||||
* class
|
||||
* {@link javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax}
|
||||
* for an explanation of array form.
|
||||
*
|
||||
* @param members Set members in array form.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>members</CODE> is null or
|
||||
* any element of <CODE>members</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>members</CODE> is not a length-one or length-two array. Also
|
||||
* thrown if <CODE>members</CODE> is a zero-length array or if any
|
||||
* member of the set is less than 1.
|
||||
*/
|
||||
public NumberUpSupported(int[][] members) {
|
||||
super (members);
|
||||
if (members == null) {
|
||||
throw new NullPointerException("members is null");
|
||||
}
|
||||
int[][] myMembers = getMembers();
|
||||
int n = myMembers.length;
|
||||
if (n == 0) {
|
||||
throw new IllegalArgumentException("members is zero-length");
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < n; ++ i) {
|
||||
if (myMembers[i][0] < 1) {
|
||||
throw new IllegalArgumentException
|
||||
("Number up value must be > 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new number up supported attribute containing a single
|
||||
* integer. That is, only the one value of NumberUp is supported.
|
||||
*
|
||||
* @param member Set member.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>member</CODE> is less than
|
||||
* 1.
|
||||
*/
|
||||
public NumberUpSupported(int member) {
|
||||
super (member);
|
||||
if (member < 1) {
|
||||
throw new IllegalArgumentException("Number up value must be > 0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new number up supported attribute containing a single range
|
||||
* of integers. That is, only those values of NumberUp in the one range are
|
||||
* supported.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if a null range is specified or if a
|
||||
* non-null range is specified with <CODE>lowerBound</CODE> less than
|
||||
* 1.
|
||||
*/
|
||||
public NumberUpSupported(int lowerBound, int upperBound) {
|
||||
super (lowerBound, upperBound);
|
||||
if (lowerBound > upperBound) {
|
||||
throw new IllegalArgumentException("Null range specified");
|
||||
} else if (lowerBound < 1) {
|
||||
throw new IllegalArgumentException
|
||||
("Number up value must be > 0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this number up supported attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class NumberUpSupported.
|
||||
* <LI>
|
||||
* This number up supported attribute's members and <CODE>object</CODE>'s
|
||||
* members are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this number up
|
||||
* supported attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof NumberUpSupported);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class NumberUpSupported, the
|
||||
* category is class NumberUpSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return NumberUpSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class NumberUpSupported, the
|
||||
* category name is <CODE>"number-up-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "number-up-supported";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class OrientationRequested is a printing attribute class, an enumeration,
|
||||
* that indicates the desired orientation for printed print-stream pages; it
|
||||
* does not describe the orientation of the client-supplied print-stream
|
||||
* pages.
|
||||
* <P>
|
||||
* For some document formats (such as <CODE>"application/postscript"</CODE>),
|
||||
* the desired orientation of the print-stream pages is specified within the
|
||||
* document data. This information is generated by a device driver prior to
|
||||
* the submission of the print job. Other document formats (such as
|
||||
* <CODE>"text/plain"</CODE>) do not include the notion of desired orientation
|
||||
* within the document data. In the latter case it is possible for the printer
|
||||
* to bind the desired orientation to the document data after it has been
|
||||
* submitted. It is expected that a printer would only support the
|
||||
* OrientationRequested attribute for some document formats (e.g.,
|
||||
* <CODE>"text/plain"</CODE> or <CODE>"text/html"</CODE>) but not others (e.g.
|
||||
* <CODE>"application/postscript"</CODE>). This is no different from any other
|
||||
* job template attribute, since a print job can always impose constraints
|
||||
* among the values of different job template attributes.
|
||||
* However, a special mention
|
||||
* is made here since it is very likely that a printer will support the
|
||||
* OrientationRequested attribute for only a subset of the supported document
|
||||
* formats.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class OrientationRequested extends EnumSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -4447437289862822276L;
|
||||
|
||||
/**
|
||||
* The content will be imaged across the short edge of the medium.
|
||||
*/
|
||||
public static final OrientationRequested
|
||||
PORTRAIT = new OrientationRequested(3);
|
||||
|
||||
/**
|
||||
* The content will be imaged across the long edge of the medium.
|
||||
* Landscape is defined to be a rotation of the print-stream page to be
|
||||
* imaged by +90 degrees with respect to the medium
|
||||
* (i.e. anti-clockwise) from the
|
||||
* portrait orientation. <I>Note:</I> The +90 direction was chosen because
|
||||
* simple finishing on the long edge is the same edge whether portrait or
|
||||
* landscape.
|
||||
*/
|
||||
public static final OrientationRequested
|
||||
LANDSCAPE = new OrientationRequested(4);
|
||||
|
||||
/**
|
||||
* The content will be imaged across the long edge of the medium, but in
|
||||
* the opposite manner from landscape. Reverse-landscape is defined to be
|
||||
* a rotation of the print-stream page to be imaged by -90 degrees with
|
||||
* respect to the medium (i.e. clockwise) from the portrait orientation.
|
||||
* <I>Note:</I> The REVERSE_LANDSCAPE value was added because some
|
||||
* applications rotate landscape -90 degrees from portrait, rather than
|
||||
* +90 degrees.
|
||||
*/
|
||||
public static final OrientationRequested
|
||||
REVERSE_LANDSCAPE = new OrientationRequested(5);
|
||||
|
||||
/**
|
||||
* The content will be imaged across the short edge of the medium, but in
|
||||
* the opposite manner from portrait. Reverse-portrait is defined to be a
|
||||
* rotation of the print-stream page to be imaged by 180 degrees with
|
||||
* respect to the medium from the portrait orientation. <I>Note:</I> The
|
||||
* REVERSE_PORTRAIT value was added for use with the {@link
|
||||
* Finishings Finishings} attribute in cases where the
|
||||
* opposite edge is desired for finishing a portrait document on simple
|
||||
* finishing devices that have only one finishing position. Thus a
|
||||
* <CODE>"text/plain"</CODE> portrait document can be stapled "on the
|
||||
* right" by a simple finishing device as is common use with some
|
||||
* Middle Eastern languages such as Hebrew.
|
||||
*/
|
||||
public static final OrientationRequested
|
||||
REVERSE_PORTRAIT = new OrientationRequested(6);
|
||||
|
||||
/**
|
||||
* Construct a new orientation requested enumeration value with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected OrientationRequested(int value) {
|
||||
super(value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"portrait",
|
||||
"landscape",
|
||||
"reverse-landscape",
|
||||
"reverse-portrait"
|
||||
};
|
||||
|
||||
private static final OrientationRequested[] myEnumValueTable = {
|
||||
PORTRAIT,
|
||||
LANDSCAPE,
|
||||
REVERSE_LANDSCAPE,
|
||||
REVERSE_PORTRAIT
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class OrientationRequested.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class OrientationRequested.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowest integer value used by class OrientationRequested.
|
||||
*/
|
||||
protected int getOffset() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class OrientationRequested, the
|
||||
* category is class OrientationRequested itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return OrientationRequested.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class OrientationRequested, the
|
||||
* category name is <CODE>"orientation-requested"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "orientation-requested";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class OutputDeviceAssigned is a printing attribute class, a text attribute,
|
||||
* that identifies the output device to which the service has assigned this
|
||||
* job. If an output device implements an embedded Print Service instance, the
|
||||
* printer need not set this attribute. If a print server implements a
|
||||
* Print Service instance, the value may be empty (zero- length string) or not
|
||||
* returned until the service assigns an output device to the job. This
|
||||
* attribute is particularly useful when a single service supports multiple
|
||||
* devices (so called "fan-out").
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class OutputDeviceAssigned extends TextSyntax
|
||||
implements PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 5486733778854271081L;
|
||||
|
||||
/**
|
||||
* Constructs a new output device assigned attribute with the given device
|
||||
* name and locale.
|
||||
*
|
||||
* @param deviceName Device name.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>deviceName</CODE> is null.
|
||||
*/
|
||||
public OutputDeviceAssigned(String deviceName, Locale locale) {
|
||||
|
||||
super (deviceName, locale);
|
||||
}
|
||||
|
||||
// Exported operations inherited and overridden from class Object.
|
||||
|
||||
/**
|
||||
* Returns whether this output device assigned attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class OutputDeviceAssigned.
|
||||
* <LI>
|
||||
* This output device assigned attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This output device assigned attribute's locale and
|
||||
* <CODE>object</CODE>'s locale are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this output
|
||||
* device assigned attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof OutputDeviceAssigned);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class OutputDeviceAssigned, the
|
||||
* category is class OutputDeviceAssigned itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return OutputDeviceAssigned.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class OutputDeviceAssigned, the
|
||||
* category name is <CODE>"output-device-assigned"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "output-device-assigned";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PDLOverrideSupported is a printing attribute class, an enumeration,
|
||||
* that expresses the printer's ability to attempt to override processing
|
||||
* instructions embedded in documents' print data with processing instructions
|
||||
* specified as attributes outside the print data.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class PDLOverrideSupported extends EnumSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = -4393264467928463934L;
|
||||
|
||||
/**
|
||||
* The printer makes no attempt to make the external job attribute values
|
||||
* take precedence over embedded instructions in the documents' print
|
||||
* data.
|
||||
*/
|
||||
public static final PDLOverrideSupported
|
||||
NOT_ATTEMPTED = new PDLOverrideSupported(0);
|
||||
|
||||
/**
|
||||
* The printer attempts to make the external job attribute values take
|
||||
* precedence over embedded instructions in the documents' print data,
|
||||
* however there is no guarantee.
|
||||
*/
|
||||
public static final PDLOverrideSupported
|
||||
ATTEMPTED = new PDLOverrideSupported(1);
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new PDL override supported enumeration value with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected PDLOverrideSupported(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"not-attempted",
|
||||
"attempted"
|
||||
};
|
||||
|
||||
private static final PDLOverrideSupported[] myEnumValueTable = {
|
||||
NOT_ATTEMPTED,
|
||||
ATTEMPTED
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class PDLOverrideSupported.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class PDLOverrideSupported.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PDLOverrideSupported and any vendor-defined subclasses, the
|
||||
* category is class PDLOverrideSupported itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PDLOverrideSupported.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PDLOverrideSupported and any vendor-defined subclasses, the
|
||||
* category name is <CODE>"pdl-override-supported"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "pdl-override-supported";
|
||||
}
|
||||
|
||||
}
|
||||
265
jdkSrc/jdk8/javax/print/attribute/standard/PageRanges.java
Normal file
265
jdkSrc/jdk8/javax/print/attribute/standard/PageRanges.java
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.SetOfIntegerSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class PageRanges is a printing attribute class, a set of integers, that
|
||||
* identifies the range(s) of print-stream pages that the Printer object uses
|
||||
* for each copy of each document which are to be printed. Nothing is printed
|
||||
* for any pages identified that do not exist in the document(s). The attribute
|
||||
* is associated with <I>print-stream</I> pages, not application-numbered pages
|
||||
* (for example, the page numbers found in the headers and or footers for
|
||||
* certain word processing applications).
|
||||
* <P>
|
||||
* In most cases, the exact pages to be printed will be generated by a device
|
||||
* driver and this attribute would not be required. However, when printing an
|
||||
* archived document which has already been formatted, the end user may elect to
|
||||
* print just a subset of the pages contained in the document. In this case, if
|
||||
* a page range of <CODE>"<I>n</I>-<I>m</I>"</CODE> is specified, the first page
|
||||
* to be printed will be page <I>n.</I> All subsequent pages of the document
|
||||
* will be printed through and including page <I>m.</I>
|
||||
* <P>
|
||||
* If a PageRanges attribute is not specified for a print job, all pages of
|
||||
* the document will be printed. In other words, the default value for the
|
||||
* PageRanges attribute is always <CODE>{{1, Integer.MAX_VALUE}}</CODE>.
|
||||
* <P>
|
||||
* The effect of a PageRanges attribute on a multidoc print job (a job with
|
||||
* multiple documents) depends on whether all the docs have the same page ranges
|
||||
* specified or whether different docs have different page ranges specified, and
|
||||
* on the (perhaps defaulted) value of the {@link MultipleDocumentHandling
|
||||
* MultipleDocumentHandling} attribute.
|
||||
* <UL>
|
||||
* <LI>
|
||||
* If all the docs have the same page ranges specified, then any value of {@link
|
||||
* MultipleDocumentHandling MultipleDocumentHandling} makes sense, and the
|
||||
* printer's processing depends on the {@link MultipleDocumentHandling
|
||||
* MultipleDocumentHandling} value:
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT -- All the input docs will be combined together into one
|
||||
* output document. The specified page ranges of that output document will be
|
||||
* printed.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together
|
||||
* into one output document, and the first impression of each input doc will
|
||||
* always start on a new media sheet. The specified page ranges of that output
|
||||
* document will be printed.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- For each separate input doc, the
|
||||
* specified page ranges will be printed.
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- For each separate input doc, the
|
||||
* specified page ranges will be printed.
|
||||
* </UL>
|
||||
* <UL>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- For each separate input doc, its own
|
||||
* specified page ranges will be printed..
|
||||
* <P>
|
||||
* <LI>
|
||||
* SEPARATE_DOCUMENTS_COLLATED_COPIES -- For each separate input doc, its own
|
||||
* specified page ranges will be printed..
|
||||
* </UL>
|
||||
* </UL>
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The PageRanges attribute's canonical array form
|
||||
* gives the lower and upper bound for each range of pages to be included in
|
||||
* and IPP "page-ranges" attribute. See class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of canonical array form. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PageRanges extends SetOfIntegerSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = 8639895197656148392L;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new page ranges attribute with the given members. The
|
||||
* members are specified in "array form;" see class {@link
|
||||
* javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an
|
||||
* explanation of array form.
|
||||
*
|
||||
* @param members Set members in array form.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>members</CODE> is null or
|
||||
* any element of <CODE>members</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (unchecked exception) Thrown if any element of
|
||||
* <CODE>members</CODE> is not a length-one or length-two array. Also
|
||||
* thrown if <CODE>members</CODE> is a zero-length array or if any
|
||||
* member of the set is less than 1.
|
||||
*/
|
||||
public PageRanges(int[][] members) {
|
||||
super (members);
|
||||
if (members == null) {
|
||||
throw new NullPointerException("members is null");
|
||||
}
|
||||
myPageRanges();
|
||||
}
|
||||
/**
|
||||
* Construct a new page ranges attribute with the given members in
|
||||
* string form.
|
||||
* See class {@link javax.print.attribute.SetOfIntegerSyntax
|
||||
* SetOfIntegerSyntax}
|
||||
* for explanation of the syntax.
|
||||
*
|
||||
* @param members Set members in string form.
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>members</CODE> is null or
|
||||
* any element of <CODE>members</CODE> is null.
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>members</CODE> does not
|
||||
* obey the proper syntax. Also
|
||||
* thrown if the constructed set-of-integer is a
|
||||
* zero-length array or if any
|
||||
* member of the set is less than 1.
|
||||
*/
|
||||
public PageRanges(String members) {
|
||||
super(members);
|
||||
if (members == null) {
|
||||
throw new NullPointerException("members is null");
|
||||
}
|
||||
myPageRanges();
|
||||
}
|
||||
|
||||
private void myPageRanges() {
|
||||
int[][] myMembers = getMembers();
|
||||
int n = myMembers.length;
|
||||
if (n == 0) {
|
||||
throw new IllegalArgumentException("members is zero-length");
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < n; ++ i) {
|
||||
if (myMembers[i][0] < 1) {
|
||||
throw new IllegalArgumentException("Page value < 1 specified");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new page ranges attribute containing a single integer. That
|
||||
* is, only the one page is to be printed.
|
||||
*
|
||||
* @param member Set member.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>member</CODE> is less than
|
||||
* 1.
|
||||
*/
|
||||
public PageRanges(int member) {
|
||||
super (member);
|
||||
if (member < 1) {
|
||||
throw new IllegalArgumentException("Page value < 1 specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new page ranges attribute containing a single range of
|
||||
* integers. That is, only those pages in the one range are to be printed.
|
||||
*
|
||||
* @param lowerBound Lower bound of the range.
|
||||
* @param upperBound Upper bound of the range.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if a null range is specified or if a
|
||||
* non-null range is specified with <CODE>lowerBound</CODE> less than
|
||||
* 1.
|
||||
*/
|
||||
public PageRanges(int lowerBound, int upperBound) {
|
||||
super (lowerBound, upperBound);
|
||||
if (lowerBound > upperBound) {
|
||||
throw new IllegalArgumentException("Null range specified");
|
||||
} else if (lowerBound < 1) {
|
||||
throw new IllegalArgumentException("Page value < 1 specified");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this page ranges attribute is equivalent to the passed
|
||||
* in object. To be equivalent, all of the following conditions must be
|
||||
* true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class PageRanges.
|
||||
* <LI>
|
||||
* This page ranges attribute's members and <CODE>object</CODE>'s members
|
||||
* are the same.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this page ranges
|
||||
* attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof PageRanges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PageRanges, the category is class PageRanges itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PageRanges.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PageRanges, the category name is <CODE>"page-ranges"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "page-ranges";
|
||||
}
|
||||
|
||||
}
|
||||
114
jdkSrc/jdk8/javax/print/attribute/standard/PagesPerMinute.java
Normal file
114
jdkSrc/jdk8/javax/print/attribute/standard/PagesPerMinute.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PagesPerMinute is an integer valued printing attribute that indicates
|
||||
* the nominal number of pages per minute to the nearest whole number which may
|
||||
* be generated by this printer (e.g., simplex, black-and-white). This attribute
|
||||
* is informative, not a service guarantee. Generally, it is the value used in
|
||||
* the marketing literature to describe the device. A value of 0 indicates a
|
||||
* device that takes more than two minutes to process a page.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PagesPerMinute extends IntegerSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = -6366403993072862015L;
|
||||
|
||||
/**
|
||||
* Construct a new pages per minute attribute with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public PagesPerMinute(int value) {
|
||||
super(value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this pages per minute attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class PagesPerMinute.
|
||||
* <LI>
|
||||
* This pages per minute attribute's value and <CODE>object</CODE>'s
|
||||
* value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this pages per
|
||||
* minute attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals (object) &&
|
||||
object instanceof PagesPerMinute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PagesPerMinute, the category is class PagesPerMinute itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PagesPerMinute.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PagesPerMinute, the
|
||||
* category name is <CODE>"pages-per-minute"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "pages-per-minute";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.IntegerSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PagesPerMinuteColor is an integer valued printing attribute that
|
||||
* indicates the nominal number of pages per minute to the nearest whole number
|
||||
* which may be generated by this printer when printing color (e.g., simplex,
|
||||
* color). For purposes of this attribute, "color" means the same as for the
|
||||
* {@link ColorSupported ColorSupported} attribute, namely, the device is
|
||||
* capable of any type of color printing at all, including highlight color as
|
||||
* well as full process color. This attribute is informative, not a service
|
||||
* guarantee. Generally, it is the value used in the marketing literature to
|
||||
* describe the color capabilities of this device. A value of 0 indicates a
|
||||
* device that takes more than two minutes to process a page. If a color device
|
||||
* has several color modes, it may use the pages-per- minute value for this
|
||||
* attribute that corresponds to the mode that produces the highest number.
|
||||
* <P>
|
||||
* A black and white only printer must not include the PagesPerMinuteColor
|
||||
* attribute in its attribute set or service registration. If this attribute is
|
||||
* present, then the {@link ColorSupported ColorSupported} printer description
|
||||
* attribute must also be present and have a value of SUPPORTED.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The integer value gives the IPP integer value. The
|
||||
* category name returned by <CODE>getName()</CODE> gives the IPP attribute
|
||||
* name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PagesPerMinuteColor extends IntegerSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
static final long serialVersionUID = 1684993151687470944L;
|
||||
|
||||
/**
|
||||
* Construct a new pages per minute color attribute with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*
|
||||
* @exception IllegalArgumentException
|
||||
* (Unchecked exception) Thrown if <CODE>value</CODE> is less than 0.
|
||||
*/
|
||||
public PagesPerMinuteColor(int value) {
|
||||
super(value, 0, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this pages per minute color attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class PagesPerMinuteColor.
|
||||
* <LI>
|
||||
* This pages per minute attribute's value and <CODE>object</CODE>'s
|
||||
* value are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this pages per
|
||||
* minute color attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) &&
|
||||
object instanceof PagesPerMinuteColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PagesPerMinuteColor, the
|
||||
* category is class PagesPerMinuteColor itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PagesPerMinuteColor.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PagesPerMinuteColor, the
|
||||
* category name is <CODE>"pages-per-minute-color"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "pages-per-minute-color";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
|
||||
/**
|
||||
* Class PresentationDirection is a printing attribute class, an enumeration,
|
||||
* that is used in conjunction with the {@link NumberUp NumberUp} attribute to
|
||||
* indicate the layout of multiple print-stream pages to impose upon a
|
||||
* single side of an instance of a selected medium.
|
||||
* This is useful to mirror the text layout conventions of different scripts.
|
||||
* For example, English is "toright-tobottom", Hebrew is "toleft-tobottom"
|
||||
* and Japanese is usually "tobottom-toleft".
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> This attribute is not an IPP 1.1
|
||||
* attribute; it is an attribute in the Production Printing Extension
|
||||
* (<a href="ftp://ftp.pwg.org/pub/pwg/standards/pwg5100.3.pdf">PDF</a>)
|
||||
* of IPP 1.1. The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Phil Race.
|
||||
*/
|
||||
public final class PresentationDirection extends EnumSyntax
|
||||
implements PrintJobAttribute, PrintRequestAttribute {
|
||||
|
||||
private static final long serialVersionUID = 8294728067230931780L;
|
||||
|
||||
/**
|
||||
* Pages are laid out in columns starting at the top left,
|
||||
* proceeding towards the bottom {@literal &} right.
|
||||
*/
|
||||
public static final PresentationDirection TOBOTTOM_TORIGHT =
|
||||
new PresentationDirection(0);
|
||||
|
||||
/**
|
||||
* Pages are laid out in columns starting at the top right,
|
||||
* proceeding towards the bottom {@literal &} left.
|
||||
*/
|
||||
public static final PresentationDirection TOBOTTOM_TOLEFT =
|
||||
new PresentationDirection(1);
|
||||
|
||||
/**
|
||||
* Pages are laid out in columns starting at the bottom left,
|
||||
* proceeding towards the top {@literal &} right.
|
||||
*/
|
||||
public static final PresentationDirection TOTOP_TORIGHT =
|
||||
new PresentationDirection(2);
|
||||
|
||||
/**
|
||||
* Pages are laid out in columns starting at the bottom right,
|
||||
* proceeding towards the top {@literal &} left.
|
||||
*/
|
||||
public static final PresentationDirection TOTOP_TOLEFT =
|
||||
new PresentationDirection(3);
|
||||
|
||||
/**
|
||||
* Pages are laid out in rows starting at the top left,
|
||||
* proceeding towards the right {@literal &} bottom.
|
||||
*/
|
||||
public static final PresentationDirection TORIGHT_TOBOTTOM =
|
||||
new PresentationDirection(4);
|
||||
|
||||
/**
|
||||
* Pages are laid out in rows starting at the bottom left,
|
||||
* proceeding towards the right {@literal &} top.
|
||||
*/
|
||||
public static final PresentationDirection TORIGHT_TOTOP =
|
||||
new PresentationDirection(5);
|
||||
|
||||
/**
|
||||
* Pages are laid out in rows starting at the top right,
|
||||
* proceeding towards the left {@literal &} bottom.
|
||||
*/
|
||||
public static final PresentationDirection TOLEFT_TOBOTTOM =
|
||||
new PresentationDirection(6);
|
||||
|
||||
/**
|
||||
* Pages are laid out in rows starting at the bottom right,
|
||||
* proceeding towards the left {@literal &} top.
|
||||
*/
|
||||
public static final PresentationDirection TOLEFT_TOTOP =
|
||||
new PresentationDirection(7);
|
||||
|
||||
/**
|
||||
* Construct a new presentation direction enumeration value with the given
|
||||
* integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
private PresentationDirection(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"tobottom-toright",
|
||||
"tobottom-toleft",
|
||||
"totop-toright",
|
||||
"totop-toleft",
|
||||
"toright-tobottom",
|
||||
"toright-totop",
|
||||
"toleft-tobottom",
|
||||
"toleft-totop",
|
||||
};
|
||||
|
||||
private static final PresentationDirection[] myEnumValueTable = {
|
||||
TOBOTTOM_TORIGHT,
|
||||
TOBOTTOM_TOLEFT,
|
||||
TOTOP_TORIGHT,
|
||||
TOTOP_TOLEFT,
|
||||
TORIGHT_TOBOTTOM,
|
||||
TORIGHT_TOTOP,
|
||||
TOLEFT_TOBOTTOM,
|
||||
TOLEFT_TOTOP,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class PresentationDirection.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class PresentationDirection.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PresentationDirection
|
||||
* the category is class PresentationDirection itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PresentationDirection.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PresentationDirection
|
||||
* the category name is <CODE>"presentation-direction"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "presentation-direction";
|
||||
}
|
||||
|
||||
}
|
||||
135
jdkSrc/jdk8/javax/print/attribute/standard/PrintQuality.java
Normal file
135
jdkSrc/jdk8/javax/print/attribute/standard/PrintQuality.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.DocAttribute;
|
||||
import javax.print.attribute.PrintRequestAttribute;
|
||||
import javax.print.attribute.PrintJobAttribute;
|
||||
|
||||
/**
|
||||
* Class PrintQuality is a printing attribute class, an enumeration,
|
||||
* that specifies the print quality that the printer uses for the job.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author David Mendenhall
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public class PrintQuality extends EnumSyntax
|
||||
implements DocAttribute, PrintRequestAttribute, PrintJobAttribute {
|
||||
|
||||
private static final long serialVersionUID = -3072341285225858365L;
|
||||
/**
|
||||
* Lowest quality available on the printer.
|
||||
*/
|
||||
public static final PrintQuality DRAFT = new PrintQuality(3);
|
||||
|
||||
/**
|
||||
* Normal or intermediate quality on the printer.
|
||||
*/
|
||||
public static final PrintQuality NORMAL = new PrintQuality(4);
|
||||
|
||||
/**
|
||||
* Highest quality available on the printer.
|
||||
*/
|
||||
public static final PrintQuality HIGH = new PrintQuality(5);
|
||||
|
||||
/**
|
||||
* Construct a new print quality enumeration value with the given integer
|
||||
* value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected PrintQuality(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"draft",
|
||||
"normal",
|
||||
"high"
|
||||
};
|
||||
|
||||
private static final PrintQuality[] myEnumValueTable = {
|
||||
DRAFT,
|
||||
NORMAL,
|
||||
HIGH
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class PrintQuality.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return (String[])myStringTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class PrintQuality.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return (EnumSyntax[])myEnumValueTable.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lowest integer value used by class PrintQuality.
|
||||
*/
|
||||
protected int getOffset() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PrintQuality and any vendor-defined subclasses, the category is
|
||||
* class PrintQuality itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PrintQuality.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PrintQuality and any vendor-defined subclasses, the category
|
||||
* name is <CODE>"print-quality"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "print-quality";
|
||||
}
|
||||
|
||||
}
|
||||
121
jdkSrc/jdk8/javax/print/attribute/standard/PrinterInfo.java
Normal file
121
jdkSrc/jdk8/javax/print/attribute/standard/PrinterInfo.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PrinterInfo is a printing attribute class, a text attribute, that
|
||||
* provides descriptive information about a printer. This could include things
|
||||
* like: <CODE>"This printer can be used for printing color transparencies for
|
||||
* HR presentations"</CODE>, or <CODE>"Out of courtesy for others, please
|
||||
* print only small (1-5 page) jobs at this printer"</CODE>, or even \
|
||||
* <CODE>"This printer is going away on July 1, 1997, please find a new
|
||||
* printer"</CODE>.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PrinterInfo extends TextSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = 7765280618777599727L;
|
||||
|
||||
/**
|
||||
* Constructs a new printer info attribute with the given information
|
||||
* string and locale.
|
||||
*
|
||||
* @param info Printer information string.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>info</CODE> is null.
|
||||
*/
|
||||
public PrinterInfo(String info, Locale locale) {
|
||||
super (info, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this printer info attribute is equivalent to the passed
|
||||
* in object. To be equivalent, all of the following conditions must be
|
||||
* true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class PrinterInfo.
|
||||
* <LI>
|
||||
* This printer info attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This printer info attribute's locale and <CODE>object</CODE>'s
|
||||
* locale are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this printer
|
||||
* info attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof PrinterInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PrinterInfo, the category is class PrinterInfo itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PrinterInfo.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PrinterInfo, the category name is <CODE>"printer-info"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "printer-info";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.EnumSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PrinterIsAcceptingJobs is a printing attribute class, an enumeration,
|
||||
* that indicates whether the printer is currently able to accept jobs. This
|
||||
* value is independent of the {@link PrinterState PrinterState} and {@link
|
||||
* PrinterStateReasons PrinterStateReasons} attributes because its value does
|
||||
* not affect the current job; rather it affects future jobs. If the value is
|
||||
* NOT_ACCEPTING_JOBS, the printer will reject jobs even when the {@link
|
||||
* PrinterState PrinterState} is IDLE. If value is ACCEPTING_JOBS, the Printer
|
||||
* will accept jobs even when the {@link PrinterState PrinterState} is STOPPED.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The IPP boolean value is "true" for ACCEPTING_JOBS
|
||||
* and "false" for NOT_ACCEPTING_JOBS. The category name returned by
|
||||
* <CODE>getName()</CODE> is the IPP attribute name. The enumeration's
|
||||
* integer value is the IPP enum value. The <code>toString()</code> method
|
||||
* returns the IPP string representation of the attribute value.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PrinterIsAcceptingJobs extends EnumSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = -5052010680537678061L;
|
||||
|
||||
/**
|
||||
* The printer is currently rejecting any jobs sent to it.
|
||||
*/
|
||||
public static final PrinterIsAcceptingJobs
|
||||
NOT_ACCEPTING_JOBS = new PrinterIsAcceptingJobs(0);
|
||||
|
||||
/**
|
||||
* The printer is currently accepting jobs.
|
||||
*/
|
||||
public static final PrinterIsAcceptingJobs
|
||||
ACCEPTING_JOBS = new PrinterIsAcceptingJobs(1);
|
||||
|
||||
/**
|
||||
* Construct a new printer is accepting jobs enumeration value with the
|
||||
* given integer value.
|
||||
*
|
||||
* @param value Integer value.
|
||||
*/
|
||||
protected PrinterIsAcceptingJobs(int value) {
|
||||
super (value);
|
||||
}
|
||||
|
||||
private static final String[] myStringTable = {
|
||||
"not-accepting-jobs",
|
||||
"accepting-jobs"
|
||||
};
|
||||
|
||||
private static final PrinterIsAcceptingJobs[] myEnumValueTable = {
|
||||
NOT_ACCEPTING_JOBS,
|
||||
ACCEPTING_JOBS
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the string table for class PrinterIsAcceptingJobs.
|
||||
*/
|
||||
protected String[] getStringTable() {
|
||||
return myStringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the enumeration value table for class PrinterIsAcceptingJobs.
|
||||
*/
|
||||
protected EnumSyntax[] getEnumValueTable() {
|
||||
return myEnumValueTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PrinterIsAcceptingJobs, the
|
||||
* category is class PrinterIsAcceptingJobs itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PrinterIsAcceptingJobs.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PrinterIsAcceptingJobs, the
|
||||
* category name is <CODE>"printer-is-accepting-jobs"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "printer-is-accepting-jobs";
|
||||
}
|
||||
|
||||
}
|
||||
119
jdkSrc/jdk8/javax/print/attribute/standard/PrinterLocation.java
Normal file
119
jdkSrc/jdk8/javax/print/attribute/standard/PrinterLocation.java
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PrinterLocation is a printing attribute class, a text attribute, that
|
||||
* identifies the location of the device. This could include things like:
|
||||
* <CODE>"in Room 123A, second floor of building XYZ"</CODE>.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PrinterLocation extends TextSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = -1598610039865566337L;
|
||||
|
||||
/**
|
||||
* Constructs a new printer location attribute with the given location and
|
||||
* locale.
|
||||
*
|
||||
* @param location Printer location.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>location</CODE> is null.
|
||||
*/
|
||||
public PrinterLocation(String location, Locale locale) {
|
||||
super (location, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this printer location attribute is equivalent to the
|
||||
* passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class PrinterLocation.
|
||||
* <LI>
|
||||
* This printer location attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This printer location attribute's locale and <CODE>object</CODE>'s
|
||||
* locale are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this printer
|
||||
* location attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) && object instanceof PrinterLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PrinterLocation, the
|
||||
* category is class PrinterLocation itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PrinterLocation.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PrinterLocation, the
|
||||
* category name is <CODE>"printer-location"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "printer-location";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package javax.print.attribute.standard;
|
||||
|
||||
import java.util.Locale;
|
||||
import javax.print.attribute.Attribute;
|
||||
import javax.print.attribute.TextSyntax;
|
||||
import javax.print.attribute.PrintServiceAttribute;
|
||||
|
||||
/**
|
||||
* Class PrinterMakeAndModel is a printing attribute class, a text attribute,
|
||||
* that the make and model of the printer.
|
||||
* <P>
|
||||
* <B>IPP Compatibility:</B> The string value gives the IPP name value. The
|
||||
* locale gives the IPP natural language. The category name returned by
|
||||
* <CODE>getName()</CODE> gives the IPP attribute name.
|
||||
* <P>
|
||||
*
|
||||
* @author Alan Kaminsky
|
||||
*/
|
||||
public final class PrinterMakeAndModel extends TextSyntax
|
||||
implements PrintServiceAttribute {
|
||||
|
||||
private static final long serialVersionUID = 4580461489499351411L;
|
||||
|
||||
/**
|
||||
* Constructs a new printer make and model attribute with the given make
|
||||
* and model string and locale.
|
||||
*
|
||||
* @param makeAndModel Printer make and model string.
|
||||
* @param locale Natural language of the text string. null
|
||||
* is interpreted to mean the default locale as returned
|
||||
* by <code>Locale.getDefault()</code>
|
||||
*
|
||||
* @exception NullPointerException
|
||||
* (unchecked exception) Thrown if <CODE>makeAndModel</CODE> is null.
|
||||
*/
|
||||
public PrinterMakeAndModel(String makeAndModel, Locale locale) {
|
||||
super (makeAndModel, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this printer make and model attribute is equivalent to
|
||||
* the passed in object. To be equivalent, all of the following conditions
|
||||
* must be true:
|
||||
* <OL TYPE=1>
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is not null.
|
||||
* <LI>
|
||||
* <CODE>object</CODE> is an instance of class PrinterMakeAndModel.
|
||||
* <LI>
|
||||
* This printer make and model attribute's underlying string and
|
||||
* <CODE>object</CODE>'s underlying string are equal.
|
||||
* <LI>
|
||||
* This printer make and model attribute's locale and
|
||||
* <CODE>object</CODE>'s locale are equal.
|
||||
* </OL>
|
||||
*
|
||||
* @param object Object to compare to.
|
||||
*
|
||||
* @return True if <CODE>object</CODE> is equivalent to this printer
|
||||
* make and model attribute, false otherwise.
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (super.equals(object) &&
|
||||
object instanceof PrinterMakeAndModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the printing attribute class which is to be used as the "category"
|
||||
* for this printing attribute value.
|
||||
* <P>
|
||||
* For class PrinterMakeAndModel, the
|
||||
* category is class PrinterMakeAndModel itself.
|
||||
*
|
||||
* @return Printing attribute class (category), an instance of class
|
||||
* {@link java.lang.Class java.lang.Class}.
|
||||
*/
|
||||
public final Class<? extends Attribute> getCategory() {
|
||||
return PrinterMakeAndModel.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the category of which this attribute value is an
|
||||
* instance.
|
||||
* <P>
|
||||
* For class PrinterMakeAndModel, the
|
||||
* category name is <CODE>"printer-make-and-model"</CODE>.
|
||||
*
|
||||
* @return Attribute category name.
|
||||
*/
|
||||
public final String getName() {
|
||||
return "printer-make-and-model";
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user