public class BasicCyFileFilter extends Object implements CyFileFilter
CyFileFilter
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>
Modifier and Type | Field and 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 and Description |
---|
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.
|
Modifier and Type | Method and 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.
|
protected final String description
protected final StreamUtil streamUtil
protected final DataCategory category
public BasicCyFileFilter(Set<String> extensions, Set<String> contentTypes, String description, DataCategory category, StreamUtil streamUtil)
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.public BasicCyFileFilter(String[] extensions, String[] contentTypes, String description, DataCategory category, StreamUtil streamUtil)
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.public boolean accepts(URI uri, DataCategory category)
accepts
in interface CyFileFilter
uri
- The URI to be checked.category
- The data category of URI.public boolean accepts(InputStream stream, DataCategory category)
accepts
in interface CyFileFilter
stream
- The stream that references the file we'd like to read.category
- The type of input that we're considering.public final Set<String> getExtensions()
getExtensions
in interface CyFileFilter
public final Set<String> getContentTypes()
getContentTypes
in interface CyFileFilter
public final String getDescription()
getDescription
in interface CyFileFilter
public final DataCategory getDataCategory()
getDataCategory
in interface CyFileFilter
public String toString()
protected final String getExtension(String filename)
filename
- the file name as a string.protected final String getHeader(InputStream stream, int numLines)
stream
- the input stream from which to read the header.numLines
- the number of lines from the beginning of the file.Copyright 2011-2015 Cytoscape Consortium. All rights reserved.