// Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java
// public class CatalogItem {
// 	private String title = "";
// 	private String url = "";
// 	private String name = "";
// 	private Date date = null;
// 	private String compressedSize = "";
// 	private String fullSize = "";
// 
// 	private boolean stateLocal = false;
// 	private boolean stateNewer = false;
// 
// 
// 	public CatalogItem() {
// 	}
// 
// 
// 	public void setTitle( String s ) {
// 		title = (( s != null ) ? s : "");
// 	}
// 
// 	public String getTitle() {
// 		return title;
// 	}
// 
// 	public void setUrl( String s ) {
// 		url = (( s != null ) ? s : "");
// 	}
// 
// 	public String getUrl() {
// 		return url;
// 	}
// 
// 	public void setName( String s ) {
// 		name = (( s != null ) ? s : "");
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setDate( Date d ) {
// 		date = d;
// 	}
// 
// 	public Date getDate() {
// 		return date;
// 	}
// 
// 	/**
// 	 * Sets the reported size of the zip file that wraps the UHS file.
// 	 */
// 	public void setCompressedSize( String s ) {
// 		compressedSize = (( s != null ) ? s : "");
// 	}
// 
// 	public String getCompressedSize() {
// 		return compressedSize;
// 	}
// 
// 	/**
// 	 * Sets the reported size of the UHS file, once extracted from the zip file.
// 	 */
// 	public void setFullSize( String s ) {
// 		fullSize = (( s != null ) ? s : "");
// 	}
// 
// 	public String getFullSize() {
// 		return fullSize;
// 	}
// 
// 
// 	/**
// 	 * Sets whether there is a local file with this catalog entry's name.
// 	 *
// 	 * @see #resetState()
// 	 */
// 	public void setLocal( boolean b ) {
// 		stateLocal = b;
// 	}
// 
// 	public boolean isLocal() {
// 		return stateLocal;
// 	}
// 
// 	/**
// 	 * Sets whether the catalog entry is newer than the local file.
// 	 *
// 	 * @see #resetState()
// 	 */
// 	public void setNewer( boolean b ) {
// 		stateNewer = b;
// 	}
// 
// 	public boolean isNewer() {
// 		return stateNewer;
// 	}
// 
// 	/**
// 	 * Resets the catalog-vs-local state flage.
// 	 *
// 	 * @see #setLocal(boolean)
// 	 * @see #setNewer(boolean)
// 	 */
// 	public void resetState() {
// 		setLocal( false );
// 		setNewer( false );
// 	}
// 
// 
// 	@Override
// 	public String toString() {
// 		return getTitle();
// 	}
// }
// 
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java
// public class FetchUnitException extends Exception {
// 
// 
//     public FetchUnitException() {
// 	}
// 
// 	public FetchUnitException( String message ) {
// 		super(message);
// 	}
// 
// 	public FetchUnitException( Throwable cause ) {
// 		super( cause );
// 	}
// 
// 	public FetchUnitException( String message, Throwable cause ) {
// 		super( message, cause );
// 	}
// }


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry;
import javax.swing.SwingWorker;
import net.vhati.openuhs.core.downloader.CatalogItem;
import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;
package net.vhati.openuhs.desktopreader.downloader;




/**
 * A background task that downloads a hint file, while unzipping it.
 * <p>
 * Progress can be monitored with a PropertyChangeListener.
 * <p>
 * Available properties:
 * <ul>
 * <li>state: One of the SwingWorker.StateValue constants.</li>
 * <li>progress: Overall progress, from 0 to 100.</li>
 * <li>PROP_UNIT_NAME: the name of an individual download currently in progress.</li>
 * <li>PROP_UNIT_PROGRESS: progress for an individual download.</li>
 * </ul>
 */
public class UHSFetchTask extends SwingWorker<List<UHSFetchTask.UHSFetchResult>, Object> {

	// First generic is the result, returned by doInBackground().
	// Second generic is for returning intermediate results while running. (Unused)

	public static final String PROP_UNIT_NAME = "unitName";
	public static final String PROP_UNIT_PROGRESS = "unitProgress";

	private volatile boolean aborting = false;
	private String userAgent = System.getProperty( "http.agent" );

	private File destDir;
// Path: core/src/main/java/net/vhati/openuhs/core/downloader/CatalogItem.java
// public class CatalogItem {
// 	private String title = "";
// 	private String url = "";
// 	private String name = "";
// 	private Date date = null;
// 	private String compressedSize = "";
// 	private String fullSize = "";
// 
// 	private boolean stateLocal = false;
// 	private boolean stateNewer = false;
// 
// 
// 	public CatalogItem() {
// 	}
// 
// 
// 	public void setTitle( String s ) {
// 		title = (( s != null ) ? s : "");
// 	}
// 
// 	public String getTitle() {
// 		return title;
// 	}
// 
// 	public void setUrl( String s ) {
// 		url = (( s != null ) ? s : "");
// 	}
// 
// 	public String getUrl() {
// 		return url;
// 	}
// 
// 	public void setName( String s ) {
// 		name = (( s != null ) ? s : "");
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setDate( Date d ) {
// 		date = d;
// 	}
// 
// 	public Date getDate() {
// 		return date;
// 	}
// 
// 	/**
// 	 * Sets the reported size of the zip file that wraps the UHS file.
// 	 */
// 	public void setCompressedSize( String s ) {
// 		compressedSize = (( s != null ) ? s : "");
// 	}
// 
// 	public String getCompressedSize() {
// 		return compressedSize;
// 	}
// 
// 	/**
// 	 * Sets the reported size of the UHS file, once extracted from the zip file.
// 	 */
// 	public void setFullSize( String s ) {
// 		fullSize = (( s != null ) ? s : "");
// 	}
// 
// 	public String getFullSize() {
// 		return fullSize;
// 	}
// 
// 
// 	/**
// 	 * Sets whether there is a local file with this catalog entry's name.
// 	 *
// 	 * @see #resetState()
// 	 */
// 	public void setLocal( boolean b ) {
// 		stateLocal = b;
// 	}
// 
// 	public boolean isLocal() {
// 		return stateLocal;
// 	}
// 
// 	/**
// 	 * Sets whether the catalog entry is newer than the local file.
// 	 *
// 	 * @see #resetState()
// 	 */
// 	public void setNewer( boolean b ) {
// 		stateNewer = b;
// 	}
// 
// 	public boolean isNewer() {
// 		return stateNewer;
// 	}
// 
// 	/**
// 	 * Resets the catalog-vs-local state flage.
// 	 *
// 	 * @see #setLocal(boolean)
// 	 * @see #setNewer(boolean)
// 	 */
// 	public void resetState() {
// 		setLocal( false );
// 		setNewer( false );
// 	}
// 
// 
// 	@Override
// 	public String toString() {
// 		return getTitle();
// 	}
// }
// 
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java
// public class FetchUnitException extends Exception {
// 
// 
//     public FetchUnitException() {
// 	}
// 
// 	public FetchUnitException( String message ) {
// 		super(message);
// 	}
// 
// 	public FetchUnitException( Throwable cause ) {
// 		super( cause );
// 	}
// 
// 	public FetchUnitException( String message, Throwable cause ) {
// 		super( message, cause );
// 	}
// }


// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/UHSFetchTask.java
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry;
import javax.swing.SwingWorker;
import net.vhati.openuhs.core.downloader.CatalogItem;
import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;

package net.vhati.openuhs.desktopreader.downloader;




/**
 * A background task that downloads a hint file, while unzipping it.
 * <p>
 * Progress can be monitored with a PropertyChangeListener.
 * <p>
 * Available properties:
 * <ul>
 * <li>state: One of the SwingWorker.StateValue constants.</li>
 * <li>progress: Overall progress, from 0 to 100.</li>
 * <li>PROP_UNIT_NAME: the name of an individual download currently in progress.</li>
 * <li>PROP_UNIT_PROGRESS: progress for an individual download.</li>
 * </ul>
 */
public class UHSFetchTask extends SwingWorker<List<UHSFetchTask.UHSFetchResult>, Object> {

	// First generic is the result, returned by doInBackground().
	// Second generic is for returning intermediate results while running. (Unused)

	public static final String PROP_UNIT_NAME = "unitName";
	public static final String PROP_UNIT_PROGRESS = "unitProgress";

	private volatile boolean aborting = false;
	private String userAgent = System.getProperty( "http.agent" );

	private File destDir;
	private CatalogItem[] catItems;