Created
December 13, 2013 20:58
-
-
Save keiono/7951230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KeggscapeFileFilter extends BasicCyFileFilter { | |
private static final Logger logger = LoggerFactory.getLogger(KeggscapeFileFilter.class); | |
private static final String KEGG_TAG = "www.kegg.jp/kegg"; | |
public KeggscapeFileFilter(Set<String> extensions, Set<String> contentTypes, String description, | |
DataCategory category, StreamUtil streamUtil) { | |
super(extensions, contentTypes, description, category, streamUtil); | |
} | |
public KeggscapeFileFilter(String[] extensions, String[] contentTypes, String description, DataCategory category, | |
StreamUtil streamUtil) { | |
super(extensions, contentTypes, description, category, streamUtil); | |
} | |
@Override | |
public boolean accepts(final InputStream stream, final DataCategory category) { | |
final String header = getHeader(stream, 5); | |
logger.debug("File header: " + header); | |
if (header.contains(KEGG_TAG)) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
@Override | |
public boolean accepts(final URI uri, final DataCategory category) { | |
try { | |
return accepts(uri.toURL().openStream(), category); | |
} catch (IOException e) { | |
logger.error("Error while opening stream: " + uri, e); | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment