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 ofCyFileFilterthat can either be used directly or extended to provide different acceptance criteria. Only the accepts() methods may be overridden.Module:
io-apiTo 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 DataCategorycategoryType of data that this filter applies to.protected Set<String>contentTypesprotected Stringdescriptionprotected Set<String>extensionsprotected StreamUtilstreamUtil
-
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 booleanaccepts(InputStream stream, DataCategory category)This method always returns false in this particular implementation.booleanaccepts(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.DataCategorygetDataCategory()The DataCategory supported by this filter.StringgetDescription()A short, human readable description of the file extensions suitable for display in FileChoosers.protected StringgetExtension(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 StringgetHeader(InputStream stream, int numLines)Returns a string containing the specified number of lines from the beginning of the file.StringtoString()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:CyFileFilterA method that attempts to determine whether the specified URI can be read by the Reader using this filter.- Specified by:
acceptsin 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:
acceptsin 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:CyFileFilterReturns a list of file extensions (xml, xgmml, sif) suitable for for use in FileChoosers.- Specified by:
getExtensionsin 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:CyFileFilterThe MIME content types supported by this filter.- Specified by:
getContentTypesin 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:CyFileFilterA short, human readable description of the file extensions suitable for display in FileChoosers.- Specified by:
getDescriptionin interfaceCyFileFilter- Returns:
- A string describing this file type.
-
getDataCategory
public final DataCategory getDataCategory()
Description copied from interface:CyFileFilterThe DataCategory supported by this filter.- Specified by:
getDataCategoryin 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.
-
-