megamek.client.ui.AWT.util
Class ImageFileFactory

java.lang.Object
  extended by megamek.client.ui.AWT.util.ImageFileFactory
All Implemented Interfaces:
java.io.FilenameFilter, ItemFileFactory

public class ImageFileFactory
extends java.lang.Object
implements ItemFileFactory

This class will produce Image objects from files. If an image file is inside of JAR and ZIP file, then it must save the contents to a temporary file.

Created on January 18, 2004

Version:
1
Author:
James Damour

Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          The method that must be implemented by any object that filters filenames (i.e., selects a subset of filenames from a list of filenames).
 boolean accept(java.util.zip.ZipFile zipFile, java.lang.String name)
          The method that must be implemented by any object that filters filenames within a ZipFile (i.e., selects a subset of filenames from a list of filenames in a ZIP archive).
static ImageFileFactory getInstance()
          Get the Singleton ImageFileFactory.
 ItemFile getItemFile(java.io.File file)
          Get the ItemFile for the given File.
 ItemFile getItemFile(java.util.zip.ZipEntry zipEntry, java.util.zip.ZipFile zipFile)
          Get the ItemFile for the given ZipEntry in the ZipFile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ImageFileFactory getInstance()
Get the Singleton ImageFileFactory.

Returns:
the Singleton ImageFileFactory.

getItemFile

public ItemFile getItemFile(java.io.File file)
                     throws java.lang.IllegalArgumentException
Get the ItemFile for the given File.

Specified by:
getItemFile in interface ItemFileFactory
Parameters:
file - - the input File object that will be read to produce the item. This value must not be null.
Returns:
an ItemFile for the given file.
Throws:
IllegalArgumentException - if the file is null.
java.lang.IllegalArgumentException

getItemFile

public ItemFile getItemFile(java.util.zip.ZipEntry zipEntry,
                            java.util.zip.ZipFile zipFile)
                     throws java.lang.IllegalArgumentException
Get the ItemFile for the given ZipEntry in the ZipFile.

Specified by:
getItemFile in interface ItemFileFactory
Parameters:
zipEntry - - the ZipEntry that will be read to produce the item. This value must not be null.
zipFile - - the ZipFile object that contains the ZipEntry that will produce the item. This value must not be null.
Returns:
an ItemFile for the given zip file entry.
Throws:
IllegalArgumentException - if either the zipEntry or the zipFile is null.
java.lang.IllegalArgumentException

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
The method that must be implemented by any object that filters filenames (i.e., selects a subset of filenames from a list of filenames).

This definition is copied from java.io.FilenameFilter for completeness.

Specified by:
accept in interface java.io.FilenameFilter
Specified by:
accept in interface ItemFileFactory
Parameters:
dir - - the File object of the directory containing the named file.
name - - the String name of the file.

accept

public boolean accept(java.util.zip.ZipFile zipFile,
                      java.lang.String name)
The method that must be implemented by any object that filters filenames within a ZipFile (i.e., selects a subset of filenames from a list of filenames in a ZIP archive).

Specified by:
accept in interface ItemFileFactory
Parameters:
zipFile - - the ZipFile object that contains the named file's entry.
name - - the String name of the file.