Package org.cytoscape.io
Class BasicCyFileFilter
java.lang.Object
org.cytoscape.io.BasicCyFileFilter
- All Implemented Interfaces:
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.
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>
-
Field Summary
Modifier and TypeFieldDescriptionprotected final DataCategory
Type of data that this filter applies to.protected final String
protected final StreamUtil
-
Constructor Summary
ConstructorDescriptionBasicCyFileFilter
(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
Modifier and TypeMethodDescriptionboolean
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.The MIME content types supported by this filter.final DataCategory
The DataCategory supported by this filter.final String
A short, human readable description of the file extensions suitable for display in FileChoosers.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.Returns a list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.protected final String
getHeader
(InputStream stream, int numLines) Returns a string containing the specified number of lines from the beginning of the file.toString()
Returns a human readable description of this class.
-
Field Details
-
extensions
-
contentTypes
-
description
-
streamUtil
-
category
Type of data that this filter applies to.
-
-
Constructor Details
-
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 Details
-
accepts
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
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
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
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
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
Description copied from interface:CyFileFilter
The DataCategory supported by this filter.- Specified by:
getDataCategory
in interfaceCyFileFilter
- Returns:
- The DataCategory supported by this filter.
-
toString
Returns a human readable description of this class. -
getExtension
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
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.
-