Package org.cytoscape.io
Class BasicCyFileFilter
- java.lang.Object
-
- org.cytoscape.io.BasicCyFileFilter
-
- All Implemented Interfaces:
CyFileFilter
public class BasicCyFileFilter extends Object implements CyFileFilter
This is meant to be an basic implementation ofCyFileFilter
that can either be used directly or extended to provide different acceptance criteria. Only the accepts() methods may be overridden.Module:
io-api
To use this in your app, include the following dependency in your POM:
<dependency> <groupId>org.cytoscape</groupId> <artifactId>io-api</artifactId> </dependency>
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
Fields Modifier and Type Field Description 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
Constructors Constructor Description BasicCyFileFilter(String[] extensions, String[] contentTypes, String description, DataCategory category, StreamUtil streamUtil)
Creates a file filter from the specified arguments.BasicCyFileFilter(Set<String> extensions, Set<String> contentTypes, String description, DataCategory category, StreamUtil streamUtil)
Creates a file filter from the specified arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
Field Detail
-
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)
Description copied from interface:CyFileFilter
A method that attempts to determine whether the specified URI can be read by the Reader using this filter.- Specified by:
accepts
in interfaceCyFileFilter
- 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 interfaceCyFileFilter
- 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()
Description copied from interface:CyFileFilter
Returns a list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.- Specified by:
getExtensions
in interfaceCyFileFilter
- Returns:
- A list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.
-
getContentTypes
public final Set<String> getContentTypes()
Description copied from interface:CyFileFilter
The MIME content types supported by this filter.- Specified by:
getContentTypes
in interfaceCyFileFilter
- Returns:
- A set of strings the describe the different MIME types supported by this filter.
-
getDescription
public final String getDescription()
Description copied from interface:CyFileFilter
A short, human readable description of the file extensions suitable for display in FileChoosers.- Specified by:
getDescription
in interfaceCyFileFilter
- Returns:
- A string describing this file type.
-
getDataCategory
public final DataCategory getDataCategory()
Description copied from interface:CyFileFilter
The DataCategory supported by this filter.- Specified by:
getDataCategory
in interfaceCyFileFilter
- Returns:
- The DataCategory supported by this filter.
-
toString
public String toString()
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.
-
-