edu.washington.biostr.sig.vault.files
Class AbstractFileType

java.lang.Object
  extended by edu.washington.biostr.sig.vault.files.AbstractFileType
All Implemented Interfaces:
FileType, Serializable, Comparable<FileType>
Direct Known Subclasses:
FileTypeAnd, FileTypeOr

public abstract class AbstractFileType
extends Object
implements FileType, Serializable

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface edu.washington.biostr.sig.vault.files.FileType
ACCEPTABLE, DISCOURAGED, PREFERRED
 
Constructor Summary
protected AbstractFileType(String name, String[] extensions, Icon image, int preference, boolean decodable, boolean encodable)
           
 
Method Summary
 boolean accept(FileType type)
           
 int compareTo(FileType o)
          compareTo compares the acceptable extensions.
protected static int count(String str, char object)
           
 boolean equals(Object parm1)
          Two filters are equal if they accept the same thing for all values.
 Icon getDefaultIcon(String file)
          A filetype can optionally have an icon.
 String getExtension(int extensionNum)
           
protected  SortedSet<String> getExtensions()
          Return a set of extension objects.
protected  String getMeaningfulPart(URI uri)
           
 String getName()
           
 int getPreference()
          Return PREFERRED, ACCEPTABLE (default) or DISCOURAGED.
 int getSortingSpot()
          To ensure that nodes are comparable across different types, when comparing different types, simply return:
int value = getSortingSpot() - other.getSortingSpot();
if (value == 0)
{
value = toString().compareTo(other.toString());
if (value == 0)
{
return getClass().getName().compareTo(other.getClass().getName());
}
}
return value;
 FileType getType(URI[] group)
          If this type supports subtypes, get the subtype for this group.
protected  boolean hasAllExtensions(Collection<String> filenames)
          Check that the list has all of the given extensions.
protected  boolean hasAllExtensions(URI[] filenames)
           
protected  String hasExtension(URI uri)
          Check the filename to see if it has one of the accepted extensions.
 int hashCode()
           
 boolean isDecodable()
           
 boolean isEncodable()
           
 URI[] next(SortedSet<URI> files)
          Get the next set of files that match this type and remove them from files.
 AbstractFileType setName(String name)
          Change the name
protected  String stripCompressionExtensions(String name)
           
 String toString()
           
 String toString(FileGroup group)
          Get the preferred string for this group.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.washington.biostr.sig.vault.files.FileType
accept, accept, generateFiles
 

Constructor Detail

AbstractFileType

protected AbstractFileType(String name,
                           String[] extensions,
                           Icon image,
                           int preference,
                           boolean decodable,
                           boolean encodable)
Method Detail

count

protected static int count(String str,
                           char object)

getExtensions

protected SortedSet<String> getExtensions()
Return a set of extension objects.

Returns:

hasExtension

protected String hasExtension(URI uri)
Check the filename to see if it has one of the accepted extensions. Return the accepted extension or null if it does not have that extension.

Parameters:
filename -
Returns:

stripCompressionExtensions

protected String stripCompressionExtensions(String name)

hasAllExtensions

protected boolean hasAllExtensions(Collection<String> filenames)
Check that the list has all of the given extensions. Filenames should not be very long.

Parameters:
filenames -
Returns:

getMeaningfulPart

protected String getMeaningfulPart(URI uri)

hasAllExtensions

protected boolean hasAllExtensions(URI[] filenames)

accept

public boolean accept(FileType type)
Specified by:
accept in interface FileType

getName

public String getName()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object parm1)
Two filters are equal if they accept the same thing for all values.

Overrides:
equals in class Object
Parameters:
parm1 -
Returns:

setName

public AbstractFileType setName(String name)
Change the name

Parameters:
name -
Returns:
this

compareTo

public int compareTo(FileType o)
compareTo compares the acceptable extensions. DataFileFilterGroups are always less than a general DataFileFilter. A longer extension list will make a DataFileFilter smaller if everything else is equal.

Specified by:
compareTo in interface Comparable<FileType>
Parameters:
o -
Returns:

getType

public FileType getType(URI[] group)
Description copied from interface: FileType
If this type supports subtypes, get the subtype for this group.

Specified by:
getType in interface FileType
Returns:

getDefaultIcon

public Icon getDefaultIcon(String file)
Description copied from interface: FileType
A filetype can optionally have an icon.

Specified by:
getDefaultIcon in interface FileType
Returns:

toString

public String toString()
Overrides:
toString in class Object

getSortingSpot

public int getSortingSpot()
Description copied from interface: FileType
To ensure that nodes are comparable across different types, when comparing different types, simply return:
int value = getSortingSpot() - other.getSortingSpot();
if (value == 0)
{
value = toString().compareTo(other.toString());
if (value == 0)
{
return getClass().getName().compareTo(other.getClass().getName());
}
}
return value;

Specified by:
getSortingSpot in interface FileType
Returns:
1000.

next

public URI[] next(SortedSet<URI> files)
Description copied from interface: FileType
Get the next set of files that match this type and remove them from files. Return null if there is no matching set.
Currently it is only required to get the next set that start at 0.

Specified by:
next in interface FileType
Parameters:
files - An list of files alphabatized using String's compareTo method.
Returns:

getPreference

public int getPreference()
Description copied from interface: FileType
Return PREFERRED, ACCEPTABLE (default) or DISCOURAGED.

Specified by:
getPreference in interface FileType
Returns:

toString

public String toString(FileGroup group)
Description copied from interface: FileType
Get the preferred string for this group.

Specified by:
toString in interface FileType
Returns:

isDecodable

public boolean isDecodable()
Specified by:
isDecodable in interface FileType
Returns:
true f there is a decoder for this type.

isEncodable

public boolean isEncodable()
Specified by:
isEncodable in interface FileType
Returns:
true if there is an encoder for this type.

getExtension

public String getExtension(int extensionNum)
Specified by:
getExtension in interface FileType


Copyright © 2006 University of Washington. All Rights Reserved.