Cytoscape 3.0.1 API

org.cytoscape.io
Class BasicCyFileFilter

java.lang.Object
  extended by org.cytoscape.io.BasicCyFileFilter
All Implemented Interfaces:
CyFileFilter

public class BasicCyFileFilter
extends Object
implements CyFileFilter

This is meant to be an basic implementation of CyFileFilter that can either be used directly or extended to provide different acceptance criteria. Only the accepts() methods may be overridden.


Cytoscape Backwards Compatibility (Abstract Class): This class is abstract and meant to be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Field Summary
protected  DataCategory category
          Type of data that this filter applies to.
protected  Set<String> contentTypes
           
protected  String description
           
protected  Set<String> extensions
           
protected  StreamUtil streamUtil
           
 
Constructor Summary
BasicCyFileFilter(Set<String> extensions, Set<String> contentTypes, String description, DataCategory category, StreamUtil streamUtil)
          Creates a file filter from the specified arguments.
BasicCyFileFilter(String[] extensions, String[] contentTypes, String description, DataCategory category, StreamUtil streamUtil)
          Creates a file filter from the specified arguments.
 
Method Summary
 boolean accepts(InputStream stream, DataCategory category)
          This method always returns false in this particular implementation.
 boolean accepts(URI uri, DataCategory category)
          A method that attempts to determine whether the specified URI can be read by the Reader using this filter.
 Set<String> getContentTypes()
          The MIME content types supported by this filter.
 DataCategory getDataCategory()
          The DataCategory supported by this filter.
 String getDescription()
          A short, human readable description of the file extensions suitable for display in FileChoosers.
protected  String getExtension(String filename)
          Returns a string of the characters following the last '.' in the input string, which is to say the file extension assuming that the input string represents a file name.
 Set<String> getExtensions()
          Returns a list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.
protected  String getHeader(InputStream stream, int numLines)
          Returns a string containing the specified number of lines from the beginning of the file.
 String toString()
          Returns a human readable description of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

extensions

protected final Set<String> extensions

contentTypes

protected final Set<String> contentTypes

description

protected final String description

streamUtil

protected final StreamUtil streamUtil

category

protected final DataCategory category
Type of data that this filter applies to.

Constructor Detail

BasicCyFileFilter

public BasicCyFileFilter(Set<String> extensions,
                         Set<String> contentTypes,
                         String description,
                         DataCategory category,
                         StreamUtil streamUtil)
Creates a file filter from the specified arguments. Note that a "." before the extension is not needed and will be ignored.

Parameters:
extensions - The set of valid extensions for this filter.
contentTypes - The set of valid MIME content types that this filter should recognize.
description - A human readable description of the filter.
category - The type of data this filter is meant to support.
streamUtil - An instance of the StreamUtil service.

BasicCyFileFilter

public BasicCyFileFilter(String[] extensions,
                         String[] contentTypes,
                         String description,
                         DataCategory category,
                         StreamUtil streamUtil)
Creates a file filter from the specified arguments. Note that a "." before the extension is not needed and will be ignored.

Parameters:
extensions - The set of valid extensions for this filter.
contentTypes - The set of valid MIME content types that this filter should recognize.
description - A human readable description of the filter.
category - The type of data this filter is meant to support.
streamUtil - An instance of the StreamUtil service.
Method Detail

accepts

public boolean accepts(URI uri,
                       DataCategory category)
A method that attempts to determine whether the specified URI can be read by the Reader using this filter.

Specified by:
accepts in interface CyFileFilter
Parameters:
uri - The URI to be checked.
category - The data category of URI.
Returns:
True if we believe the URI can be read, false otherwise.

accepts

public boolean accepts(InputStream stream,
                       DataCategory category)
This method always returns false in this particular implementation. You must extend this class and override this method to get alternative behavior. Ideally this method would return true if this class is capable of processing the specified InputStream.

Specified by:
accepts in interface CyFileFilter
Parameters:
stream - The stream that references the file we'd like to read.
category - The type of input that we're considering.
Returns:
Always returns false in this particular implementation.

getExtensions

public final Set<String> getExtensions()
Returns a list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.

Specified by:
getExtensions in interface CyFileFilter
Returns:
A list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.

getContentTypes

public final Set<String> getContentTypes()
The MIME content types supported by this filter.

Specified by:
getContentTypes in interface CyFileFilter
Returns:
A set of strings the describe the different MIME types supported by this filter.

getDescription

public final String getDescription()
A short, human readable description of the file extensions suitable for display in FileChoosers.

Specified by:
getDescription in interface CyFileFilter
Returns:
A string describing this file type.

getDataCategory

public final DataCategory getDataCategory()
The DataCategory supported by this filter.

Specified by:
getDataCategory in interface CyFileFilter
Returns:
The DataCategory supported by this filter.

toString

public String toString()
Returns a human readable description of this class.

Overrides:
toString in class Object
Returns:
a human readable description of this class.

getExtension

protected final String getExtension(String filename)
Returns a string of the characters following the last '.' in the input string, which is to say the file extension assuming that the input string represents a file name. Will return null if no '.' is found.

Parameters:
filename - the file name as a string.
Returns:
a string representing the file extension of the input string.

getHeader

protected final String getHeader(InputStream stream,
                                 int numLines)
Returns a string containing the specified number of lines from the beginning of the file. This is useful for testing input streams.

Parameters:
stream - the input stream from which to read the header.
numLines - the number of lines from the beginning of the file.
Returns:
a string containing the specified number of lines from the beginning of the file.

Cytoscape 3.0.1 API

Copyright 2011 Cytoscape Consortium. All rights reserved.