//******************************************************************************
//
// File:    URLDoc.java
// Package: org.jpwg.jini.print.data
// Unit:    Class org.jpwg.jini.print.data.URLDoc
//
//******************************************************************************

package org.jpwg.jini.print.data;

import java.net.URL;

import javax.print.attribute.DocAttributeSet;

import javax.print.DocFlavor;

/**
 * Class URLDoc is an implementation of interface {@link net.jini.print.data.Doc 
 * Doc} that provides a printer-accessed file as a piece of print data in a doc 
 * flavor with MIME type given by the client and representation class name = 
 * <CODE>"java.net.URL"</CODE>. The {@link AbstractDoc#getPrintData() 
 * <CODE>getPrintData()</CODE>} method returns a URL, and the return value can 
 * be cast from class Object to class java.net.URL. Thus, when the Print Job 
 * asks the URLDoc for the print data representation object, the file's URL 
 * address is passed to the Print Job, and the printer accesses the URL directly 
 * without involving the client. If the printer cannot access the URL for some 
 * reason, the print job will fail. (If the client can access the URL but the 
 * printer cannot, use class {@link InputStreamDoc InputStreamDoc} instead.) 
 * <P>
 * Class URLDoc stores the URL to be printed in an internal field. If a URLDoc 
 * object is passed as an argument or return value of a remote method invocation 
 * (RMI), the URL is serialized and sent to the remote location inside the 
 * URLDoc object. 
 * <P>
 * <B>DRAFT STANDARD VERSION 1.0 (23-MAY-2000)</B>
 *
 * @author  Alan Kaminsky
 * @version 18-May-2000
 */
public class URLDoc
	extends AbstractDoc
	{

// Exported constructors.

	/**
	 * Construct a URL doc object to read the given URL.
	 *
	 * @param  theURL         URL of the file to be printed.
	 * @param  theMimeType    MIME media type string giving the format of the
	 *                        file.
	 * @param  theAttributes  Unmodifiable set of printing attributes, or null
	 *                        to request the Print Job's default values. 
	 *
	 * @exception  NullPointerException
	 *     (unchecked exception) Thrown if <CODE>theURL</CODE> is null or
	 *     <CODE>theMimeType</CODE> is null. 
	 * @exception  IllegalArgumentException
	 *     (unchecked exception) Thrown if <CODE>theMimeType</CODE> does not 
	 *     obey the syntax for a MIME media type string. 
	 */
	public URLDoc
		(URL theURL,
		 String theMimeType,
		 DocAttributeSet theAttributes)
		{
		super (new DocFlavor.URL (theMimeType), verify (theURL), theAttributes);
		}

	private static URL verify
		(URL theURL)
		{
		if (theURL == null)
			{
			throw new NullPointerException
				("org.jpwg.jini.print.data.URLDoc.URLDoc(): theURL is null");
			}
		return theURL;
		}

	}